mercredi 16 novembre 2016

Check all checkbox taking long time to check all checkboxes in gridview

I am using below code to check all checkboxes in gridview. Gird in having approx 2000 to 2500 records. But it is taking long time to check all checkboxes also sometimes the page stops responding when clicked on checkall checkbox.

Please suggest improvement for this. It will be helpful.

function checkAll(checkAllBox)
        {

        var chkBoxId;
        chkBoxId = "chkSelect";     

        //alert(checkAllBox.value);


        //alert(chkBoxId);
        var chkState = checkAllBox.checked;

        for(i=0;i<document.Form1.length;i++)
        {
            e = document.Form1.elements[i];

            if(e.type == 'checkbox' && e.name.indexOf(chkBoxId) != -1)
            {
                checkAllBox.checked = chkState;
                if(e.disabled == false)
                {
                    e.checked=chkState;                     
                }       
            }
            else if(e.type == 'checkbox' && e.name.indexOf(chkBoxId) == -1)
            {
                if(chkState == true)
                {
                    e.checked = false;
                }

            }
        }
    }




Aucun commentaire:

Enregistrer un commentaire