cant setData to TreeGrid

Hi

I have problem of setting data to a tree grid for the below code if i called

SwitchListDetailsTree.fetchData() it fetches fine .. but after doing this i cant reorder records . I think this is because of the DataSource assigned to it . thinking so i tried set data to it by calling

SwitchListDetailsTree.fetchData(null,“SwitchListDetailsTree.setData(data)”);
although the request generates and response comes it does not display the data. how can i set dynamicaly generated data in to a tree grid?

Regards
shivantha

DataSource.create({
    ID:"RailCarDetails",

 transformRequest : function (dsRequest) {
           var params =
            {
                railRoadId :document.getElementById('railRoad').value,
                switchListId : selectedSwitchId

            };
              return params;
      },

    fields: [
        {name: "categoryName", type:"text", primaryKey: true, title: "Item", length: 128},
        {name: "station", type:"text", title: "station", length: 128},
        {name: "parentID", type:"text", hidden: true, foreignKey: "supplyCategory.categoryName", rootValue:"root"},
 {name: "equipmentInitial", type:"text", title:"Equipment Initial", type:"text", length:500},
		{name: "equipmentNumber", type:"text", title:"Equipment Number", type:"text", length:500},
		{name: "carTypeCd", type:"text", title:"Car Type Code", type:"text", length:500},
		{name: "outsideLength", type:"text", title:"Outside Length", type:"text", length:500},
		{name: "outsideWidth", type:"text", title:"Outside Width", type:"text", length:500},
		{name: "outsideHeight", type:"text", title:"Outside Height", type:"text", length:500},
		{name: "tareWeight", type:"text", title:"Tare Weight", type:"text", length:500},
		{name: "weight", type:"text", title:"Weight", type:"text", length:500},
		{name: "trackSeqId", type:"text", title:"Track Sequence", type:"text", length:500},
		{name: "equipStatusCd", type:"text", title:"Equipment Status", type:"text", length:500},
		{name: "isHazmat", type:"text", title:"is Hazmat", type:"text", length:500},
		{name: "destOnline", type:"text", title:"Destination Online", type:"text", length:500},
		{name: "comments", type:"text", title:"Comments", type:"text", length:500},
		{name: "receivedDTM", type:"text", title:"Recieved Date", type:"text", length:500},

		{name: "fromToRoad", type:"text", title:"From To Road", type:"text", length:500},
		{name: "lastMoveDTM", type:"text", title:"Last Move Date", type:"text", length:500},
		{name: "equipmentMoveType", type:"text", title:"Equipment Move Type", type:"text", length:500},

		{name: "lastStorageMove", type:"text", title:"Last Storage Move", type:"text", length:500},
		{name: "lastPlacementMove", type:"text", title:"Last Placement Move", type:"text", length:500},
		{name: "lastStatusMove", type:"text", title:"Last Status Move", type:"text", length:500},

		{name: "lastStatusMoveDTM", type:"text", title:"Last Status Move Date", type:"text", length:500},
		{name: "lastPlacementStatusSame", type:"text", title:"Last Placement Satus Same", type:"text", length:500},
		{name: "badOrderReasonCd", type:"text", title:"Bad Order Reason", type:"text", length:500},
		{name: "trackLocation", type:"text", title:"Track Location", type:"text", length:500},
		{name: "blockId", type:"text", title:"Block Id", type:"text", length:500},
        {name: "isSelectedIcon", type:"boolean", defaultValue:false ,title:"Selected"},

		{name: "descIcon", type:"text", title:"Description Icon", type:"text", length:500},
		{name: "railCarIcon", type:"text", title:"Railcar Icon", type:"text", length:500},
        {name:"moveTypes",    width:300,   title:"Move Type" , type: "comboBox"},

        {name:"moveDate", title:"Move Date", type: "Date"},

        {name:"moveTime", title:"Move Time", type: "Time"},

        {name:"moveStations",title:"Stations" , type: "comboBox"},

        {name:"moveLocations",title:"Locations" , type: "comboBox"},

        {name:"patrons",title:"Patrons" , type: "comboBox"},

        {name:"barOrderCodes",title:"Bad order code", type: "comboBox"},

        {name:"Comments",title:"Move Comments", type: "text", length:500}
    ]
})


