easyui的datagrid中,操作记录成功,重新加载datagrid后,继续点操作按钮,仍可把之前那条记录进行请求,正常情况应该是,操作成功后再去点击,应提示没有被选中的记录。现在这个情景说明,在datagrid操作数据重新加载后,当datagrid调用getSelections方法时,仍能返回之前使用的那条记录。这时,要解决这个问题,应该在操作完数据重新加载datagrid后再清空selections。
代码如下:
<div data-options="region:'center'" border="false">
<table id="dataGrid" class="easyui-datagrid"
data-options="rownumbers:true
,idField :'id'
,singleSelect:true
,rowStyler:styler
,view: detailview
,autoRowHeight:false
,fitColumns:false
,toolbar:'#gridTools'
,detailFormatter:detailFormatter
,onExpandRow:onExpandRow
,striped:true
,pagination:true
,pageSize:'${pageSize}'
,fit:true
,url:'${currentBaseUrl}/list'
,queryParams:queryParamsHandler()
,onLoadSuccess:dataGridLoadSuccess
,method:'get'">
<thead>
<tr>
<th field="id" hidden="hidden"></th>
<th field="orderSn" width="150" align="center" >订单号</th>
<th field="orderType" width="150" align="center" formatter="orderType">订单类型</th>
<th field="name" width="120" align="center" >买家用户名</th>
<th field="sellerName" width="120" align="center" >店铺</th>
<th field="moneyProduct" width="80" align="center">商品金额</th>
<th field="moneyOrder" width="80" align="center">订单总金额</th>
<th field="paymentStatus" width="70" align="center" formatter="paymentStatus">付款状态</th>
<th field="orderState" width="80" align="center" formatter="getState">订单状态</th>
<th field="invoiceStatus" width="70" align="center" formatter="invoiceStatus">发票状态</th>
<th field="invoiceTitle" width="100" align="center">发票抬头</th>
<th field="invoiceType" width="70" align="center">发票类型</th>
<th field="paymentName" width="70" align="center">支付方式</th>
<th field="logisticsName" width="80" align="center">物流名称</th>
<th field="logisticsNumber" width="100" align="center">快递单号</th>
<th field="deliverTime" width="150" align="center">发货时间</th>
<th field="createTime" width="150" align="center" formatter="formatDatetime">创建时间</th>
<th field="updateTime" width="150" align="center" formatter="formatDatetime">修改时间</th>
</tr>
</thead>
</table>
<div id="gridTools">
<@shiro.hasPermission name="/seller/order/orders/serviceover">
<a id="a_serviceover" href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" plain="true">服务完成</a>
</@shiro.hasPermission>
</div>
</div>
加上这个就好啦!!
$('#dataGrid').datagrid('clearSelections');