1、传统方式
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<span style= "font-size:18px;" >$( function () { $(dg).datagrid({ url: url, queryParams: { qsrq: qsrq, zzrq: zzrq } }); }) <table id= "DataGrid" class= "easyui-datagrid" fit= "true" border= "false" toolbar= "#TBar" pagination= "true" data-options= "pageSize:20,pageList: [10, 20, 30, 40, 50,100,5000],idField:'chjid',sortName:'chjbh', queryParams: { 'action': 'query'}" rownumbers= "true" singleSelect= "true" url= "../Source/JiChu/chjdoc.ashx" > <thead> <tr> </tr> </thead> </table></span> |
2、原因分析及解决方案
html代码中利用class声明了datagrid,导致easyUI解析class代码的时候先解析class声明中的datagrid,这样组件就请求了一次url;然后又调用js初始化代码请求一次url。这样导致了重复加载,解决的方法就是只用一种初始化方法来声明easyUI组件以避免重复的提交请求,即删除html中的class声明(class="easyui-datagrid"),修改后的代码如下:
1
2
3
4
5
6
7
8
|
< span style = "font-size:18px;" >< table id = "DataGrid" fit = "true" border = "false" toolbar = "#TBar" pagination = "true" data-options = "pageSize:20,pageList: [10, 20, 30, 40, 50,100,5000],idField:'chjid',sortName:'chjbh'" rownumbers = "true" singleSelect = "true" url = "../Source/JiChu/chjdoc.ashx" > < thead > < tr > </ tr > </ thead > </ table ></ span > |