Extjs中的帮助文档中都是些简单的查询,grid的分页查询只是默认传入start,limit,sort,dir等参数,但实际情况中可能需要传入自定义参数,试了好多次都没有发布传入
在网上找一个一个办法,利用JsonStore的beforeload事件来强制添加自定义的参数列表即可以实现,关键代码如下:
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
var ds = new Ext.data.JsonStore(
{
2
url: "../Handlers/PageHandlerPage.aspx",
3
//url: "../Handlers/PageHandler.ashx",
4
root: "root",
5
totalProperty: "totalProperty",
6
id: "id",
7![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
baseParams:
{id:Ext.get("txtId").dom.value,name:Ext.get("txtName").dom.value},
8
fields:["id","name","descn"
9
],
10
remoteSort:true
11
});
12![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
ds.on("beforeload", function(thiz, options)
{
14
//debugger
15
thiz.baseParams["id"] = Ext.get("txtId").dom.value;
16
thiz.baseParams["name"] = Ext.get("txtName").dom.value;
17
});
希望对大家有帮助。