Hi
Tyrone,
Yes,
you can automatically assign new values to the primary key column using the DefaultValue
property in the GridColumn. This property ensures that newly added rows
receive a predefined value, making data entry more efficient.
Since
your scenario involves batch editing, you can achieve this by handling the OnBatchAdd
event. This event allows you to dynamically assign and increment values for the
primary key column when new rows are added. Please refer to the following code
snippet for implementation.
Concern
Code Snippet:
|
<GridEvents
OnBatchAdd="BatchAddHandler"
TValue="Order"></GridEvents>
….
int incer = 16;
public void
BatchAddHandler(BeforeBatchAddArgs<Order> args)
{
args.DefaultData.OrderID= incer++;
}
|
Playground
Sample:
https://blazorplayground.syncfusion.com/embed/VXBJMiVaqdDHZvUN?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5
Additional
References:
https://blazor.syncfusion.com/documentation/datagrid/events#onbatchadd
Please
get back to us if you need any other assistance.
Regards,
Sanjay
Kumar Suresh