Hi there,
I've created a grid with columns that can be added dynamically, but I'm unable to use incell editing in the dynamically created columns.
QuestionData is a Dictionary<string, object>
Source below:
<TelerikGrid Data=@QuestionGroup
ScrollMode="@GridScrollMode.Scrollable"
Height="35vh"
EditMode="@GridEditMode.Incell"
Resizable="true"
@ref="gridref"
Reorderable="true"
RowDraggable="true"
OnRowDrop="@((GridRowDropEventArgs<EvaluateQuestion> args) => OnRowDropHandler(args))"
OnCreate="@CreateHandlerAsync">
<GridSettings>
<GridRowDraggableSettings DragClueField="@nameof(EvaluateQuestion.Title)"></GridRowDraggableSettings>
</GridSettings>
<GridToolBar>
<GridCommandButton Command="Add">New Question</GridCommandButton>
<TelerikButton OnClick="NewColumn">New Column</TelerikButton>
<TelerikButton OnClick="RemoveGrid">Remove Grid</TelerikButton>
</GridToolBar>
<GridColumns>
<GridColumn Field="Title">
</GridColumn>
<GridColumn Field="FullQuestion">
</GridColumn>
@foreach (string entry in Template.ColumnHeadings)
{
<GridColumn Title="@entry">
<Template>
@{
var c = context as EvaluateQuestion;
if (c.QuestionData.TryGetValue(entry, out var check))
{
@c.QuestionData.Where(v => v.Key == entry).FirstOrDefault().Value
}
else
{
c.QuestionData.Add(entry, new string("test"));
}
}
</Template>
<EditorTemplate>
</EditorTemplate>
</GridColumn>
}
</GridColumns>
</TelerikGrid>
public void NewColumn() {
Template.ColumnHeadings.Add(new string("Placeholder"));
StateHasChanged();
}