简体   繁体   English

使用Ext表单中的值重新加载下一个JSON数据网格ExtJS

[英]Reload Next JSON Data Grid ExtJS with Value from Ext Form

I'm trying to create grid data view from ExtJS with pagination. 我正在尝试通过分页从ExtJS创建网格数据视图。
Actually there's no issue when I create a simple data grid. 实际上,当我创建一个简单的数据网格时没有问题。
Then I want to create a "filter/search" function using Ext Form. 然后,我想使用Ext Form创建一个“过滤/搜索”功能。
It's only work for page one. 仅适用于第一页。 Here is my Ext Form Code below : 这是我的Ext表格代码如下:

var winFilter = Ext.create('widget.window',{
title   : 'Filter',
width  : 400,
height : 200,
modal  : true,
closeAction    : 'hide',
items  : frmFilter,
layout : 'fit',
bodyPadding: 5,
buttons:[
{
    text    : 'Filter',
    handler: function(btn){
        var win = btn.up('window');
        var form = win.down('form');
        tempProductID = form.getForm().findField('Product_ID').getSubmitValue();
        tempDescription = form.getForm().findField('Description').getSubmitValue();
        store.load({
            params: {
                start: 0,
                limit: itemsPerPage,
                productid: form.getForm().findField('Product_ID').getSubmitValue(),
                description: form.getForm().findField('Description').getSubmitValue()
            }
        });
        winFilter.hide();
    }
},
{
    text    : 'Close',
        handler: function(){
        winFilter.hide();
    }
}
]});

for the next page, my JSON return all data without using filtering value that I used before (Product ID and Description). 对于下一页,我的JSON返回所有数据,而不使用之前使用的过滤值(产品ID和描述)。
Please if any advice 如果有任何建议请

Thanks bud. 谢谢芽。

params (when used as an argument of load method) are applied only once. params (当用作load方法的参数时)仅应用一次。 If you want to apply these params to each request you have to modify proxy extraParams property: 如果要将这些参数应用于每个请求,则必须修改proxy extraParams属性:

Ext.apply(store.proxy.extraParams, {
    productid: form.getForm().findField('Product_ID').getSubmitValue(),
    description: form.getForm().findField('Description').getSubmitValue()
}, {});
store.load();

Else you can use store filter method ( store.remoteFilter should be set to true): 另外,您可以使用商店过滤器方法(将store.remoteFilter设置为true):

store.filter([
    {property: "productid", value: form.getForm().findField('Product_ID').getSubmitValue()},
    {property: "description", value: form.getForm().findField('Description').getSubmitValue()
]);

But note that the filter part of request url has different form when filter approach is used. 但是请注意,使用过滤filter方法时,请求url的过滤器部分具有不同的形式。 In this case filter part looks something like ?filter=[{'property':'productid','value':2}]&limit=10... . 在这种情况下,过滤器部分看起来类似于?filter=[{'property':'productid','value':2}]&limit=10... Whereas when params approach is used url looks something like ?productid=2&limit=10... . 而使用params方法时,url看起来类似于?productid=2&limit=10... So when filter approach is used backend should parse filter property of request. 因此,当使用filter方法时,后端应解析请求的filter属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM