我想在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
的一部分,您已经嵌套在双引号中。