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

[Solved] How to know if GridDataItem is Enabled on the client?

1 Answer 155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Grisha
Top achievements
Rank 1
Grisha asked on 21 Jan 2008, 03:52 PM
I want to show all items in the grid but some for wich I set enabled property to false on the server I don't want to be selectable.
Does anybody jnows is there a way to get this property on the client in RowSelecting event handler?

Thanks,
Grisha

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 23 Jan 2008, 11:21 AM
Hi Grisha,

You can conditionally cancel the selecting event. On the other hand, the enabled property is only meaningful under IE, since it is not properly applied under FF. However, you can take the following approach. First, you can assign a css class on some of the rows, according to your logic, which resembles a disabled row. On in the rowselecting event, you can cancel the event if the css class is the same.
This is demonstrated in the code snippet below:

.css
<style type="text/css">  
      
    .class1  
    {  
     background-color:Gray;  
     color:White;  
    }  
      
    </style> 

.cs
  protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        RadGrid1.MasterTableView.Items[2].CssClass = "class1";  
        RadGrid1.MasterTableView.Items[4].CssClass = "class1";  
    } 

.Js
 <script type="text/javascript">  
      
    function RowSelecting (sender, eventArgs)  
    {  
    var row = eventArgs.get_tableView().get_dataItems()[eventArgs.get_itemIndexHierarchical()].get_element();  
      
        if(row.className=="class1")  
        {  
        eventArgs.set_cancel(true);          
        }  
    }      
      
    </script> 

I hope this information helps.

Greetings,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Grisha
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or