We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridCommandColumn button click event

Hi,

In my SfGrid I have a GridCommandColumn with a button:


I have a OnCommandClicked method:


I placed a breakpoint on the highlighted code, but it is never hit.

I even tried without the if statement, and that didn't help.

I want the button to bring the user to a page so see the details of the selected row.

Any help is appreciated.


3 Replies 1 reply marked as answer

MS Monisha Saravanan Syncfusion Team December 30, 2022 10:32 AM UTC

Hi Praveen,


Greetings from Syncfusion support.


We could not able to replicate the reported issue at our end. We suggest you to ensure whether you have included the below highlighted changes at your end. Also we have included a sample for your reference. Kindly check the attached sample and code snippet.



@inject NavigationManager urihelper

 

<SfGrid DataSource="@Orders" AllowPaging="true" Height="315">

    <GridEvents CommandClicked="OnCommandClicked" TValue="Order"></GridEvents>

    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>

    <GridColumns>

       

        <GridColumn HeaderText="Manage Records" Width="150">

            <GridCommandColumns>

                <GridCommandColumn ButtonOption="@(new CommandButtonOptions() { Content = "Details", CssClass = "e-flat" })"></GridCommandColumn>

            </GridCommandColumns>

        </GridColumn>

    </GridColumns>

</SfGrid>

 

@code{

  

 

    public void OnCommandClicked(CommandClickEventArgs<Order> args)

    {

        if(args.CommandColumn.ButtonOption.Content == "Details")

        {

            urihelper.NavigateTo(https://www.bing.com/);

        }

    }

}


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorApp1-2004070343.zip


If you still face difficulties then kindly share the below details to proceed further.


  1. Share us the entire Grid code snippets.
  2. Share us the video demonstration of the issue
  3. If possible share us the simple issue reproducing sample or try to reproduce the reported issue on the above mentioned sample.


Above requested details will be very helpful in validating the reported query at our end and provide solution as early as possible.


Regards,

Monisha



Marked as answer

PR Preveen December 30, 2022 07:33 PM UTC

Of course, I forgot to modify the GridEvents 🤦‍♂️

Thanks so much for the help.

Wishing you a very happy new year in advance. Cheers!!!



SG Suganya Gopinath Syncfusion Team January 2, 2023 08:40 AM UTC

Preveen,

We are glad that the provided solution helped to solve the issue. 

Wishing you a very happy New year from Syncfusion Team.

Regards,

Suganya Gopinath.


Loader.
Up arrow icon