jQuery UI Widgets Forums Grid grid datasource objects with absent attributes

This topic contains 3 replies, has 2 voices, and was last updated by  Hristo 7 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • JellyRaptor
    Participant

    On jqwidgets 4.2.1, I am noticing some odd behavior when I bind data to my grid.

    I have an array of data that comes from the server like this:
    [
    { firstName: “John”, lastName: “Doe”, age: 30 },
    { firstName: “Jack”, lastName: “Johnson” }
    ]

    This data displays fine in my grid. When I have the exact same data come back from the server in the opposite order, however, the grid does not show ANY values in the age column. I’m guessing the grid looks to see what attributes are on the first record and ignores attributes that are not on it for the remaining rows.

    //No age is shown in the grid for either record
    [
    { firstName: “Jack”, lastName: “Johnson” },
    { firstName: “John”, lastName: “Doe”, age: 30 }
    ]

    Do I have to change my server code to serialize null object attributes to support this odd behavior of jqxgrid, or is there some better way to handle absent properties on the client side with jqxgrid?

    I am currently getting around this issue with:

    [
    { firstName: “Jack”, lastName: “Johnson”, age: null },
    { firstName: “John”, lastName: “Doe”, age: 30 }
    ]

    Thanks


    Hristo
    Participant

    Hello JellyRaptor,

    I try the mentioned scenario but the Grid looks ok – shows ages when has such value (in both “data”).
    Could you try to update to the latest version?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com


    JellyRaptor
    Participant

    Right, the issue is that jqxgrid requires the age attribute to be present on the first record in the source array, which isn’t the case in my scenario.

    Here is a fiddle demonstrating the issue in the latest jqwidgets.
    http://jsfiddle.net/1ah9ph8g/14/

    If you replace the current source with the commented out one (simply a reversal of the records), the age displays properly.


    Hristo
    Participant

    Hello JellyRaptor,

    I would like to suggest you use jqxDataAdapter.
    Please, take a look at this example.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.