Hello,
when using grid with multiple-selection mode and row template, ONLY single row selection works. Not able to select multiple rows. Grid somehow internally "reverts"(lose) selection to single row.
Here is full detail, with video and sample "what acts weird". Start with the post " Michal - Posted on: 19 Oct 2023 08:38":
Simplified reproducible sample from Nadezhda Tacheva(thanks), has that issue also - try to select multiple rows:
Video with the problem AND expected result(video is based on sample posted at same feedback above "Posted on: 19 Oct 2023 08:38":
https://feedback.telerik.com/attachment/download/1120622
Fully working example(recorded video) in VS - GridCheckBoxColumn in sample "IS HACK!", not required at all(just hint, which can be removed):
@using System.Collections.Generic;
@using System.Dynamic;
<span>Selection bind not working as expected:</span>
<TelerikGrid TItem="ExpandoObject"
@bind-SelectedItems="@gSelectedItems"
OnRowClick="@OnGridRowClicked"
SelectionMode="GridSelectionMode.Multiple"
OnRead=@gHLReadItems
RowHeight="60">
<RowTemplate Context="ctx">
<td>
@{
var it = (ctx as IDictionary<string, object>);
@(it["Name"].ToString())
}
</td>
</RowTemplate>
<GridColumns>
<GridCheckboxColumn CheckBoxOnlySelection="true" Visible="false" @key="@("sIDX1")" SelectAll="false" />
<GridColumn Field="Name" FieldType=@typeof(string) Title="Name" />
</GridColumns>
</TelerikGrid>
<span>WORKs OK:</span>
<TelerikGrid TItem="ExpandoObject"
@bind-SelectedItems="@gSelectedItems"
OnRowClick="@OnGridRowClicked"
SelectionMode="GridSelectionMode.Multiple"
OnRead=@gHLReadItems
RowHeight="60">
<GridColumns>
<GridCheckboxColumn CheckBoxOnlySelection="true" Visible="false" @key="@("sIDX2")" SelectAll="false" />
<GridColumn Field="Name" FieldType=@typeof(string) Title="Name" />
</GridColumns>
</TelerikGrid>
@code
{
private List<ExpandoObject> RowData;
IEnumerable<ExpandoObject> gSelectedItems { get; set; } = Enumerable.Empty<ExpandoObject>();
protected override void OnInitialized()
{
RowData = new List<ExpandoObject>();
dynamic obj0 = new ExpandoObject();
obj0.Name = "Tester";
RowData.Add(obj0);
dynamic obj1 = new ExpandoObject();
obj1.Name = "Testovicz";
RowData.Add(obj1);
dynamic obj2 = new ExpandoObject();
obj2.Name = "Selectant";
RowData.Add(obj2);
}
protected async Task gHLReadItems(GridReadEventArgs args)
{
//RowData are readen from DYNAMIC source, cannot add any NEW property to it
args.Data = RowData;
args.Total = 3;
}
protected void OnGridRowClicked(GridRowClickEventArgs args)
{
var it = args.Item as ExpandoObject;
if (gSelectedItems.Any(x => x == it))
{
gSelectedItems = gSelectedItems.Where(x => x != it);
}
else
{
gSelectedItems = gSelectedItems.Union(RowData.Where(x => x == it));
}
}
}
thanks