在做项目中遇到每次删除或者编辑后,再进行其他操作,会保留原来选中的行号,试验了多种方法,最终用这种方法解决了:

  //重新加载当前页
  $('#ylDataGrid').datagrid('reload');
  //清除所有选择(搞定)
 $('#ylDataGrid').datagrid('clearSelections');

如果是需要清除ajax缓存,则可以用在传参后加randnum: Math.floor(Math.random() * 1000000):

//2.1.3绑定数据
//当用户单击修改的时候,显示部门信息
         function BindData() {
             //首先获取用户选择的ID信息
             var BindID = $('#ylDataGrid').datagrid('getChecked')[0].roleid;
             //使用异步发送时间的请求
             $.getJSON("/Role/BindData", { id: BindID, randnum: Math.floor(Math.random() * 1000000) }, function (data) {
                 console.info(data);
                 $("#roleid").val(data.roleid);
                 $("#rolename1").val(data.rolename);
                 $("#description").val(data.description);
                 $('#gentime').datetimebox('setValue', data.gentime);
             });
         }

相关文章: