SearchPanes custom ordering in one pane

SearchPanes custom ordering in one pane

BPATBPAT Posts: 28Questions: 13Answers: 1

Currently in a table I have data in one column that supplies a search pane thusly:
1-1
100-249
1k+
2-50
250-299
300-999
51-99

What I want is for that search pane to look like:
1-1
2-50
51-99
100-249
250-299
300-999
1k+

Is this possible?

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @BPAT ,

    The panes are DataTables themselves. You can set their config using the searchPanes.dtOpts config option, and set the config for a specific pane using columns.searchPanes.dtOpts. You should be able to add an ordering plug-in that way.

    Thanks,
    Sandy

  • BPATBPAT Posts: 28Questions: 13Answers: 1

    So I did this and it puts stuff in the search pane, but search pane still orders it and I don't know enough about what I'm doing to get the search pane to impact the table filtering. Thanks for your help Sandy. I will look at what you pointed me to. I guess I have to get smarter.

    searchPanes: {
    options:[
    {
    label: '1-1',
    value: function(rowData, rowIdx){
    return rowData[8] = '1-1';
    }
    },
    {
    label: '2-50',
    value: function(rowData, rowIdx){
    return rowData[8] = '2-50';
    }
    },
    {
    label: '100-249',
    value: function(rowData, rowIdx){
    return rowData[8] = "100-249";
    }
    },

                    ]
                },
                targets:[8],
            },
    
  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @BPAT ,

    I don't think you want to do what you have above.

    Take a look at this page. You will want to create a function as is documented there. Then check the type and if it is sort then return whatever value you want to sort on. If you are defining custom options you may be able to just hard code it there?

    Thanks,
    Sandy

This discussion has been closed.