Saturday 27 September 2014

Select/Unselect All inside griview with modal popup using javascript with Color selected rows


//Gridview

<asp:TemplateField >
 <ItemTemplate>
 <asp:CheckBox runat="server" ID="Chk_allCh" />
  </ItemTemplate>
 <HeaderTemplate>
 <asp:CheckBox runat="server" ID="Chk_all" onclick="checkAllRow(this);" />
</HeaderTemplate>
</asp:TemplateField>


//Script

function checkAllRow(objRef) {
       var GridView = objRef.parentNode.parentNode.parentNode.parentNode.parentNode;
       var inputList = GridView.getElementsByTagName("input");
       for (var i = 0; i < inputList.length; i++) {
           //Get the Cell To find out ColumnIndex
           var row = inputList[i].parentNode.parentNode;
           if (inputList[i].type == "checkbox" && objRef!= inputList[i]) {
              if (objRef.checked) {
       //If the header checkbox is checked//check all checkboxes//and highlight all rows
                 row.style.backgroundColor = "#5CADFF";
                 inputList[i].checked = true;
                }
           else {
       //If the header checkbox is checked//uncheck all checkboxes//and change rowcolor back to original
               if (row.rowIndex % 2 == 0) {
                //Alternating Row Color
                  row.style.backgroundColor = "#AED6FF";
                  }
                  else {
                   row.style.backgroundColor = "white";
                     }
                      inputList[i].checked = false;
                           }
                       }
                   }

               }

No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...