This is a migrated thread and some comments may be shown as answers.

Disable Grid

2 Answers 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin Cauchi
Top achievements
Rank 1
Kevin Cauchi asked on 18 Sep 2012, 12:34 PM
How do you disable and grey out a grid in javascript?

Thanks in advance

K

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Sep 2012, 01:02 PM
Hi,

Here is the script I tried. Please take a look into it.

Javascript:
function pageLoad()
{
    var grid = $find("<%=RadGrid1.ClientID %>");   
    grid._element.disabled = true;
}

Thanks,
Shinu.
0
Kevin Cauchi
Top achievements
Rank 1
answered on 18 Sep 2012, 03:05 PM
_element is undifined.

My solution is this:

function EnableDisableChildren(control, isenabled) {
 
     //disable the control
     control.disabled = !isenabled;
      
     //grey out the control
     if (control.style != null) {
         if (!isenabled)
             control.style.color = "#888";
         else
             control.style.color = "";
     }
 
     //If there are any links, hide them as they cannot be disabled
     if ((control.type != null) && (control.type == '')) {
         if (isenabled) {
             control.style.display = 'block';
         }
         else
             control.style.display = 'none';
     }
 
     //Do the same for the children
     for (var i = 0; i < control.children.length; i++) {
         EnableDisableChildren(control.children[i], isenabled);
     }
 }

Although this works, it  worries me a bit... maybe there are some consequences to it.
Tags
Grid
Asked by
Kevin Cauchi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kevin Cauchi
Top achievements
Rank 1
Share this question
or