jQuery UI Widgets › Forums › Grid › How to map a mixed JSON with arrays.
This topic contains 6 replies, has 3 voices, and was last updated by Peter Stoev 11 years, 3 months ago.
-
Author
-
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
My JSON File: http://pastebin.com/xvJzEt8G
My Code: http://pastebin.com/n9xsBi8A
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 StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter Thanks for prompt reply, I did that too, but it said to me Json Parse Error, But My JSON is pretty valid.
Thank you for your help Peter, got the problem solved by removing ” [ ] ” from the start of the JSON.
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’?
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 StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.