jQuery UI Widgets › Forums › Navigation › Tree › Refresh whole tree after drag and drop
Tagged: dataadapter, dragdrop, refresh, Tree
This topic contains 4 replies, has 2 voices, and was last updated by Martin 6 years, 1 month ago.
-
Author
-
Hello I have a tree populated using dataAdapter with json data. After drag and drop I need to do a refresh for the whole tree. I have tried different things and none of them have worked. Please could you help me to refresh after drag and drop? On success: function (data) {…}. I have followed https://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtree/index.htm#demos/jqxtree/dragdrop.htm and https://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtree/index.htm#demos/jqxtree/treebindingtojson.htm. Thanks in advance.
I am refreshing like this on success:
tree.jqxTree(‘clear’);
source = {datatype: “json”,datafields: [{ name: ‘id’ },{ name: ‘parentid’ },{ name: ‘text’ },{ name: ‘value’ },{ name: ‘icon’ }],id: ‘id’,localdata: data.d};
dataAdapter1 = new $.jqx.dataAdapter(source);
dataAdapter1.dataBind();
records1 = dataAdapter1.getRecordsHierarchy(‘id’, ‘parentid’, ‘items’, [{ name: ‘text’, map: ‘label’ }]);
tree.jqxTree({source: records1, width: ‘300px’, allowDrag: true, allowDrop: true});I wonder if there is any shorter way.
Thanks in advanced.Hello net.nimbus,
Why are you creating a new source and dataAdapter every time you drag and drop an item? It is unnecessary.
So you want to refresh the tree to show the original data order that was before the dragging, is that right?
Here is an Example that do this.Best Regards,
MartinjQWidgets Team
http://www.jqwidgets.com/Hello, thanks for your prompt response. There is an image that comes from database and needs to be refreshed in the tree. Here is my last version on success of dragEnd:
tree.jqxTree(‘clear’);
source.localdata =data.d;
dataAdapter.dataBind();
records = dataAdapter.getRecordsHierarchy(‘id’, ‘parentid’, ‘items’, [{ name: ‘text’, map: ‘label’ }]);
tree.jqxTree({source: records});
tree.jqxTree(‘expandAll’);
Just tree.jqxTree({source: records}); doesnt work for me.
I appreciate your help. Is there is any shorter way to do this?
Thanks in advancedHello net.nimbus,
In this case, this is the correct way for updating the tree.
Best Regards,
MartinjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.