Title: datagrid scrollview request the service twice when no json data return?
Post by: frankgao on February 17, 2016, 08:50:58 PM
This problem existing for a long time. I have not fix it. The page have a datagrid. the view type is scrollview, When search not exist in my database query. I click the doSearchPage2(). I found out the datagrid refresh(load) twice.If search the data exist,the datagrid load once,it's normal. <div id="tb2" style="padding:0px;height:auto"> <div> Type Name: <input id="btntypename" class="easyui-textbox pagetextbox" type="text"> <a id="btnLoad2" href="#" class="easyui-linkbutton" iconcls="icon-search" onclick="doSearchPage2()">Query1</a> </div> </div>
<div id="tb" style="padding:0px;height:auto"> <div> Code: <input id="btnum" class="easyui-textbox pagetextbox" type="text"> Name: <input id="btnname" class="easyui-textbox pagetextbox" type="text"> <a id="btnLoad" href="#" class="easyui-linkbutton" iconcls="icon-search" onclick="doSearchPage()">Query2</a> </div> </div>
<div id="main_layout" class="easyui-layout" style="width:100%;height:100%;"> <div id="p" data-options="region:'west',split:true" title="List" style="width:25%;padding:0px"> <div id="gridtype" inline="true"></div> </div> <div data-options="region:'center'" title="Detail"> </div> </div>
$(function () { $('#gridtype').datagrid({ title: '', url: '/Box/BaseDetail/TypeReload', method: 'get', dataType: "json", fit: true, toolbar: '#tb2', fitColumns: true, rownumbers: true, striped: true, view: scrollview, autoRowHeight: false, remoteSort: false, columns: [[ { field: 'type_number', title: 'Type Code', width: '100px', sortable: true }, { field: 'type_name', title: 'Type Name', width: '100px', sortable: true } ]], queryParams: { typenumber: '', typename: $('#btntypename').val() }, singleSelect: true, onLoadSuccess: function (data2) { if (data2.rows.length > 0) { $(this).datagrid("selectRow", 0); } }, onClickRow: function (rowIndex, rowData) { doSearchPage(); } });
});
function doSearchPage2() { $("#gridtype").datagrid('load', { typenumber: '', typename: $('#btntypename').val() }); }
function doSearchPage() { //omit code }
|