Hi.
My first question is about Master-Details grid:
I've created a hirarchial grid where the details table is a many-to-many junction talbe (i.e - master is custumers, details is customerToProduct) and all the details have is a single dropdown column with the name of the detail.
My problem is that if I set the AutoGenerateEditColumn to True, I also get an Edit column in the details grid, that I don't want.
My question is How can I set the edit column only for the master table?
My second question is about validation. I used the code examples provided by telerik to add a RequiredFieldValidator to a textBox column, and with a little t & e managed to adapt it also to Numeric columns and DateTime columns.
Now I have 3 methods, each for every column type mentioned about (text, numeric, and datetime).
My problem with that is that all of these 3 methods have almost the exact same code, except for the editor part - see attached snippet:
If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
Dim item As GridEditableItem = CType(e.Item, GridEditableItem)
Dim editor As GridTextBoxColumnEditor = CType(item.EditManager.GetColumnEditor("ContactName"), GridTextBoxColumnEditor)
Dim cell As TableCell = CType(editor.TextBoxControl.Parent, TableCell)
Dim validator As RequiredFieldValidator = New RequiredFieldValidator
editor.TextBoxControl.ID = "ID_for_validation"
validator.ControlToValidate = editor.TextBoxControl.ID
validator.ErrorMessage = "*"
cell.Controls.Add(validator)
End If
for Numeric column I use Dim editor As GridNumericColumnEditor = CType(item.EditManager.GetColumnEditor(ColumnUniqueName), GridNumericColumnEditor)
and for DateTime column I use Dim editor As GridDateTimeColumnEditor = CType(item.EditManager.GetColumnEditor(ColumnUniqueName), GridDateTimeColumnEditor)
My question is how can I use a single method to attach a required field validator to all kinds of built-in columns of the grid?
My first question is about Master-Details grid:
I've created a hirarchial grid where the details table is a many-to-many junction talbe (i.e - master is custumers, details is customerToProduct) and all the details have is a single dropdown column with the name of the detail.
My problem is that if I set the AutoGenerateEditColumn to True, I also get an Edit column in the details grid, that I don't want.
My question is How can I set the edit column only for the master table?
My second question is about validation. I used the code examples provided by telerik to add a RequiredFieldValidator to a textBox column, and with a little t & e managed to adapt it also to Numeric columns and DateTime columns.
Now I have 3 methods, each for every column type mentioned about (text, numeric, and datetime).
My problem with that is that all of these 3 methods have almost the exact same code, except for the editor part - see attached snippet:
If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
Dim item As GridEditableItem = CType(e.Item, GridEditableItem)
Dim editor As GridTextBoxColumnEditor = CType(item.EditManager.GetColumnEditor("ContactName"), GridTextBoxColumnEditor)
Dim cell As TableCell = CType(editor.TextBoxControl.Parent, TableCell)
Dim validator As RequiredFieldValidator = New RequiredFieldValidator
editor.TextBoxControl.ID = "ID_for_validation"
validator.ControlToValidate = editor.TextBoxControl.ID
validator.ErrorMessage = "*"
cell.Controls.Add(validator)
End If
for Numeric column I use Dim editor As GridNumericColumnEditor = CType(item.EditManager.GetColumnEditor(ColumnUniqueName), GridNumericColumnEditor)
and for DateTime column I use Dim editor As GridDateTimeColumnEditor = CType(item.EditManager.GetColumnEditor(ColumnUniqueName), GridDateTimeColumnEditor)
My question is how can I use a single method to attach a required field validator to all kinds of built-in columns of the grid?