Skip to content Skip to sidebar Skip to footer

Jquery Searchable Checkbox List And Tristate Checkbox

I'm building a simple asp page on which I have list of peoples with checkbox on left of every name. I've managed to create a simple jQuery script that allows hiding and showing row

Solution 1:

A tristate checkbox is like the Three-Portal Device: an illusion.

What you actually want is to make the checkbox indeterminate (by setting the property of the same name to true). To implement this, you will need a change (or click) handler on each checkbox, then you'll need to check if all of them are in the same state, and if not then you set the indeterminate property. It's a hassle, really, because you rarely see indeterminate checkboxes and so most users don't know what to do with them. To be avoided, if possible.

Solution 2:

To create multiple instances of the same plugin access elements relatively to an other element.

For example: in your case instead of keeping the item in a jQuery object var $tableRows = $('table.myList tr'); access them in the event.

$('#user_name').keyup(function () {
    var sValue = $.trim($('input#user_name').val());
    if(lastInput==sValue) return;
    var $tableRows = $(this).next().next().find("table.myList tr");
    if (sValue == '') {
        $tableRows.show();
    } else {
        $tableRows.each(function () {
            var oLabel = $(this).find('label');
            if (oLabel.length > 0) {
                if (oLabel.text().toLowerCase().indexOf(sValue.toLowerCase()) >= 0) {
                    $(this).show();
                } else {
                    $(this).hide();
                }
            }
        });
        lastInput=sValue;
    }
});

and you only have your actual list.

And for the tree state checkbox you don t need a plugin just add a button or link and every click check it status you can keep the status by jQuery data and change the element image according to this data.

Post a Comment for "Jquery Searchable Checkbox List And Tristate Checkbox"