treeview select all checkboxes in group node

Develop and Deploy Cross-Browser Web Apps .
Post Reply
sedrok
Posts: 26
Joined: Tue Jun 03, 2014 12:50 pm

treeview select all checkboxes in group node

Post by sedrok »

   
// The default code is a com class (inherited from xui.Com)
Class('App', 'xui.Com',{
    // Ensure that all the value of "key/value pair" does not refer to external variables
    Instance:{
        // To determine whether or not the com will be destroyed, when the first UI control be destroyed
        autoDestroy : true,
        // To initialize properties
        properties : {},
        // To initialize instance(e.g. properties)
        initialize : function(){
        },
        // To initialize internal components (mostly UI controls)
        // *** If you're not a skilled, dont modify this function manually ***
        iniComponents : function(){
            // [[Code created by CrossUI RAD Studio
            var host=this, children=[], append=function(child){children.push(child.get(0));};
           
            append(
                (new xui.UI.TreeView())
                .setHost(host,"ctl_treeview2")
                .setDirtyMark(false)
                .setShowDirtyMark(false)
                .setItems([{
                    "id" : "node_1",
                    "caption" : "node1",
                    "sub" : [{
                        "id" : "node11"
                    },{
                        "id" : "node12",
                        "image" : "http://www.crossui.com/RAD/img/demo.png"
                    },{
                        "id" : "node13"
                    },{
                        "id" : "node14"
                    }]
                },{
                    "id" : "node_2",
                    "caption" : "node2",
                    "sub" : [{
                        "id" : "node21"
                    },{
                        "id" : "node22"
                    },{
                        "id" : "node23"
                    },{
                        "id" : "node24"
                    }]
                }])
                .setSelMode("multibycheckbox")
                .setValue("")
                .onItemSelected("_ctl_treeview2_onitemselected")
            );
           
            return children;
            // ]]Code created by CrossUI RAD Studio
        },
        // Give a chance to determine which UI controls will be appended to parent container
        customAppend : function(parent, subId, left, top){
            // "return false" will cause all the internal UI controls will be added to the parent panel
            return false;
        },
        // Give a chance to load other resource
        iniResource: function(com, threadid){
            //xui.Thread.suspend(threadid);
            //var callback=function(/**/){
            //    /**/
            //    xui.Thread.resume(threadid);
            //};
        },
        // Give a chance to load other com
        iniExComs : function(com, threadid){
            //xui.Thread.suspend(threadid);
            //var callback=function(/**/){
            //    /**/
            //    xui.Thread.resume(threadid);
            //};
        },
        _ctl_treeview2_onitemselected:function(profile, item, e, src, type){
            var ns = this, uictrl = profile.boxing();
           
           var ret = "";
           var cur = ns.ctl_treeview2.getValue();
            _.each(ns.ctl_treeview2.getItems(), function(o,i) {
                if(o.id === item.id) {
                   console.log('было = '+cur);
                   _.each(o.sub, function(o1,i1) {
                       cur = cur.replace(new RegExp(o1.id+";",'g'),"");
                       cur = cur.replace(new RegExp(";"+o1.id,'g'),"");
                       cur = cur.replace(new RegExp(o1.id,'g'),"");
                       console.log(cur);
                       console.log(i1);

                       ret = ret + ';' + o1.id ;
                   });
                }                         
            });

            console.log('ret = ' + ret);
            if( cur.indexOf(item.id) !== -1 ) {               
               cur = cur + ret;
            }
            console.log("итог = " + cur);
            ns.ctl_treeview2.setValue(cur);
        }
    }
});
// The default code is a com class (inherited from xui.Com)
Class('App', 'xui.Com',{
    // Ensure that all the value of "key/value pair" does not refer to external variables
    Instance:{
        // To determine whether or not the com will be destroyed, when the first UI control be destroyed
        autoDestroy : true,
        // To initialize properties
        properties : {},
        // To initialize instance(e.g. properties)
        initialize : function(){
        },
        // To initialize internal components (mostly UI controls)
        // *** If you're not a skilled, dont modify this function manually ***
        iniComponents : function(){
            // [[Code created by CrossUI RAD Studio
            var host=this, children=[], append=function(child){children.push(child.get(0));};
           
            append(
                (new xui.UI.TreeView())
                .setHost(host,"ctl_treeview2")
                .setDirtyMark(false)
                .setShowDirtyMark(false)
                .setItems([{
                    "id" : "node_1",
                    "caption" : "node1",
                    "sub" : [{
                        "id" : "node11"
                    },{
                        "id" : "node12",
                        "image" : "http://www.crossui.com/RAD/img/demo.png"
                    },{
                        "id" : "node13"
                    },{
                        "id" : "node14"
                    }]
                },{
                    "id" : "node_2",
                    "caption" : "node2",
                    "sub" : [{
                        "id" : "node21"
                    },{
                        "id" : "node22"
                    },{
                        "id" : "node23"
                    },{
                        "id" : "node24"
                    }]
                }])
                .setSelMode("multibycheckbox")
                .setValue("")
                .onItemSelected("_ctl_treeview2_onitemselected")
            );
           
            return children;
            // ]]Code created by CrossUI RAD Studio
        },
        // Give a chance to determine which UI controls will be appended to parent container
        customAppend : function(parent, subId, left, top){
            // "return false" will cause all the internal UI controls will be added to the parent panel
            return false;
        },
        // Give a chance to load other resource
        iniResource: function(com, threadid){
            //xui.Thread.suspend(threadid);
            //var callback=function(/**/){
            //    /**/
            //    xui.Thread.resume(threadid);
            //};
        },
        // Give a chance to load other com
        iniExComs : function(com, threadid){
            //xui.Thread.suspend(threadid);
            //var callback=function(/**/){
            //    /**/
            //    xui.Thread.resume(threadid);
            //};
        },
        _ctl_treeview2_onitemselected:function(profile, item, e, src, type){
            var ns = this, uictrl = profile.boxing();
           
           var ret = "";
           var cur = ns.ctl_treeview2.getValue();
            _.each(ns.ctl_treeview2.getItems(), function(o,i) {
                if(o.id === item.id) {
                   console.log('было = '+cur);
                   _.each(o.sub, function(o1,i1) {
                       cur = cur.replace(new RegExp(o1.id+";",'g'),"");
                       cur = cur.replace(new RegExp(";"+o1.id,'g'),"");
                       cur = cur.replace(new RegExp(o1.id,'g'),"");
                       console.log(cur);
                       console.log(i1);

                       ret = ret + ';' + o1.id ;
                   });
                }                         
            });

            console.log('ret = ' + ret);
            if( cur.indexOf(item.id) !== -1 ) {               
               cur = cur + ret;
            }
            console.log("итог = " + cur);
            ns.ctl_treeview2.setValue(cur);
        }
    }
});
   
Attachments
yfuyfgoijop.jpg
yfuyfgoijop.jpg (23.29 KiB) Viewed 9152 times

Post Reply