Announcement

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

    TreeGrid isLeaf function ??

    using SmartClient 8.3

    I'm trying to implement this function in a TreeGrid to prevent removal of a node if the node is a folder (has child nodes):

    Code:
    removeSelectedNodeIfNoChildrenExist: function(data, node) {
       if (this.data.isLeaf(node)) {
          isc.say("huh");
       //this.removeSelectedData();
       }
    }
    Problem is, in my example code above, it always executes the code in my if block regardless of whether the node is a leaf or has children.

    So, I have two questions:

    1. What am I doing wrong with my client side code?

    2. How would I go about preventing deletion of a node with child nodes via some bit of magic in my server side data source declaration? I suspect I would put something in the "remove" operationBinding, but need help on what that would look like.

    Thanks for any help!
    Jerry
    Last edited by jerry426; 25 Mar 2013, 09:39.

    #2
    partially solved by hacked workaround...

    Ok... so I solved part of my problem for now by creating a client-side function which fetches child records which then allows me to get the length of the returned data array. Here's what I did:

    Code:
       function setChildGroupVariables(groupId) {
          isc.DataSource.get("Groups").fetchData({groupParentId: groupId},
          function(dsResponse, data) {
             childGroupCount = data.length;
          });
       }
    which then lets me use the childGroupCount elsewhere as a boolean. I'm sure there's a cleaner way to do this and with luck I'll stumble across it later.

    However, if anyone could point me in a direction toward preventing deletion of a node whenever that node has child records (it's a self referential parent/child relationship in a single table) by some magic in my server side DataSource declaration xml file I would be most grateful!

    Thanks,
    Jerry

    Comment

    Working...
    X