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

RadGrid disable a particular Row

1 Answer 186 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chandra
Top achievements
Rank 1
Chandra asked on 26 Sep 2014, 08:47 PM
Hi ,


I would like to disable a particular row based on a particular label name for instance "TEST", so if the Row has label name = "TEST", I would like to disable that entire row. There are two problems that I am facing.

1. I have a GridClientSelectColumn, and I'm inclined to thinking this the cause of the issue.
2. The row is being disabled only after a postback has occured.  But on initial load it is not being disabled.

For Each item As GridDataItem In grdVisibleColumns.MasterTableView.Items
            If item.Cells(3).Text = "TEST" Then
                item.Enabled = False
                Dim chkbx As CheckBox = DirectCast(item("grdVisibleChkBox").Controls(0), CheckBox)
                chkbx.Enabled = False
            End If
        Next

I put this code in the page pre-render event BTW, I tried placing the code in a number of places (Grid events), but it did not help, when the page initially loads the Row TEST is enabled.

Please advise.

Thanks.
Chandra

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 01 Oct 2014, 03:02 PM
Hello Chandra,

The behavior that you are observing is due to the fact that the PreRender event it too late in the page's life cycle. The correct event for disabling the row and the CheckBox control would be the OnItemDataBound:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
        If item.Cells(3).Text = "TEST" Then
            item.Enabled = False
            Dim chkbx As CheckBox = DirectCast(item("grdVisibleChkBox").Controls(0), CheckBox)
            chkbx.Enabled = False
        End If
    End If
End Sub

Please give this a try and see if the result meets your requirements.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Chandra
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or