Is it possible to use SfGrid.SelectRows, with RowTemplates
I'm trying to use the SelectRows method of the SfGrid, following the example showed here Selection in Blazor DataGrid component - Syncfusion, I'm using RowTemplates but when I run the code the rows are not marked as selected, when I don't user RowTemplate everything is working well, but not with RowTemplate, is there a way to solve this? are the features of the Selection section of the grid supported for row templates?
Thanks in advance
SIGN IN To post a reply.
4 Replies
1 reply marked as answer
DA
Daniel
January 26, 2021 12:47 AM UTC
Just attaching the code that I'm using
@page "/multiple-selection-row-template"
@using Syncfusion.Blazor.Grids
<SfGrid @ref="@Grid" DataSource="@Orders" AllowFiltering="true" AllowPaging="true" Height="315">
<GridSelectionSettings Type="SelectionType.Multiple">GridSelectionSettings>
<GridEvents DataBound="Data" TValue="Order">GridEvents>
<GridTemplates>
<RowTemplate>
@{
var employee = (context as Order);
<td>
@employee.OrderID
td>
<td>
@employee.CustomerID
td>
<td>
@employee.OrderDate
td>
<td>
@employee.Freight
td>
}
RowTemplate>
GridTemplates>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Center" Width="120">GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer ID" TextAlign="TextAlign.Center" Width="150">GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Center" Width="130">GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Center" Width="120">GridColumn>
GridColumns>
SfGrid>
@code{
SfGrid<Order> Grid;
public List<Order> Orders { get; set; }
List<double> SelectIndex { get; set; }
protected override void OnInitialized()
{
Orders = Enumerable.Range(1, 75).Select(x => new Order()
{
OrderID = 1000 + x,
CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
Freight = 2.1 * x,
OrderDate = DateTime.Now.AddDays(-x),
}).ToList();
}
public async Task Data(object args)
{
var Source = await Grid.GetCurrentViewRecords();
var IndexNum = 0;
SelectIndex = new List<double>();
foreach (var record in Source)
{
if (record.CustomerID == "ALFKI")
{
SelectIndex.Add(IndexNum);
}
IndexNum++;
}
await Grid.SelectRows(SelectIndex.ToArray());
}
public class Order
{
public int? OrderID { get; set; }
public string CustomerID { get; set; }
public DateTime? OrderDate { get; set; }
public double? Freight { get; set; }
}
}
RS
Renjith Singh Rajendran
Syncfusion Team
January 26, 2021 06:32 AM UTC
Hi Daniel,
Greetings from Syncfusion support.
We would like to inform you that Selection feature is not supported when using RowTemplate feature in Grid.
RowTemplate feature is not compatible with all the features which are available in grid and it has only limited features support. We suggest you to refer the below documentation for the list of supported features when using RowTemplate in Grid.
Please get back to us if you need further assistance.
Regards,
Renjith Singh Rajendran
Marked as answer
Thanks for the quick reply Renjith
RS
Renjith Singh Rajendran
Syncfusion Team
January 27, 2021 04:59 AM UTC
Hi Daniel,
Thanks for your update.
Please get back to us if you need any further assistance.
Regards,
Renjith R
SIGN IN To post a reply.
- 4 Replies
- 2 Participants
- Marked answer
-
DA Daniel
- Jan 26, 2021 12:04 AM UTC
- Jan 27, 2021 04:59 AM UTC