I am trying to setup my own treeGrid and reuse a XML DS on my site.
I have seen the examples on the site (http://www.smartclient.com/index.jsp#treeLoadXML). I have tried to combine multiple fragments from them to create something that uses a slightly different DS.
The page loads, the XML is fetched but the treeGrid does not display anything - it just says ‘Loading data…’
What do I need to change to make it work with my XML DS?
All items in the treeGrid have silver triangle indicating they can be expanded. This is the case for some and when they’re expanded the data is requested from the server and displayed correctly but is there anyway in the XML to indicate that the element won’t expand further.
Bhushan has a triangle indicating it can be expanded, a request is made to the server which returns with to expanded details. It would save the user a click if when Bhushan loaded it indicated it can’t be expanded.
No details are given about what position wxy4 should have in wxy. I move it from the 4th slot to the 2nd slot, but you can not tell this information from the server.
About the property to use for reordering nodes - check the docs.
Are you trying to establish a permanent stored order for these nodes? As in, there will be a DataSource field specifying the order, which you will be updating when the user drags?
TreeGrid extends ListGrid, and canReorderFields is an inherited method - it’s used as it is in ListGrid, to allow the user to drag columns around with the header button. This may not have occurred to you, as many applications of TreeGrid only require one column (that containing the tree itself).
If your DS will contain an additional field to stipulate child order, then unless I’m missing something it seems fairly obvious that’s how you communicate it to the server. Client-side, child sequence within a node will be determined by the child’s position within treeGrid.data.getChildren(node) - use that info to update your DS field.
That example for folderDrop() shows how it can be used to recategorize records shown in a related list. That particular example is not trying to show how to reorder tree nodes, and it’s true there’s a crash if you try to reorder tree nodes, but that’s a flaw in the example (which we’ll correct) not the folderDrop API.
Unlike that example, you want to save the “index” parameter to the DataSource representing the tree.
The treeGrid is able to submit the following to the server, however the get parameter name is useless _parent_isc_ResultTree_54 for being able to update the database with the change.
$42c isc_ResultTree_54
_parent_isc_ResultTree_54 {sectionName:"Section: 9",sectionId:"id9",parentId:"root",isFolder:true,isOpen:true,orderby:"",children:[{sectionName:"Sub: 0 of Section: 9",sectionId:"sub0id9",parentId:"id9",isFolder:false,isOpen:false,orderby:""},{sectionName:"Sub: 1 of Section: 9",sectionId:"sub1id9",parentId:"id9",isFolder:false,isOpen:false,orderby:""},{sectionName:"Sub: 2 of Section: 9",sectionId:"sub2id9",parentId:"id9",isFolder:false,isOpen:false,orderby:""},{sectionName:"Sub: 3 of Section: 9",sectionId:"sub3id9",parentId:"id9",isFolder:false,isOpen:false,orderby:1},{sectionName:"Sub: 4 of Section: 9",sectionId:"sub4id9",parentId:"id9",isFolder:false,isOpen:false,orderby:""}]}
_selection_6 true
do fetch
isFolder false
isOpen false
orderby 1
page adminmenu
parentId id9
sectionId sub3id9
sectionName Sub: 3 of Section: 9
Just a sanity check - did you know the SmartClient Reference is searchable? Because you’re passing parameters to methods that don’t match the documented method signature…
You need to add the index to each dragRecord and save them to the server via an updateData() call for each dragRecord.