If I create a <TelerikGrid> whose Data property is set to a collection of 'object' (actual type not known at compile time, only at runtime), I can create <GridColumn> components for each property through e.g.
@{
IEnumerable<PropertyInfo> props = GetModelType().GetProperties();
foreach (PropertyInfo prop in props)
{
string propName = prop.Name;
<GridColumn Field="@propName" ... />
}
}
@code {
private Type GetModelType()
{
Type modelType = ...; // code determines the type of model at runtime ...
return modelType;
}
}
This works fine if the grid's EditMode is GridEditMode.Popup. When editing a row, the popup dialog properly displays each column header and value and binds correctly.
However, this does not work if the EditMode is GridEditMode.Inline nor GridEditMode.Incell. When placing the row in edit mode, no editor control appears at all, and the value in the cell is displayed as blank.
The design of the grid component thus only works well when given a known type at compile time, or one is constrained to always use Popup edit mode due to this flaw.
In addition to a request to fix this, it would also be great if the grid could be passed a Type (a runtime type, not a class name) to use for generating columns automatically, rather than having to resort to developers having to use reflection to generate grid columns themselves.
For instance,
<TelerikGrid T="@GetModelType()" ...> should invoke the GetModelType() method which would return a type at runtime, not necessarily known at compile time. Currently T can only be set to a hard-coded type name such as "Employee".