jQuery UI Widgets Forums Grid How to map a mixed JSON with arrays.

Tagged: , , ,

This topic contains 6 replies, has 3 voices, and was last updated by  Peter Stoev 11 years, 3 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • How to map a mixed JSON with arrays. #47203

    suleman1
    Participant

    Hi, I really appreciate the work you guys have put through and the widgets you created are really awesome. I was working on JqxGrid from some time, but I am unable to map the JSON I have, My Json contains nested objects and arrays in it. I have been able to display single items by using map: 'Rotation>Shifts>0>BeginOffset but its impractical as I have lots of records. In the grid I want to display all the records but if I just get a kickstart I will do the rest by myself. You can find my JSON here , and My code can be found here.

    .

    Thanks your help will be really appreciated.

    Thanks

    How to map a mixed JSON with arrays. #47204

    suleman1
    Participant
    How to map a mixed JSON with arrays. #47216

    Peter Stoev
    Keymaster

    Hi suleman1,

    You can try the following:

    1. Set the source object’s “root” member to “Rotation>Shifts”.
    2. Remove the “map” member in the datafields initialization.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    How to map a mixed JSON with arrays. #47223

    suleman1
    Participant

    Hi Peter Thanks for prompt reply, I did that too, but it said to me Json Parse Error, But My JSON is pretty valid.

    How to map a mixed JSON with arrays. #47228

    suleman1
    Participant

    Thank you for your help Peter, got the problem solved by removing ” [ ] ” from the start of the JSON.

    How to map a mixed JSON with arrays. #47730

    JRoseman
    Participant

    Hi Peter –

    I’m running into the same situation except I’ve got nested arrays within nested arrays within nested arrays, so while setting the root alleviates the problem at the first nested level I’m still facing problems at the next (2) deeper levels.

    Similar to the above example of ‘map: ‘Rotation>Shifts>0>BeginOffset’ I actually have an array of weeks under an array of projects under an array of studios for an employee:

    map: ‘Employee>Studio>0>Projects>0>Weeks’ or
    map: ‘Employee>Studio>0>Projects>0>Weeks>0’ (because Weeks is an array as well)

    Mapping root to ‘Employee>Studio’ is great for iterating over the Studios but I’d still need a way around using >0, >1, >2, etc for ‘Projects’ and ‘Weeks’. Not knowing how many Projects there might be per Studio, or Weeks per Project am I going to have to write a loop to iterate over the length of each array and dynamically build the ‘datafields’?

    How to map a mixed JSON with arrays. #47734

    Peter Stoev
    Keymaster

    Hi JRoseman,

    I think that you will need to write some custom code which loads your data in Array. jqxDataAdapter will not load your json nested data arrays like that.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.