isc.TreeGrid.create({
    ID:"SwitchListDetailsTree",
    dataSource:"RailCarDetails",
    //nodeClick:"SwitchListDetailsFindForm.findItems(node.categoryName)",

    leaveScrollbarGap:false,
    animateFolders:true,
    canAcceptDroppedRecords:true,
    canReparentNodes:false,
    selectionType:"multiple",
    animateRowsMaxTime:750,
    sortFieldNum: 3,
        headerHeight: 30,
        sortDirection: "ascending",
          canReorderRecords: true,

fields: [
                    {name: "categoryName" ,width:350},
   
        {name:"descIcon", title:"Description Icon", width:80, align:"center",wrap:true,canEdit:false,
            formatCellValue : function (value, record, field, rowNum, colNum) {
                if (value !="" || value !=null ) return isc.Canvas.imgHTML("demoApp/checked.png",13,13);
                //else return isc.Canvas.imgHTML("demoApp/unchecked.png",13,13)
        }},

       {name:"railCarIcon", title:"Railcar Icon", width:80, align:"center",wrap:true,canEdit:false,
      formatCellValue : function (value, record, field, rowNum, colNum) {
         if (value !="" || value !=null ) return isc.Canvas.imgHTML("demoApp/checked.png",13,13);
        //else return isc.Canvas.imgHTML("demoApp/unchecked.png",13,13)
      }},

         {name:"trackSeqId",wrap:true,width:32},

       	 {name:"equipmentInitial", title:"Railcar Initail", canEdit:false},

       	 {name:"equipmentNumber", title:"Railcar Number", showHover:true,canEdit:false},

         {name:"destOnline", title:"Detsination", showHover:true,canEdit:false,width:190},

         {name:"equipmentMoveType", title:"Equipment Move Type", showHover:true,canEdit:false}
    ]
  //  folderDrop: function (dragRecords, dropFolder) {
       // var record = SwitchListDetailsItemList.getSelectedRecord();
     //   var newCategory = dropFolder.categoryName;
     //   record.category = newCategory;
        //supplyItem.updateData(record);
   // }
});

Hi
A straight dataSource fetch operation will return data as an array of objects by default.
Before assigning this data to a TreeYou will need to create a Tree object from this flat list - see the Tree class documentation for how to do this.
Once you have your Tree, you should be able to call ‘setData()’ to apply it to the TreeGrid instance.

duplicate record sets in tree grid

thanks for replying ..

there are 3 issues

I did it but it displays duplicate record sets. Im using smartclient 5.7
this is the way i did it.. see the below code

I did a straight dataSource fetch operation and it fills the data to the tree grid fine. but it doesn’t allow me to reorder rows using drag and drop. any idea of what seems to be the problem?

and although the floderDrop function works it doesn’t return the correct row index of the drop record . is there any other way to get the index of the row?

Regards
Shivantha

      loadResult :function(data1){


SwitchListDetailsTree.setData(isc.Tree.create({
modelType: "parent",
rootValue: "root",
nameProperty: "name",
idField: "categoryName",
parentIdField: "parentID",
data:data1}));


           SwitchListDetailsTree.data.openAll();
           },

isc.Button.create({
	    	title:"View",
	    	margin:20,
	    	autoDraw:false,
	   	width:200,
	    	ID:"SwitchListChooserView",
        click:"          detailTabs.selectTab(1); SwitchListDetailsTree.fetchData(null,\"this.loadResult(data)\");",
                    height:100
            })

Hi Shivantha,

  1. Without seeing a running example, or at least your TreeGrid definition, and the raw data returned from the DataSource fetch by the server, it’s not clear why you’d be getting duplicate records.
    Any chance you coiuld put together a standalone example that demonstrates the problem which we could run on our end and take a look? You could either post raw code here, or zip up the test file(s) and mail it to support@isomorphic.com

  2. Do you have canReorderRecords set to true on the TreeGrid definition? Once again, a running example would be the best way for us to debug this for you.

  3. Not sure what you’re asking here
    Pointers to the selected node(s) that are being dragged into a new location are available as the first parameter of folderDrop (nodes).
    The target folder into which the nodes are being dropped is available as the second parameter
    The third parameter is the index within that target folder where the nodes were dropped

Isomorphic Software