Search code examples
javascriptdevextreme

DevExtreme set default sort values


Is possible set default sorting values in DevExtreme grid over one specific column?

In this Example i have two columns. One Column has disable filtering. For example at second column, which i want to filtering i have values 1,2,3. On load document i need show to user only values 1,2 and user can set value 3 if he want.

This is my code:

   this.grid = {
                        dataSource: this.dataSource,
                        columns: [                        
                            {
                           dataField: "OneColumn",
                           allowFiltering: false
                        }, 
"SecondColumn"],
                        sorting: {
                            mode: "multiple"
                        },
                        headerFilter: {
                            visible: true
                        },
                        hoverStateEnabled: true,
                        searchPanel: {
                            visible: true
                        }, selection: {
                            mode: "single"
                        }
                    }

Solution

  • You can use the column.filterValues option to predefine the header filter value. Here the jsFiddle that demonstrates it in action