jQuery UI Widgets › Forums › Navigation › NavigationBar, ToolBar, NavBar › Tree JSON Call set checkbox of item
Tagged: Tree checkboxes Json restful
This topic contains 2 replies, has 2 voices, and was last updated by codinggal 5 years, 5 months ago.
-
Author
-
Hi all,
i have researched this and can not find a solutions
my Scenario is the following
1) Restful web service call using the dataadapter
2) my json is named the same as indicated in this page JqWidgets tree documentation
3) I want to dynamically set whether the checkbox is set for each node based on what is returned from the json property “checked”I know the mapping is working as a assigned selected to the value of checked and the first node showed as if it was selected.
So it seems that the “checked” is not working in the tree when mapping. not sure why. Seems like a no brainer.
Help would be greatly appreciated.
here is my code
//define permission data source var permissionListSource = { datatype: "json", url: "/roles/permissions", data: { roleId: 1 }, datafields: [ { name: 'id'}, { name: 'parentid' }, { name: 'label' }, { name: 'value' }, { name: 'checked', type: 'bool'} ], id: 'id', async: false }; var permissionListData = new $.jqx.dataAdapter(permissionListSource); permissionListData.dataBind(); // get the tree items. The first parameter is the item's id. The second parameter is the parent item's id. The 'items' parameter represents // the sub items collection name. Each jqxTree item has a 'label' property, but in the JSON data, we have a 'text' field. The last parameter // specifies the mapping between the 'text' and 'label' fields. var permissionRecords = permissionListData.getRecordsHierarchy( 'id', 'parentid', 'items', [ { name: 'label', map: 'label' }, { name: 'checked', map: 'checked' }, { name: 'checked', map: 'selected' }, ] ); $('#treeview').jqxTree({ source: permissionRecords, width: '92%', hasThreeStates: true, checkboxes: true });
here is my json being returned from my webservice
[ { "id":1, "value":1, "parentid":0, "label":"Admin", "checked":true }, { "id":2, "value":2, "parentid":1, "label":"Manage Users", "checked":false }, { "id":3, "value":3, "parentid":1, "label":"Manage Roles", "checked":false }, { "id":4, "value":4, "parentid":1, "label":"Manage Company Profile", "checked":false }, { "id":5, "value":5, "parentid":2, "label":"Send User Invitation", "checked":false } ]
Hello codinggal,
At the moment of creating the source the all items except first are not checked.
Immediately after the initialization is expecting all to be selected (because ofhasThreeStates
property).
Please, take a look at this example.Best Regards,
Hristo HristovjQWidgets team
https://www.jqwidgets.comThanks Hristo, you are right… It did not propagate down. I corrected it on the server side to force it. Sorry I posted in the wrong forum… Don’t know how that happened.
and thanks for showing me client side checking because I am going to need that with something I am going to do…
Look forward to working with jqwidgets controls in my project.
Have a wonderful day,
Angela
-
AuthorPosts
You must be logged in to reply to this topic.