Hi Ariel,
When creating components by repeated iteration inside foreach loop, we suggest you to fetch the ref variable in a List. Later, use that particular ref value of that particular Grid component to call the corresponding component’s methods. We have found a general link regarding this, please find the link below,
Please refer and use as like the code below,
|
<GridColumn HeaderText="Owner" Width="150" AllowEditing="false">
<Template>
@{
var a = context as OrdersDetails;
}
@*Based on the variables render the template column value*@
@if (DropdownValue != "" && a.OrderID.ToString() == ClaimPrimaryValue)
{
@DropdownValue;
}
else
{
//We have added a new field as GridNumber to place a numbering for the rendered Grid's
<button @onclick="() => OnClick(a.OrderID, day.GridNumber)">Claim</button>
}
</Template>
</GridColumn>
</GridColumns>
List<SfGrid<OrdersDetails>> ComponentRefs = new List<SfGrid<OrdersDetails>>();SfGrid<OrdersDetails> ComponentRef{ set { ComponentRefs.Add(value); }}
public async Task OnClick(int? PrimaryValue, int GridRef) //GridRef is the newly added GridNumber field value { var index = await ComponentRefs[GridRef].GetRowIndexByPrimaryKey(PrimaryValue); //Get the row index await ComponentRefs[GridRef].SelectRow(index); //Select a row await ComponentRefs[GridRef].StartEdit(); //Open edit dialog}
protected override void OnInitialized(){ GridData = Enumerable.Range(1, 5).Select(x => new Order() { Day = DateTime.Now.AddDays(-x), GridNumber = x-1, Digests = (x > 5)? Enumerable.Range(1, 5).Select(x => new OrdersDetails() { ... }).ToList() }).ToList();}public class Order{ public DateTime Day { get; set; } public int GridNumber { get; set; } public List<OrdersDetails> Digests { get; set; }}
|
Try the above suggestion from your side and please get back to us if you need further assistance.
We suspect that you have another forum 158285 for same query. The query is addressed in this thread. Could you please let us know if you have any concerns.
Regards,
Rahul