Dojo dgrid:当我单击Filter按钮时,使用不同的字段从存储中过滤数据

Dojo dgrid:当我单击Filter按钮时,使用不同的字段从存储中过滤数据,dojo,store,dgrid,dstore,Dojo,Store,Dgrid,Dstore,我正在使用“dgrid/Grid”和dstore/RequestMemory来创建网格和存储数据。现在我想根据字段SEE img中的值筛选数据。我不确定在使用简单Dgrid和dstore时如何过滤数据 var structure = [{ label : "Value Date", field : "valueDate" }, { id: "currencyCol", label :

我正在使用“dgrid/Grid”和dstore/RequestMemory来创建网格和存储数据。现在我想根据字段SEE img中的值筛选数据。我不确定在使用简单Dgrid和dstore时如何过滤数据

 var structure = [{
            label : "Value Date",
            field : "valueDate"
        }, {
            id: "currencyCol",
            label : "Currency",
            field : "currency"
        }, {
            label : "Nostro",
            field : "nostroAgent"
        }];

        var store= new RequestMemory({
            target: 'getReportData',
            idProperty: "cashflowId",
            headers: structure
        });
        // Create an instance of OnDemandGrid referencing the store
        var grid = new(declare([Grid, Pagination, Selection]))({
            collection: store,
            columns: structure,
            loadingMessage: 'Loading data...',
            noDataMessage: 'No results found.',
            minRowsPerPage: 50,
        }, 'grid');
        grid.startup(); 

      on(document.getElementById("filter"), "click", function(event) {
            event.preventDefault();
            grid.set('collection', store.filter({                   
                **currencyCol: "AED"**
                      .
                      .
                      .
            }));

如果我使用不同的存储或网格,我们将非常感谢您的帮助或建议。

我得到了问题的解决方案。在“筛选”按钮上,单击“我已写入所有筛选逻辑”,最终存储将设置为dgrid:

        on(document.getElementById("filter"), "click", function(event) {

            var store= new RequestMemory({
                target: 'getReportData',
                idProperty: "cashflowId",
                headers: structure
            });

            var from=dijit.byId('from').value;
            var to=dijit.byId('to').value;
            var curr=dijit.byId('currency').value;
            var nos=dijit.byId('nostro').value;
            var authStatus=dijit.byId('authStatus').value;
            var filterStore;
            var finalStore=store;
            var filter= new store.Filter();
            var dateToFindFrom;
            var dateToFindTo;

            if (from != "" && from !== null) {

                var yyyy = from.getFullYear().toString();
                var mm = ((from.getMonth()) + 1).toString(); // getMonth() is zero-based
                var dd  = from.getDate().toString();

                if(mm <= 9){
                    mm= "0" + mm;
                }
                if(dd <= 9){
                    dd= "0" + dd;
                }

                dateToFindFrom =yyyy + mm + dd;

                filterStore= filter.gte('valueDate', dateToFindFrom);
                finalStore=finalStore.filter(filterStore);

            }
            if (to != "" && to !== null) {
                var yyyy = to.getFullYear().toString();
                var mm = ((to.getMonth()) + 1).toString(); // getMonth() is zero-based
                var dd  = to.getDate().toString();

                if(mm <= 9){
                    mm= "0" + mm;
                }
                if(dd <= 9){
                    dd= "0" + dd;
                }


                dateToFindTo =yyyy + mm + dd;

                filterStore= filter.lte('valueDate', dateToFindTo); //.lte('valueDate', dateToFindTo);
                finalStore=finalStore.filter(filterStore);
            }

            if(curr != "" && curr !== null) {
                filterStore= filter.eq('currency', curr);
                finalStore=finalStore.filter(filterStore);
            }
            if(nos != "" && nos !== null) {
                filterStore= filter.eq('nostroAgent',nos);
                finalStore=finalStore.filter(filterStore);
            }

            if(authStatus != "" && authStatus !== null) {
                    if (authStatus=='ALL') {
                        var both= [true, false];
                        filterStore= filter.in('approved', both);
                        finalStore=finalStore.filter(filterStore);
                    } else if (authStatus=='Authorised Only') {
                        filterStore= filter.eq('approved', true);
                        finalStore=finalStore.filter(filterStore);
                    } else if (authStatus=='Unauthorised Only') {
                        filterStore= filter.eq('approved', false);
                        finalStore=finalStore.filter(filterStore);
                    };
            };
            grid.set('collection', finalStore);

        });

看起来你已经有了这个想法的开始,只需要把多个过滤器放在一起。如果你还没有看到dstore's,他们可能会有所帮助。