Javascript to perform validations based on datagrid's hidden column values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Blacky
    New Member
    • Jan 2009
    • 40

    Javascript to perform validations based on datagrid's hidden column values

    Hi,

    I am using c# asp.net application.I have datagrid which binds column dynamically and i make certain columns say visibility to false in my itemdatabound event EMPID AS E.ITEM.CELLS[3].VISIBLE = FALSE.Now i want to perform validations based on this value in cell[3] using javascript...

    By clicking on one rows checkbox in datagrid, i need to color all other rows which has the same value in the hidden column EMP... IE cells[3]..

    Code:
    function colorSelectedRow(chkB)
            {
                var prefix = getCrtlPrefix();
                
                var dataGridCtrlName = prefix + 'dg_Approve';
                
                var hiddenTxtBoxName = prefix + 'hdnTxtRowOrgColor';
                 
                //// Highlight the row of Matched Grid based on the Checkbox selection
                var IsChecked = chkB.checked;
                
                var navRoot,node,dgRowid = null,tBody,rwVal;
                 
                //// Get the RowID of the row checked by the user
                var rowID = chkB.parentElement.parentElement.cells[1].innerText;
                alert(rowID);
                //// Get the GroupID of the row checked by the user
                [B]var reconseqNo = chkB.parentElement.parentElement.cells[3].innerText;[/B]            alert(reconseqNo);
                
                if(document.all && document.getElementById)
                {
                    navRoot = document.getElementById(dataGridCtrlName);
                    if(navRoot != null)
                    {
                        tBody = navRoot.childNodes[0];
                   if(IsChecked)
                    {             
                        //// Loop through all the childnodes of the Form body to Highlight the Row checked by user and also its Matching Row
                        for(i=1;i<tBody.childNodes.length;i++)
                        {
                            node = tBody.childNodes[i];
                   
                            //node.style.backgroundColor = "Khaki";
                             if(node.cells[1].innerText == rowID)
                            {   
                                         document.getElementById(node.childNodes[0].childNodes[0].id).checked = true;
                                        if(document.getElementById(hiddenTxtBoxName).value == '')
                                              node.style.backgroundColor = "Khaki";
                            }
                            
                            if(node.cells[3].innerText == rowID)
                            {   
                                         document.getElementById(node.childNodes[0].childNodes[0].id).checked = true;
                                        if(document.getElementById(hiddenTxtBoxName).value == '')
                                              node.style.backgroundColor = "Khaki";
                            }
                        }
                        }

    Reply asap
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    and what exactly is not working? (what does the code do/not do?)

    Comment

    • Blacky
      New Member
      • Jan 2009
      • 40

      #3
      When i click a checkbox in datagrid based on the reference column value of the row which is made visible false i need to automatically check the checbox of the matched rows and color it. It works fine if the reference column visibility is true. I want to perform the checking n coloring of matched rows based on the reference column which is made visible false at runtime

      Comment

      Working...