[CLOSED] TreeGrid : Check child checkbox with parent checkbox checked

Page 3 of 4 FirstFirst 1234 LastLast
  1. #21
    OK, but you will need to repeat the same process when applying the permissions of a module or submodule elsewhere in your project, eventually.
  2. #22
    Not clearly get you.can you please let me one thing?after page load I get menu checkbox checked or unchecked .so is it possible a back calculation with java script?
  3. #23
    Let's get back to the problem at hand...

    The following code will check/uncheck all children of a checked/unchecked parent and will check/uncheck a parent if all children are checked/unchecked.

    Please, note that you have to apply same logic when the tree is loaded with data.


    var onCheckChange = function (obj, node) {
        console.log(node)
    
        if (!node.locked) {
            node.locked = true;
    
            // if parent is checked/unchecked then check/uncheck all children, too
            node.cascadeBy(function (childNode) {
                childNode.set(obj.dataIndex, node.data[obj.dataIndex]);      
            });
                
            // if all children are checked/unchecked then check/uncheck the parent, too
            var status = node.data[obj.dataIndex];
            node.bubble(function (n) {
                    var childNodes = this.childNodes;
                    var length = childNodes.length;
                    var allCheckStatus = true;
    
                    for (var i = 0; i < length; i++) {
                        if (childNodes[i].data[obj.dataIndex] != status) {
                            allCheckStatus = false;
                            break;
                        }
                    }
    
                    if (allCheckStatus) {
                        n.set(obj.dataIndex, node.data[obj.dataIndex]);
                    }
            });
        }
        node.locked = false;
    }
  4. #24
    Thanks for minimize code with new approach.I try in Treestore

    l.Load.Handler = "onCheckChange(this,node)";
    the function called but check/uncheck a parent functionality not performing.
  5. #25
    You said you only store the state of the parents in your database. So, when loading the tree you can only apply cascadeBy, which should be enough.
  6. #26
    Hi,@Mimisss
    You said you only store the state of the parents in your database.
    No, I store only last child ,here menu.
    http://forums.ext.net/showthread.php...l=1#post234681
    So, when loading the tree you can only apply cascadeBy, which should be enough.
    Not get your clue.Its very helpful for me you do this with my example which post previously.

    thankx
  7. #27
    OK, you need to bubble instead of cascade. I think it should be done each time a leaf node is added to the tree with the leaf node passed as a parameter to the handler function...
    Last edited by Dimitris; Jan 19, 2015 at 4:43 AM.
  8. #28
    Hi
    I am bit confused and don't understand which handler to use ?so a mock up code sample will be appreciate .
  9. #29
    There is the itemAppend handler with the node and it's index as params but further changes are required since the ChangeChange listener is applied to each of the P columns and different params are provided... May I suggest another option? What about adding the logic in code behind when the data are constructed?
  10. #30
    May I suggest another option? What about adding the logic in code behind when the data are constructed?
    I think this is not possible with current database structure.
    There is the itemAppend handler with the node and it's index as params but further changes are required since the ChangeChange listener is applied to each of the P columns and different params are provided
    If possible can you please elaborate this.some code sample is good for my understanding.
Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. [CLOSED] Another way to check checkbox is checked ot not....
    By rosua in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 21, 2012, 5:39 AM
  2. [CLOSED] Check all checkbox for TreeGrid
    By bakardi in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 04, 2012, 7:25 AM
  3. Replies: 11
    Last Post: Mar 14, 2012, 10:12 AM
  4. Replies: 1
    Last Post: Aug 13, 2009, 9:37 AM
  5. Replies: 0
    Last Post: Jun 25, 2009, 12:16 PM

Posting Permissions