Search code examples
javascriptdojodojox.griddojo.gridx

How to add filter in EnhancedGrid


I want to add filter in dojox.grid.EnhancedGrid and my grid is created declaratively. I added filter in data-dojo-props attribute.

My code :

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

When I try to run this code am facing this error,

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

how to add filter correctly? can any help me


Solution

  • You need to wrap songs in single quotes, not double quotes. You are already nested within double quotes as part of data-dojo-props.