ParamQuery grid support forum

General Category => Help for ParamQuery Grid (free version) => Topic started by: joelclark on August 21, 2020, 01:25:01 am

Title: How to Filter on Nested Json
Post by: joelclark on August 21, 2020, 01:25:01 am
Hi There,

So I have a few columns that are nested Json. For example the below column. I want to filter on "['FxCalcConfigType']['Value']" but can't get the filter to point to that value. Is this even possibly? I have been looking and have found nothing. Tried the value functionality in the filter and it did not help :(

{
                title: FI.res.fXRates.CalcConfigTypeLabel, dataType: "integer", editable: false, align: "left", minWidth: 150,
                render: function (ui) {
                    //Below line returns the value of the type value so that I don't have to do anything to the entity
                    return ui.rowData['FxCalcConfigType']['Value'];
                },
                filter: { crules: [{ condition: 'contain' }], listeners: ['keyup'] }
            },
Title: Re: How to Filter on Nested Json
Post by: paramvir on August 21, 2020, 10:10:27 am
1. you need to define dataIndx: 'FxCalcConfigType' for your column.

2. write a custom compare function for the column.filter

Code: [Select]
conditions: {
    contain: {
        compare: function (cellData, val) {           
            //write the custom logic here.
        }
    }
}

Here is an example for writing custom filter compare function: https://paramquery.com/pro/demos/filter_custom

Please let me know if you need further assistance on this.
Title: Re: How to Filter on Nested Json
Post by: joelclark on August 21, 2020, 10:40:52 pm
Still doesn't seem to be working unless i am missing something? I can't event get into the compare function to debug it. My code is below and as you can see in the attached screenshot it still is showing the data as [Object] [object]

{
                title: FI.res.fXRates.CalcConfigTypeLabel, dataType: "string", dataIndx: "FxCalcConfigType", editable: false, align: "left", minWidth: 150,
                render: function (ui) {
                    //Below line returns the value of the type value so that I don't have to do anything to the entity
                    return ui.rowData['FxCalcConfigType']['Value'];
                },
                filter: { crules: [{ condition: 'contain' }], listeners: ['keyup'] },
                conditions: {
                    contain: {
                        compare: function (cellData, val) {
                            if ((cellData.Value + "").indexOf(val) != -1) {
                                return true;
                            }
                            else {
                                return false;
                            }
                        }
                    }
                }
            },


Title: Re: How to Filter on Nested Json
Post by: tarunsharma on May 17, 2022, 01:31:40 am
Hi, have you able to fix this issue? I am also getting the same issue, cellData return "[Object Object]" and I am not able to read that.
Title: Re: How to Filter on Nested Json
Post by: paramvir on May 20, 2022, 01:58:33 pm
Recent version of pqgrid makes it very easy to work with nested json data.

Please check this example: https://paramquery.com/pro/demos/json_nested