I want to set the default value of the row when performing inline edit add in Grid.

Hi!

If you click the Add button of the Toolbar in the Grid, a row is added and you can enter a value.

What I want is to dynamically insert default values for each row position. The reason is that action values such as sort order can make sense.
I know that among the GridColumn properties of the Grid, static inserts that are not dynamic can be given as DefaultValue.
What I want is a way to set default values for edit columns by putting values in specific properties of DataRow or Data in events like AddBegin.

To my intuition, I thought args.Data would do that, but no matter how much I set the value, it doesn't reflect.
Where is the correct location?

Thanks!


3 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team August 7, 2020 11:37 AM UTC

Hi Seil, 

Greetings from Syncfusion support. 

Based on this requirement, we suggest you to set the args.Data values for the corresponding fields in the OnActionBegin event of Grid by checking for the RequestType as Add. We have prepared a sample based on this scenario, please download the sample from the link below, 
 
Please refer and use as like the code below, 

 
<GridEvents OnActionBegin="OnActionBegin" TValue="Order"></GridEvents>
public void OnActionBegin(ActionEventArgs<Order> args){    if (args.RequestType.ToString() == "Add")    {        args.Data.OrderID = 15;    //here you can dynamically assign value for OrderID column    }}


Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 



SE Seil August 7, 2020 12:45 PM UTC

Thanks for the response.

Oh, what I was trying to say is TreeGrid, not Grid. There was a mistake.

As you said, Grid works fine by writing values to args.Data through 'Add' RequestType of OnActionBegin.

TreeGrid doesn't.

It seems to be a bug in TreeGrid or something else to achieve.



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team August 10, 2020 12:27 PM UTC

Hi Seil, 

Query#:- A common approach is to set a value in args.Data when the RequestType of OnActionBegin is Add when the add toolbar button is pressed. This works fine for Grid, but no changes to TreeGrid. 

We are able to replicate the problem at our end. We have confirmed this issue “Need to set default value on performing Add operation using args.Data from OnActionBegin event” as bug. Thank you for the taking the time to report the issue and helping us improve our product. At Syncfusion we are committed to fixing all the validated defect (subject to technological feasibility and Product Development Life Cycle) and including its fix in our subsequent release. The fix for the issue will be included first NuGet release after Volume 2 Service pack release. 

You can track the current status of your request, review the resolution timeline and contact us for any further inquiries through this link.      
 
Note: To view the above feedback, kindly login into your account.      

Please get back to us if you need any further assistance.  

Regards, 
Farveen sulthana T 



Marked as answer
Loader.
Up arrow icon