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

Radgrid Conditional Editing

3 Answers 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 07 Jul 2009, 12:35 PM
I have a RadGrid with 8 Columns. The last 5 columns are editable. however what I am trying  to achieve is :

On first edit all 5 editable cells are empty, but initially need the last 3 cells to remain uneditable unless something is entered into the first two cells. 

Can anyone guide me on how to do that?

Thx

Mark

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 09 Jul 2009, 03:29 PM
Hello Mark,

Thank you for contacting us.

To achieve your goal you need to write a custom JavaScript method, which will be called when onkeypress event is raised. To accomplish this task you can wire the ItemCreated event and check whether the item is GridEditableItem and the e.Item.IsInEditMode is "true". If the condition is true, you can retrieve the IDs of controls, which are placed in the edit form. Hence you can disable the last three textboxes and assign the custom JavaScript method to the onkeypress event of the first two controls. The method will check whether the first two controls are empty or not and will disable/enable the last three textboxes.

Please give this suggestion a try and let me know how it goes.

Best regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Pam
Top achievements
Rank 2
answered on 12 Sep 2012, 11:17 PM
Can you give a sample code on vb.net to accomplish this? thanks.
0
Shinu
Top achievements
Rank 2
answered on 19 Nov 2012, 06:20 AM
Hi Pam,

I guess you want the code steps in VB.

VB:
Protected Sub RadGrid1_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs)
    If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
        Dim eitem As GridEditableItem = DirectCast(e.Item, GridEditableItem)
        Dim txt1 As TextBox = DirectCast(eitem("UniqueName1").Controls(0), TextBox)
        Dim txt2 As TextBox = DirectCast(eitem("UniqueName2").Controls(0), TextBox)
        Dim txt3 As TextBox = DirectCast(eitem("UniqueName3").Controls(0), TextBox)
        Dim txt4 As TextBox = DirectCast(eitem("UniqueName4").Controls(0), TextBox)
        Dim txt5 As TextBox = DirectCast(eitem("UniqueName5").Controls(0), TextBox)
        txt3.Enabled = False
        txt4.Enabled = False
        txt5.Enabled = False
        txt1.Attributes.Add("onkeypress", "OnKeyPress1('" + txt2.ClientID + "','" + txt3.ClientID + "','" + txt4.ClientID + "','" + txt5.ClientID + "')")
 
        txt2.Attributes.Add("onkeypress", "OnKeyPress2('" + txt1.ClientID + "','" + txt3.ClientID + "','" + txt4.ClientID + "','" + txt5.ClientID + "')")
    End If
End Sub

Thanks,
Shinu.
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Pam
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Share this question
or