Announcement

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

    TreeGrid filtering problem

    I am using SmartClient_v111p_2017-09-16_LGPL with IE11.

    I am trying to hide certain rows of a TreeGrid. I started by following your example on Filtering Trees. The difference is that I am using a Tree (Tree.create) with the TreeGrid (TreeGrid.create) and client only DataSource (DataSource.create). When I set the filter,

    _isoDDTree.setCriteria({ Current: 'true' });

    Nothing is filtered. Is there a different technique for filtering when using a Tree?

    Thanks,
    Paul

    #2
    For in-place filtering, such as via the FilterEditor or by calling fetchData(), a ResultTree is required: it manages separately lists of loaded vs visible nodes.

    If you prefer to continue with Tree, you can use Tree.getFilteredTree(criteria) to get a reduced Tree, and apply that via setData().

    Comment


      #3
      I still have not gotten the filter to work. I have included a snippet of code. Can you tell me where I have gone wrong?

      Code:
      isc.Tree.create({
      ID: "_ddTreeData",
      root: {
      Display: "_ddTreeData", ID: "0", children: [
      { Display: "N08-00001", DisplayOrder: 0, Level: 0, ID: "N08-00001", Churn: 7, Editable: true, Current: "true", ItemIndex: 0, children: [
      { Display: "NITSS QA", DisplayOrder: 1, Level: 1, ID: "N08-00001", Churn: 11, Editable: false, Current: "true", ItemIndex: 1, children: [
      { Display: "Industrial" , DisplayOrder: 2, Level: 2, ID: "N08-00001", Churn: 13, Editable: true, Current: "false", ItemIndex: 2 },
      { Display: "Equipment Load", DisplayOrder: 3, Level: 2, ID: "N08-00001", Churn: 69, Editable: true, Current: "true" , ItemIndex: 3 }
      ]
      }
      ]
      }
      ]
      }
      });
      
      isc.DataSource.create({
      ID: "_isoDsDD",
      fields: [{ name: "Level", type: "integer" },
      { name: "ID", type: "text", length: 40, primaryKey: "true" },
      { name: "Display", type: "text", length: 50 },
      { name: "Churn", type: "integer" },
      { name: "Editable", type: "boolean" },
      { name: "Current", type: "text", length: 10 },
      { name: "ItemIndex", type: "integer" }]
      });
      
      isc.TreeGrid.create({
      ID: "_isoDDTree",
      top: 0,
      left: 1,
      width: 500,
      height: 110,
      alternateRecordStyles: true,
      DataSource: _isoDsDD,
      canSort: false,
      sortFieldNum: 8,
      sortDirection: "ascending",
      showHeaderContextMenu: false,
      canEdit: true,
      editByCell: true,
      selectOnEdit: true,
      selectionType: "single", // "simple", //"multiple", // "single",
      showOpenIcons: true,
      showDropIcons: true,
      showNodeIcons: false,
      showFolderIcons: false,
      folderIcon: null,
      nodeIcon: null,
      showFullConnectors: true,
      showRowNumbers: false,
      closedIconSuffix: "+",
      fields: [
      { name: "Display", title: "D&D Tree", width: 150, canEdit: false, align: "center" },
      { name: "ID", title: "ID", width: 70, canEdit: false, hidden: false },
      { name: "Churn", title: "Churn Days", width: 75, canEdit: true, cellAlign: "right", align: "center" },
      { name: "Editable", title: "Allow Edit", width: 65, canEdit: false, hidden: false, type: "boolean", canToggle: false },
      { name: "Current", title: "Current", width: 60, canEdit: false, hidden: false, cellAlign: "right", align: "center" },
      { name: "ItemIndex", title: "ItemIndex", width: 60, canEdit: false, hidden: false, cellAlign: "right", align: "center" }
      ]
      });
      
      isc.Button.create({
      ID: "_btnFilter",
      left: 10,
      top: 150,
      width: 100,
      title: "Filter",
      click: "btnFilter_Click(this)",
      enabled: true
      });
      
      _isoDDTree.setData(_ddTreeData);
      _isoDDTree.getData().openAll();
      
      function btnFilter_Click(btn) {
      if (btn.title.startsWith('Filter')) {
      _isoDDTree.setData(_ddTreeData.getFilteredTree({ Current: "true" }, "keepParents"));
      } else {
      
      }
      
      _isoDDTree.markForRedraw();
      
      }
      In the function btnFilter_Click, _ddTreeData.getFilteredTree({ Current: "true" }, "keepParents") is return null.

      Thanks,
      Paul

      Comment


        #4
        Check your Developer Console (always do this). You will find a warning telling you that the Tree has no DataSource, therefore can't filter. So assign the DataSource to Tree.dataSource in your tree.create().

        Comment


          #5
          I am using Visual Studio and haven't set up the Developer Console.

          I set the dataSource on the Tree and the data is being filtered, but I am losing the tree structure. I tried setting the primary key and foreign key in the DataSource, but this did not make a difference. I did change the IDs to be unique. If this is the key to maintaining the tree structure, how do you specify a compound key?

          Thanks,
          Paul

          Comment


            #6
            There's not really a "set up" process for the Developer Console. Unless you actively took steps to delete its files, it's already there and just needs to be opened. Please do this before reporting any further problems - using this tool is required (not using it is basically ignoring all framework diagnostics).

            As far as your filtered tree - since you set up the parent/child links by hand, there is no way for the framework to know how to link nodes once filtering has created a subset of the original nodes. To retain the structure, use the idField/parentIdField approach for linking nodes. This does not require a compound key. The Tree DataBinding overview covers this in detail, with links to samples.

            Comment


              #7
              Thanks, I got it working, with your help. From the database design, I will have to create a new ID field, the database uses a compound key.

              Comment

              Working...
              X