jQWidgets Forums

jQuery UI Widgets Forums General Discussions Lists ListBox "SelectAll" item inside listbox (checkboxes enabled)

This topic contains 2 replies, has 2 voices, and was last updated by  jonmikelm 12 years, 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • jonmikelm
    Member

    Hi All,

    I am trying to use the first item in a listbox as a Select all/none button. I have assigned a checkChange event to the listbox in this way:

    $("#listbox").bind('checkChange', function (event) {
    var args = event.args;
    //get the item and it's label and value fields.
    var item = args.item;
    //I check or un check all just if the item with 0 value is changed
    if(item.value == 0){
    // get new check state.
    var checked = args.checked;
    if(checked){
    $("#listbox").jqxListBox('checkAll');
    }else{
    $("#listbox").jqxListBox('uncheckAll');
    }
    }
    });

    The problem is that the checkChange event, gets fired also when I call the checkAll & uncheckAll methods. The next error happens:

    TypeError: item is undefined

    I have tried with event.stopPropagation() as the first instruction of the checkChange event function, but it doesn’t work.

    I can go through this error using a try/catch in the event function, but it’s not a “nice” solution.

    Any other way to create a select all/none item inside the listbox?

    thanks & regards

    Jon Mikel


    Peter Stoev
    Keymaster

    Hi Jon Mikel,

    The following sample illustrates how to achieve that: customfiltering.htm.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    jonmikelm
    Member

    Thank you very much Peter,

    That solved all my problems. Keep on working on these great tools!!

    Thanks again!!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.