如何在 EnhancedGrid 中添加过滤器

How to add filter in EnhancedGrid

我想在 dojox.grid.EnhancedGrid 中添加过滤器,并且我的网格是以声明方式创建的。我在 data-dojo-props 属性中添加了过滤器。

我的代码:

<div id="myGrid" 
    data-dojo-type="dojox.grid.EnhancedGrid" 
    data-dojo-props="plugins:{indirectSelection: true,nestedSorting: true,
                     filter: {
                         closeFilterbarButton: true,
                        ruleCount: 5,
                        itemsName: "songs"
                      } },
            store: mystore,
            structure: [{
                    defaultCell: { width: 8, editable: false, type: dojox.grid.cells._Widget, styles: 'text-align: left;'  },
                    rows: [
                        { field: 'RN', name: '${RN}', width: '32%',formatter : function(val, rowIdx, cell){
                              cell.customClasses.push('anchorLookAlike');
                              return val;
                            } 
                        },
                        { field: 'DC', name: '${DC}', width: '10%' },
                        { field: 'PN', name: '${PN}', width: '10%' },
                        { field: 'MD', name: '${MD}', width: '10%' },
                        { field: 'RD', name: '${RD}', width: '10%' },
                        { field: 'UR', name: '${UR}', width: '10%' },
                        { field: 'DL', name: '${DL}', width: '10%',formatter: function(datum){
                                if(datum){
                                    return dojo.date.locale.format(new Date(datum), {selector: 'date', formatLength: 'long'});
                                }
                                return '...';
                            } 
                        },
                        {field: 'RP', name: '', hidden: true}
                    ]
                }]"></div>

当我尝试运行此代码时遇到此错误,

dojo/parser::parse() error
Error: SyntaxError: syntax error in data-dojo-props='plugins:{indirectSelection: true,nestedSorting: true, filter: { closeFilterbarButton: true, ruleCount: 5, itemsName:

如何正确添加过滤器?能帮我吗

您需要将 songs 括在单引号中,而不是双引号中。作为 data-dojo-props.

的一部分,您已经嵌套在双引号中