代码之家  ›  专栏  ›  技术社区  ›  KSK

如何在EnhancedGrid中添加筛选器

  •  1
  • KSK  · 技术社区  · 9 年前

    我想在dojox.grid中添加过滤器。EnhancedGrid和我的网格是以声明方式创建的。我在数据dojoprops属性中添加了过滤器。

    我的代码:

    <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:
    

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

    1 回复  |  直到 9 年前
        1
  •  1
  •   Jeff French    9 年前

    你需要包装 songs 用单引号,而不是双引号。您已经嵌套在双引号中,作为 data-dojo-props .