Hello team,
Can you provide an example of change value event in checkbox column. just like in text box or combobox (
<GridSelectionSettings CheckboxOnly="true" PersistSelection="true">
// What should I put here?
</GridSelectionSettings>
Best Regards,
Tyrone
Hi Vignesh,
Thanks so much for the immediate reply..
can you provide me a sample or documentation links for this?
1) We suggest you to achieve your requirement using RowSelected / RowSelecting event of the Grid.
2) Render SfCheckBox component using ColumnTemplate feature of the Grid
Best Regards,
Tyrone
Hi Vingesh,
I just found this code at your site..
Can we edit and Apply value change here.. if Yes, How?
Field=@nameof(Order.Verified) HeaderText="Verified"Type="ColumnType.Boolean"EditType="EditType.BooleanEdit"TextAlign="TextAlign.Center"DisplayAsCheckBox="true"Width="120">
Best Regards,
Tyrone
|
<SfGrid @ref="GridInstance" DataSource="@Orders" AllowSelection="true" AllowPaging="true">
<GridSelectionSettings Type="SelectionType.Multiple"></GridSelectionSettings>
<GridEvents RowSelected="RowSelected" DataBound="DataBoundHandler" TValue="Order"></GridEvents>
<GridColumns>
<GridColumn Type="ColumnType.CheckBox" Width="50"></GridColumn>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.AmtPaid) HeaderText="Amunt Paid" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.Balance) HeaderText="Balance" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code{
public SfGrid<Order> GridInstance { get; set; }
public List<Order> Orders { get; set; }
public bool IsInitial { get; set; }
public async Task DataBoundHandler()
{
var selected = new List<double>();
var paid_list = Orders.Where(x => x.AmtPaid > 0).ToList();
foreach (var list in paid_list)
{
var index = Orders.IndexOf(list);
if (!selected.Contains(index))
{
selected.Add(index);
}
}
IsInitial = true;
await GridInstance.SelectRowsAsync(selected.ToArray());
IsInitial = false;
}
public void RowSelected(RowSelectEventArgs<Order> Args)
{
if (!IsInitial)
{
//this event will be selected when mrecord is selected in Grid
Order ord = Orders.Find(x => x.OrderID == Args.Data.OrderID);
ord.AmtPaid = ord.Balance;
ord.Balance = 0;
GridInstance.Refresh();
}
}
|
Thanks Vignesh, I'll give it a try.