根据已经加载好的datagrid数据,通过条件查询进行重新根据查询的条件进行加载:(无需通过后台再次查询)
根据已经加载好的datagrid数据,通过条件查询进行重新根据查询的条件进行加载:
<div data-options="region:'north',border:false" style="height:32px;padding:0px">
<table>
<tr>
<td style="font-size: 15">商品编号:</td>
<td><input class="easyui-numberbox" id="goodsNumber"
name="goodsNumber" value=""></input></td>
<td style="font-size: 15">商品名称:</td>
<td><input class="easyui-textbox" id="goodsName"
name="goodsName" value=""></input></td>
<td><a id="ss" class="easyui-linkbutton"
data-options="iconCls:'icon-search'">查找</a>
</td>
<script type="text/javascript">
/* 根据当前加载完成后的datagrid,通过条件进行重新加载 */
$('#ss').click(function() {
/* alert(12); */
var goodsNumber = $('#goodsNumber').numberbox('getValue');
var goodsName = $('#goodsName').textbox('getValue');
/* var prescribedUnitType = $("#prescribedUnitType").combobox("getValue"); */
alert(goodsNumber);
alert(goodsName);
if(goodsNumber != "" || goodsName != ""){
/* $('#d').datagrid({
iconCls: 'icon-edit',
rownumbers:true,
singleSelect:false,
autoRowHeight:false,
url:"${pageContext.request.contextPath}/selectStockStatementByShopGoods.action?goodsNumber = "+goodsNumber+"&"+"goodsName = "+goodsName,
method:'get',
}); */
var newData = [];
var gridData = $('#d').datagrid('getData');
for(var i = 0;i < gridData.total;i++){
if(gridData.rows[i].number == goodsNumber || gridData.rows[i].name == goodsName){
newData.push(gridData.rows[i]);
}
}
$('#d').datagrid('loadData',newData);
}else{
alert("请正确填写查询内容!")
}
});
</script>
</table>
</div>