Dojo dgrid:当我单击过滤器按钮时,从具有不同字段的商店中过滤数据

Dojo dgrid: Filter data from store with diffrent fields when I click on filter button

我正在使用 'dgrid/Grid' 和 dstore/RequestMemory 来创建网格和存储数据。现在我想根据字段中的值过滤数据(参见 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);

        });