Double-Click Event how to get record data

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.

Image_1013_1710824221417

I see args has some options, but I couldn't figure out where to get the data.

Image_9773_1710824353312

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):

            <GridEvents OnRecordDoubleClick="DoubleClick" TValue="Oportunities"></GridEvents>

Image_1423_1710824588864 Any idea where to look ?



5 Replies

VN Vignesh Natarajan Syncfusion Team March 19, 2024 05:43 AM UTC

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


Sample: https://blazorplayground.syncfusion.com/embed/VtBzZKMELDVpSgwZ?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5


Please get back to us if you have further queries.


Regards,

Vignesh Natarajan



JG JOHN GOMECK March 19, 2024 11:47 PM UTC

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.





PS Prathap Senthil Syncfusion Team March 20, 2024 09:36 AM UTC

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

  }

 

A screenshot of a computer program

Description automatically generated                                                 



Regards,
Prathap S



JG JOHN GOMECK March 20, 2024 04:40 PM UTC

Everything worked as expected. Excellent support, thank you.



PS Prathap Senthil Syncfusion Team March 21, 2024 05:01 AM UTC

Thanks for the update,


We are happy to hear that the provided solution was helpful. We are closing the thread now.


Loader.
Up arrow icon