|
saulomartins
|
 |
« on: October 05, 2011, 10:38:42 AM » |
|
Hello! How are you!? I have a doubt about the language jslinb, i can't set values on the TreeView with multibycheckbox. How can i access the methods to get/set values on TreeView? i Try using "_xxx" like "_checked" but this does't work fine! Can you help me? Please see that function: "_treemenu_onitemselected"
Here goes my demo code:
|
|
|
|
|
Logged
|
|
|
|
|
saulomartins
|
 |
« Reply #1 on: October 06, 2011, 11:17:25 AM » |
|
Please!!!! I need Help here!! Thank you!!!
|
|
|
|
|
Logged
|
|
|
|
|
linb
|
 |
« Reply #2 on: October 07, 2011, 05:59:40 PM » |
|
You can learn these basic things from our demo or codesnip.
---------------------- Class('App', 'linb.Com',{ Instance:{ iniComponents : function(){ // [[code created by jsLinb UI Builder var host=this, children=[], append=function(child){children.push(child.get(0))}; append( (new linb.UI.SButton) .setHost(host,"ctl_sbutton1") .setLeft(200) .setTop(300) .setCaption("Set multi value") .onClick("_ctl_sbutton1_onclick") ); append( (new linb.UI.Pane) .setHost(host,"ctl_pane6") .setLeft(120) .setTop(10) .setWidth(300) .setHeight(250) ); host.ctl_pane6.append( (new linb.UI.TreeView) .setHost(host,"ctl_treeview1") .setItems([{"id":"node1", "sub":["node11", {"id":"node12", "image":"img/demo.gif"}, "node13", "node14"], "caption":"node1"}, {"id":"node2", "sub":["node21", "node22", "node23", "node24"], "caption":"node2"}]) .setSelMode("multibycheckbox") .setValue("") ); return children; // ]]code created by jsLinb UI Builder }, _ctl_sbutton1_onclick : function (profile, e, src, value) { var ns = this, uictrl = profile.boxing(); ns.ctl_treeview1.setValue("node1;node2"); } } });
|
|
|
|
|
Logged
|
|
|
|
|
Bruce_Dickey
|
 |
« Reply #3 on: October 11, 2011, 08:40:12 AM » |
|
saulomartins,
Is this what you had in mind? This is for a two-level multi tree. Make sure all your id's are unique.
Linb, If there is a better or more succinct way to do this, please indicate. Thanks.
|
|
|
|
« Last Edit: October 11, 2011, 09:09:40 AM by Bruce_Dickey »
|
Logged
|
|
|
|
|
linb
|
 |
« Reply #4 on: October 11, 2011, 05:29:07 PM » |
|
I don't understand what you are doing.
Why you set value in 'onitemselected' event? If you .setSelMode("multibycheckbox"), you can click the checkbox to select it(values were set auto), if you .setSelMode("multi"), you can just click the item to select it(values were set auto).
|
|
|
|
|
Logged
|
|
|
|
|
Bruce_Dickey
|
 |
« Reply #5 on: October 12, 2011, 02:14:24 PM » |
|
Hi Linb.
It is to check / uncheck all child items when a parent item is clicked.
I am very new to Linb -- I don't know of another / easier way to do that -- is there one?
Can you explain what you mean by "values were set to auto"? I set value to "auto" in the Builder (and commented out my onitemselected handler) w/o desired effect.
Thanks, Bruce
|
|
|
|
« Last Edit: October 12, 2011, 03:23:25 PM by Bruce_Dickey »
|
Logged
|
|
|
|
|
linb
|
 |
« Reply #6 on: October 12, 2011, 05:53:28 PM » |
|
Class('App', 'linb.Com',{ Instance:{ iniComponents:function(){ // [[code created by jsLinb UI Builder var host=this, children=[], append=function(child){children.push(child.get(0))}; append((new linb.UI.Block) .host(host,"block1") .setLeft(180) .setTop(170) .setWidth(140) .setHeight(400) ); host.block1.append((new linb.UI.TreeBar) .host(host,"treebar3") .setItems([{"id":"item a", "caption":"item a", "sub":[{"id":"sub a1", "caption":"sub a1", "sub":[{"id":"sub a111", "caption":"sub a111"}, {"id":"sub a222", "caption":"sub a222"}]}, {"id":"sub a2", "caption":"sub a2"}, {"id":"sub a3", "caption":"sub a3"}, {"id":"sub a4", "caption":"sub a4"}]}, {"id":"item b", "caption":"item b", "sub":[{"id":"sub b1", "caption":"sub b1"}, {"id":"sub b2", "caption":"sub b2"}, {"id":"sub b3", "caption":"sub b3", sub: [{"id":"sub b4", "caption":"sub b4"}]}]}]) .setSelMode("multi") .onItemSelected("_treebar3_onitemselected") ); return children; // ]]code created by jsLinb UI Builder }, _treebar3_onitemselected:function (profile, item, src) { var checked, uiv = profile.boxing().getUIValue(), arruiv = uiv.split(';'), traversal = function(item,arr){ _.arr.each(item.sub,function(o){ arr.push(o.id); if(o.sub!=null) traversal(o,arr); }) }; if(_.arr.indexOf(arruiv,item.id)!=-1) checked=true;
var arr=[]; traversal(item,arr);
if(arr.length){ _.filter(arruiv,function(o){ return _.arr.indexOf(arr,o)==-1; }); if(checked) _.arr.insertAny(arruiv, arr, -1);
profile.boxing().setUIValue(arruiv.join(';')); } } } });
|
|
|
|
|
Logged
|
|
|
|
|
Bruce_Dickey
|
 |
« Reply #7 on: October 13, 2011, 08:10:46 AM » |
|
Nice - handles an arbitrary number of levels with the traversal function.
Thanks!
|
|
|
|
|
Logged
|
|
|
|
|