I was trying to implement the double-click event in the datagrid following the documentation:
https://blazor.syncfusion.com/documentation/datagrid/events#onrecorddoubleclick
Not sure how to get the row values for the different columns of the doubleclicked row.
The above example doesn't show an implementation for the method.
I see args has some options, but I couldn't figure out where to get the data.
I also get an error when declaring the doubleclick event, that prevents the grid from rendering. It's a simple declaration (the DoubleClick method is empty, as I'm trying to figure out how to get the row data):
Hi John,
Greetings from Syncfusion support.
Query: “I also get an error when declaring the doubleclick event, that prevents the grid from rendering. It's a simple declaration (the DoubleClick method is empty, as I'm trying to figure out how to get the row data):”
We suggest you achieve your requirement using RowData property from the arguments of OnRecordDoubleClick event of the Grid. Refer to the below code example.
|
@if(DoubleClicked != null){ <div>Order ID: @DoubleClicked.OrderID</div> <br/> <div>Customer ID: @DoubleClicked.CustomerID</div> <br/> <div>Order Date: @DoubleClicked.OrderDate</div> <br/> <div>Freight: @DoubleClicked.Freight</div> <br/> }
<SfGrid DataSource="@Orders"> <GridEvents OnRecordDoubleClick="RecordDoubleClickHandler" TValue="Order"></GridEvents> <GridColumns> . . . .. . . . </GridColumns> </SfGrid>
@code{ public List<Order> Orders { get; set; } public Order DoubleClicked{get; set;} . . .. . . . . . .
public void RecordDoubleClickHandler(RecordDoubleClickEventArgs<Order> args) { // Here, you can customize your code. DoubleClicked = args.RowData; }
|
We have attached the sample for your reference
Please get back to us if you have further queries.
Regards,
Vignesh Natarajan
Thanks it worked as expected, I had a syntax error on TValue, that's why I was getting the error and the RowData was not activating.
Another question, is there a way to know the column where the double-click came from ? that way we could implement different actions depending on the column clicked. I tried using args.Column.Description but looks like it comes empty.
Hi John,
Based on your requirement, we suggest using the RecordDoubleClickEventArgs
argument's Column property to retrieve column information. Kindly refer to the
below code snippet and screenshot for your reference.
|
public void RecordDoubleClickHandler(RecordDoubleClickEventArgs<Order> args) { // Here, you can customize your code. DoubleClicked = args.RowData;
var columnname = args.Column.Field; //to get the column name }
|
Regards,
Prathap S
Everything worked as expected. Excellent support, thank you.
Thanks for the update,
We are happy to hear that the provided solution was helpful. We are closing the thread now.