Author Topic: SORT / Filter Select Options  (Read 1939 times)

cijojohn

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 73
    • View Profile
SORT / Filter Select Options
« on: April 15, 2017, 08:52:21 am »
Hi Team,

We are facing issue with Select box sorting and filter.
The way we are populating our drop down options is in the form... array of associative value label pairs e.g., [ { 'CB01': 'Mark' }, { 'CB02': 'Robert' }, ... ].

So when i sort with text box as a filter type the column is getting sort on base of value. i.e CB01 & CB02. But we want to sort our column data on basis of label. i.e Mark And Robert.

Could you please share a jsFiddle for the same.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: SORT / Filter Select Options
« Reply #1 on: April 17, 2017, 01:27:50 pm »
That's a good question.

You need to store labels ('Mark', 'Robert') in that column while values ('CB01', 'CB02') in a hidden column with help of editor.mapIndices option. and change the options from associative value label pairs to {key1: label, key2: value} format.

There is already a good example here, check the ShipVia column: https://paramquery.com/pro/demos/editing_custom

Code: [Select]
                    { dataIndx: 'ShipViaId', hidden: true }, //hidden column to store ShipVia Id.
    { title: "Shipping Via", dataIndx: "ShipVia", width: 110,
        editor: {
            type: 'select',
            init: function (ui) {
                ui.$cell.find("select").pqSelect();
            },
            valueIndx: "value",
            labelIndx: "text",                        
                            mapIndices: {"text": "ShipVia", "value": "ShipViaId"},
            options: [
                            { "value": "", "text": "" },
                            { "value": "SE", "text": "Speedy Express" },
                            { "value": "UP", "text": "United Package" },
                            { "value": "FS", "text": "Federal Shipping" }
                            ]
        }        
    },
« Last Edit: April 17, 2017, 01:32:50 pm by paramquery »