Sigma Php Ajax framework, Ajax Components, GUI Builder
May 24, 2012, 11:44:32 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: TreeView onClick event for checkbox?  (Read 1072 times)
Bruce_Dickey
Sr. Member
****
Posts: 67


View Profile
« on: October 20, 2011, 03:29:55 PM »

Hi,

I've noticed that with the "multi"-select TreeView, the onClick event is fired when clicking on the caption or on the icon, but not when clicking on the checkbox itself.

This is very unexpected compared to other UIs.  How can I get an onClick event when clicking on a checkbox in a "multi"-select TreeView?

Thanks,
Bruce
« Last Edit: October 21, 2011, 01:42:16 PM by Bruce_Dickey » Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #1 on: October 20, 2011, 09:46:03 PM »

Does TreeView has onClick event?
Logged
Bruce_Dickey
Sr. Member
****
Posts: 67


View Profile
« Reply #2 on: October 21, 2011, 09:15:43 AM »

No, you are right: TreeView does not have the onClick event (available to the user of the library in the normal usage as I understand it). I was thinking that the checkbox would be a linb.UI.SCheckbox or similar -- but looking now that has an onChecked event, not onClick.

BUT, if I set a breakpoint on the onItemSelected handler for the "multi" select TreeView, and go looking at the control returned from profile.boxing(), I see things like:

uictrl._nodes[0].behavior.MARK2.onClick                -- Is MARK2 the Checkbox?
uictrl._nodes[0].behavior.ITEMICON.onClick
uictrl._nodes[0].behavior.ITEMCAPTION.onClick

So to re-write my question better --

How can I get my own handler assigned to that onClick when single-clicking on a checkbox in a "multi"-select TreeView?
Something like the following (that doesn't work)?

.setEvents( { MARK2.onClick : "_ctl_treeview_onClick" } )

Thanks!
« Last Edit: October 21, 2011, 01:41:59 PM by Bruce_Dickey » Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #3 on: October 21, 2011, 07:58:37 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.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"}])
                .setDock("none")
                .setLeft(60)
                .setTop(60)
                .setHeight(70)
                .setSelMode("multi")
                .setValue("")
                .onItemSelected("_treeview_onitemselected")
            );
           
            append(
                (new linb.UI.TreeView)
                .setHost(host,"ctl_treeview5")
                .setItems([{"id":"node1", "sub":["node11", {"id":"node12", "image":"img/demo.gif"}, "node13", "node14"], "caption":"node1"}, {"id":"node2", "sub":["node21", "node22", "node23", "node24"], "caption":"node2"}])
                .setDock("none")
                .setLeft(310)
                .setTop(60)
                .setHeight(70)
                .setSelMode("multibycheckbox")
                .setValue("")
                .onItemSelected("_treeview_onitemselected")
            );
           
            append(
                (new linb.UI.SLabel)
                .setHost(host,"ctl_slabel3")
                .setLeft(60)
                .setTop(40)
                .setCaption("multi")
            );
           
            append(
                (new linb.UI.SLabel)
                .setHost(host,"ctl_slabel4")
                .setLeft(310)
                .setTop(40)
                .setCaption("multi by checkbox")
            );
           
            return children;
            // ]]code created by jsLinb UI Builder
        },
        _treeview_onitemselected : function (profile, item, e, src, type) {
            switch(type){
              case -1:
                    linb.message("'" + item.id + "' was clicked to uncheck.");
              break;
              case 1:
                    linb.message("'" + item.id + "' was clicked to check.");
              break;
              default:
                    linb.message("'" + item.id + "' was clicked for normal event.");
            }
        }
    }
});
Logged
Bruce_Dickey
Sr. Member
****
Posts: 67


View Profile
« Reply #4 on: October 21, 2011, 09:36:46 PM »

Super! Thank you.

To summarize, both "multi" and "multibycheckbox" have checkboxes, but I need to use "multibycheckbox" instead of "multi" in order to be able to distinguish between clicking on the checkbox itself versus the icon or caption.
« Last Edit: October 21, 2011, 09:43:36 PM by Bruce_Dickey » Logged
Bruce_Dickey
Sr. Member
****
Posts: 67


View Profile
« Reply #5 on: October 24, 2011, 10:11:17 AM »

Hi,

Oops, your example works with Firefox, but not with Chrome. That is, the onitemselected event is not fired when clicking on the checkbox when the TreeView selection mode is set to "multibycheckbox", in Chrome.

I thought perhaps I should update from v3.0 to v4.0, which I did, but that did not help.

Is this a bug or is there any way around this?

Thanks,
Bruce

Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #6 on: October 24, 2011, 05:42:39 PM »

I run the code with Chrome, it works well.
Logged
Bruce_Dickey
Sr. Member
****
Posts: 67


View Profile
« Reply #7 on: October 25, 2011, 01:31:08 PM »

Now same for me today, for your code. My large app still is misbehaving. I'll update this post when I find out why.

Later: Boiled down the files to the code shown below.

Problem: Not getting the event when clicking on the checkbox for the "multibycheckbox" tree.  Same in Chrome and Firefox.

For both working and non-working cases: Running on Red Hat Enterprise Linux 6, 64-bit, Apache sever, web2py web framework.

Conditions when not working: Running stand-alone with my index.html and my agile_diags.js files.

Conditions when working: Running in VisualJS (also from Apache and web2py) without using my index.html and agile_diags.js files.

This looks like it should be fairly simple, but I'm stumped. Please help.

Thanks,
Bruce

index.js


index.html


agile_diags.js

« Last Edit: October 27, 2011, 12:55:50 PM by Bruce_Dickey » Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #8 on: October 27, 2011, 05:41:10 PM »

I tested it, it works well in two conditions.
Logged
Bruce_Dickey
Sr. Member
****
Posts: 67


View Profile
« Reply #9 on: October 28, 2011, 05:39:24 PM »

Things that make you go "Hmmmm..."

Well, I'll figure it out some day. Must be something in my environment.. Thanks for taking a look.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!