How to bind dynamically generated json to flexgrid?

Posted by: ajanaspa on 5 September 2021, 7:11 am EST

    • Post Options:
    • Link

    Posted 5 September 2021, 7:11 am EST - Updated 3 October 2022, 3:34 am EST

    I wanted to bind json data (which is dynamically generated) to flexgrid.

    My json looks like

    [

    {

    “Msg”:{

    “Command”:{

    “Number”:“1”,

    “device”:[

    {

    “device1”:“1”

    },

    {

    “device2”:“2”

    }

    ]

    }

    },

    “Validator”:{

    “value”:“1”,

    }

    ]

    I want a view like below.

    Is it possible using Flexgrid?

  • Posted 5 September 2021, 10:07 pm EST

    Hello,

    You can update the itemsSource of the grid anytime as per your requirements.

    flexGrid.itemsSource = <dynamic json data>;
    

    Also, the JSON you have provided is not supported in the FlexGrid, because the FlexGrid data source takes either an array, array-of-object, JSON(in array-of-object structure ), an instance of IcollectionView. If you pass a JSON to the FlexGrid you need to make sure it is in that structure only.

    I have Updated the JSON a bit to show the closest desired result. Please refer to the sample link below demonstrating the same:

    https://stackblitz.com/edit/js-we11pg?file=index.js

    Regards

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels