Author Topic: Filter range options (V 5.3.0)  (Read 4185 times)

sbilleau

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Filter range options (V 5.3.0)
« on: September 24, 2018, 07:20:25 pm »
Hi all,

I've a problem with the options of my range filter.

Here the code :

Code: [Select]
filter: { type: "select",
                crules: [{
                    condition: "range"
                }] ,
                valueIndx: "value",
            labelIndx: "text",
                options: [
                    { "value": "pending", "text": "Pending" },
                    { "value": "validated", "text": "Validated" },                   
                    { "value": "unvalidated", "text": "Unvalidated" }
                ],
                listeners: ['change']
            }

The result in attachments.


Thanks

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Filter range options (V 5.3.0)
« Reply #1 on: September 24, 2018, 11:58:56 pm »
Yes, valueIndx, labelIndx no longer working in new filter design >= 5.2, documentation needs to be updated for this.

Please change your filter definition to this:

Code: [Select]
   filter: {
                crules: [{
                    condition: "range"
                }] ,
                options: [
                    { "pending": "Pending" },
                    { "validated": "Validated" },                   
                    { "unvalidated": "Unvalidated" }
                ]
            }

sbilleau

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Filter range options (V 5.3.0)
« Reply #2 on: September 25, 2018, 12:31:36 pm »
Thanks for the reply.

I've already tried several methods, including this one.
Here is the result.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Filter range options (V 5.3.0)
« Reply #3 on: September 25, 2018, 04:46:51 pm »
Works fine in the examples.

Could you please share a jsfiddle so that I can check it for you.

sbilleau

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Filter range options (V 5.3.0)
« Reply #4 on: October 30, 2018, 06:57:04 pm »
Sorry for this loooooong wait: /
I can't do a JSFiddle, too expensive in time.
Here is the complete statement from my column:

Code: [Select]
{
            dataIndx: 'action_plan_check_status', title: $.i18n.t("nucleys_elabel:general.nucleys_table_action_plan_check_status"), minWidth: '5%', maxWidth: '100%',
            filter: {
                crules: [{
                    condition: "range"
                }],
                options: [
                    { "value": "pending", "text": $.i18n.t("nucleys_elabel:general.action_plan_check_status_pending") },
                    { "value": "validated", "text": $.i18n.t("nucleys_elabel:general.action_plan_check_status_validated") },
                    { "value": "unvalidated", "text": $.i18n.t("nucleys_elabel:general.action_plan_check_status_unvalidated") }
                ]
            },
            render: function( ui ){
                return {
                    text: ui.rowData.action_plan_check_status ? $.i18n.t("nucleys_elabel:general.action_plan_check_status_"+ui.rowData.action_plan_check_status) : '',
                };
            },
            exportRender: function( ui ){
                return {
                    text: ui.rowData.action_plan_check_status ? $.i18n.t("nucleys_elabel:general.action_plan_check_status_"+ui.rowData.action_plan_check_status) : '',
                };
            },
            editor: {
            type: 'select',
            valueIndx: "value",
            labelIndx: "text",
            options: [
                    { "value": "pending", "text": $.i18n.t("nucleys_elabel:general.action_plan_check_status_pending") },
                    { "value": "validated", "text": $.i18n.t("nucleys_elabel:general.action_plan_check_status_validated") },
                    { "value": "unvalidated", "text": $.i18n.t("nucleys_elabel:general.action_plan_check_status_unvalidated") }
                ]
        }
        }

sbilleau

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Filter range options (V 5.3.0)
« Reply #5 on: October 30, 2018, 07:49:50 pm »
I feel that it takes the base value and not the value after the render.
My need is to be able to keep the base value (to be able to make the modifications), but to filter on the values after render.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Filter range options (V 5.3.0)
« Reply #6 on: October 30, 2018, 10:09:46 pm »
column.render can also be used in range filter dropdown.

Example: country flags are shown in both column cells and range filter dropdown ( ShipCountry column ) in this demo:

https://paramquery.com/pro/demos/filter_custom

Code: [Select]
selectGridObj: function(ui){
     ui.obj.colModel[0].renderLabel = ui.column.render;
}
« Last Edit: October 30, 2018, 10:12:06 pm by paramquery »

sbilleau

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Filter range options (V 5.3.0)
« Reply #7 on: October 31, 2018, 06:43:07 pm »
Thanks.
It works fine !

Now, is there a way to display, in the filter input, the rendering rather than the "true" value?


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Filter range options (V 5.3.0)
« Reply #8 on: October 31, 2018, 11:33:29 pm »
Checkboxes are used for true/false values.

as in paid column in https://paramquery.com/pro/demos/filter_header_local

sbilleau

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Filter range options (V 5.3.0)
« Reply #9 on: November 02, 2018, 01:25:21 pm »
To be more specific, my question is:
How, in the filter field, display the render rather than the value.
In my example, for a 'range' filter I get the render at the moment of selection, except that in the filter field, it is not the render that is displayed, but the value. (For example: 'validated' instead of 'Validé')

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Filter range options (V 5.3.0)
« Reply #10 on: November 05, 2018, 02:52:31 pm »
rendered values are not ( and can't be ) displayed in the range filtered field.

Please use column.format callback for that purpose as shown in this example:

https://paramquery.com/pro/demos/filter_date

API: https://paramquery.com/pro/api#option-column-format
« Last Edit: November 05, 2018, 02:55:18 pm by paramquery »