Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    fetchData ListGrid basement on TreeList node value

    Hello,
    I am making a UI with a TreeList, where the user selects a node. This does filtering a ListGrid.

    The following happens, if ListGrid.autoFetchData: false, fetchData in TreeList.nodeClick does not work. Always loads complete records of the ListGrid data source.

    Instead, if ListGrid.autoFetchData: true, it shows all records at first, then when selecting any node apply ListGrid.fetchData ({myField: myNewValue}). This filter is setted in TreeGrid.nodeClick,

    It is possible, I think so, at the beginning the ListGrid does not show records and then load the records according to a filter (I am using the fetchData function. See above) setted in the TreeList nodeClick event.

    Any suggestion?

    brgds

    #2
    To show related nodes in the ListGrid, just call listGrid.fetchData() passing criteria based on the node that was clicked. The autoFetchData setting does not make a difference.

    If this doesn't seem to be happening, then there's likely a problem in your code, for example, the criteria you are passing may be wrong in some way, such as spelling the fieldName incorrectly. We would need to see the actual code to comment further.

    Comment


      #3
      Hello,
      The problem is that not apply fetchData() if not set autoFetchData:true to the ListGrids.

      This, at least, is happening.

      The dataSource files are XML format.

      Tags Controls code:

      Code:
      // TreeGrid dataSource
      // Groups
      isc.DataSource.create({
      ID:"groupsDS",
      dataURL:"[ISOMORPHIC]/ds/groups.xml",
      recordXPath:"/List/Object",
      fields:[
      {name:"Code"},
      {name:"Description"},
      {name:"Order", primaryKey:true, type:"integer"},
      {name:"ReportsTo", foreignKey:"groupsDS.Order", type:"integer", title:"Report To"}
      ]
      });
      
      // ListGrid datasource
      // Templates
      isc.DataSource.create({
      ID:"templatesDS",
      dataURL:"[ISOMORPHIC]/ds/templates.xml",
      recordXPath:"/List/Object",
      fields:[
      {name:"Key"},
      {name:"Adjective"},
      {name:"Order", primaryKey:true, type:"integer"},
      {name:"OrderGroups"} // related to groupsDS.Order
      ]
      });
      
      // ListGrid datasource
      // Items - associated to templates
      isc.DataSource.create({
      ID:"itemsDS",
      dataURL:"[ISOMORPHIC]/ds/items.xml",
      recordXPath:"/List/Object",
      fields:[
      {name:"UserCode", title:"User Code"},
      {name:"LDescription", title:"Description"},
      {name:"Order", primaryKey:true, type:"integer"},
      {name:"OrderTemplate"} // related to templatesDS.Order
      ]
      });
      
      // Group hierarchy
      isc.TreeGrid.create({
      ID: "treeGroups",
      dataSource: groupsDS,
      selectionType: "single",
      autoFetchData: true,
      loadDataOnDemand: false,
      fields: [{name: "Description", formatCellValue:"record.Code+': '+value", frozen:true, width:250}],
      // customized appearance
      width:  350,
      height: 850,
      nodeIcon: "[SKIN]/folder_closed.png",
      folderIcon: "[SKIN]/folder_open.png",
      showOpenIcons: false,
      showDropIcons: false,
      showSelectedIcons: true,
      closedIconSuffix:"",
      // animateFolders: true,
      // animateFolderSpeed: 10
      showHeaderMenuButton: false,
      showHeader: false,
      nodeClick: function (treeGroups, node, recordNum) {
      if (treeGroups.isSelected(node)) {
      // populate Templates grid
      templates.fetchData({OrderGroups:node.Order});
      }
      }
      });
      
      // Templates list related to Groups
      isc.ListGrid.create({
      ID: "templates",
      autoDraw: true,
      width: 550,
      height: "30%",
      autoFetchData: true, // this is the question...!!!! If is true, apply fetchData(<criteria>).
      dataFetchMode: "basic",
      dataSource: templatesDS,
      fields: [{name:"Key"}, {name:"Adjective"}],
      canEdit: false,
      selectionType: "single",
      click: function (record) {
      if (this.getSelectedRecord()) {
      // populate Items grid
      items.fetchData({OrderTemplate:this.getSelectedRecord().Order});
      }
      }
      });
      
      // Items associated to templates
      isc.ListGrid.create({
      ID: "items",
      autoDraw: true,
      width: 910,
      height: "70%",
      autoFetchData: false, // here false, so, fetchData(<criteria>) doesn´t work. Always brings all records for different selection on templates Grid.
      dataFetchMode: "basic",
      dataSource: itemsDS,
      fields: [{name:"UserCode", title:"User Code", width:"20%"}, {name:"LDescription", title:"Description", width:"80%"}],
      canEdit: false,
      selectionType: "single"
      });
      If it is not enough, please ask me

      Brgds

      Comment


        #4
        Your dataURL points to a static file, so when the DataSource passes criteria to that file, nothing happens and all data is returned.

        If you want to use an XML file as a temporary DataSource for testing, use a clientOnly:true DataSource. Otherwise, either use our server framework to talk to a database, or implement your own server functionality that returns data based on criteria.

        This is all covered in the QuickStart Guide, especially the Data Integration chapter.

        Comment

        Working...
        X