hello,
since the RadGrid columns have no simple property for "IsRequired" (which would make data-entry required in edit mode), i had to write my own custom column classes. they work in MasterTableViews. cool.
but, they dont work when used in DetailTables. when i use this:
i get this:
here is the source code:
thanks,
matt
since the RadGrid columns have no simple property for "IsRequired" (which would make data-entry required in edit mode), i had to write my own custom column classes. they work in MasterTableViews. cool.
but, they dont work when used in DetailTables. when i use this:
<Nola:RequiredGridBoundColumn UniqueName="Name" HeaderText="Name" DataField="Name" MaxLength="50" /> |
i get this:
You must override Clone() for a derived grid column.
why is this?here is the source code:
namespace CustomTelerikExtensions |
{ |
/// <summary> |
/// An extended GridBoundColumn that requires users to enter data into the GridBoundColumn's TextBox. |
/// </summary> |
public class RequiredGridBoundColumn : GridBoundColumn |
{ |
public override void InitializeCell(TableCell cell, int columnIndex, GridItem gridItem) |
{ |
base.InitializeCell(cell, columnIndex, gridItem); |
// if in edit mode && the editor is not null |
if (gridItem.IsInEditMode && cell.Controls[0] != null) |
{ |
//assign ID of the default editor, if it is empty or null |
if (!Strings.Exists(cell.Controls[0].ID)) |
cell.Controls[0].ID = String.Format("{0}_TextBox", this.DataField); |
//add new required-field-validator |
RequiredFieldValidator requiredValidator = new RequiredFieldValidator(); |
requiredValidator.ID = gridItem.OwnerGridID + "_RequiredFieldValidator" + columnIndex; |
requiredValidator.ControlToValidate = cell.Controls[0].ID; |
requiredValidator.Text = " Required"; |
requiredValidator.CssClass = "required"; |
string message = String.Format("\"{0}\" cannot be empty.", this.HeaderText); |
requiredValidator.ErrorMessage = message; |
requiredValidator.ToolTip = message; |
//add validator to the cell |
cell.Controls.Add(requiredValidator); |
} |
} |
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
public override GridColumn Clone() |
{ |
return base.Clone(); |
} |
} |
} |
thanks,
matt