Several issues with custom event handlers and update in the Grid

Hi
I am seeing the following issues:

  1. I have handles the RowSelected event on a custom method and because of that the row I select does not stay selected at least visually. The event triggers but the row is not selected anymore in the Grid.
  2. The toolbar buttons also trigger the RowSelected event. I do not know if this is by design or not.
  3. When I handle the ToolbarClicked Event in a custom method the Add button no longer adds a new row to the grid. More specifically it seems it does but updates and removes the new row again.


    Here is the code:

    Index.Razor
  4. @page "/"

    @inject ProductSetViewModel ProductVM

    <PageTitle>Product Sets</PageTitle>

    <h2>Product Sets</h2>

    <SfGrid DataSource="ProductVM.GetAllProductSet()" Toolbar=Toolbaritems >

        <GridEvents RowSelected="ProductVM.RowSelectHandler" TValue="ProductSet"></GridEvents><GridEditSettings AllowAdding="true" ></GridEditSettings>

        <GridColumns>

            <GridColumn Field="@nameof(ProductSet.ProjectId)" HeaderText="Project Id" Width="50" />

            <GridColumn Field="@nameof(ProductSet.ProductSetId)" HeaderText="ProjectSet Id" Width="100" />

            <GridColumn Field="@nameof(ProductSet.DisplayName)" HeaderText="DisplayName" Width="100" />

            <GridColumn Field="@nameof(ProductSet.DataLocation)" HeaderText="Data Location" Width="100" />

            <GridColumn Field="@nameof(ProductSet.IndexTime)" HeaderText="Last Indexed Time" Width="100" />

        </GridColumns>

    </SfGrid>


@code{

    private List<Object> Toolbaritems = new List<Object>() { "Add", "Delete", "Update", "Cancel" };

    public void ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)

    {

        if (args.Item.Id == "Click")

        {

            //You can customize your code here.

        }

    }

}


ProductSetViewModel

        public void RowSelectHandler(RowSelectEventArgs<ProductSet> args)

        {

        if (args.Event != null)

       {

                List<Product> products = vision.GetAllProductsByProductSet(args.Data.Id);

                productsInSet = products;

            }

        }


6 Replies

NP Naveen Palanivel Syncfusion Team September 12, 2022 11:52 PM UTC

Hi Sune,


Sorry for the inconvenience. 


we are really sorry for the delay  We are currently Validating the reported query with high importance  at our end and we will update the further details within two days. Until then we appreciate your patience.


Regards,

Naveen Palanivel



NP Naveen Palanivel Syncfusion Team September 15, 2022 04:25 AM UTC

Hi Sune,


Thanks for the patience,


We checked your query and we would like to inform that unfortunately  reported issue is does not reproduced at our end. We prepared the video from our side attached in this ticket. We also see in your code snippet IsPrimary key is not enable in CRUD operation. While preforming the CURD operation, to enabled IsPrimarykey column to an unique column and that column will not able to edit. Please refer the video attachment and  UG documentation for more information.


Reference : https://blazor.syncfusion.com/documentation/datagrid/editing


Please get back to us if you need further assistance



Regards,

Naveen Palanivel


Attachment: Grid_c2dd12bc.zip


SS Sune Sorgenfrei September 15, 2022 04:14 PM UTC

Hi
It still does not work for me. I have added the IsPrimarykey = true to the Grid and added the the RowSelected event. Please see attached video. 




public void RowSelectHandler(RowSelectEventArgs args)

{

ProductSet ps = args.Data;

}


Attachment: 20220915_174506_b41285bf.zip


MS Monisha Saravanan Syncfusion Team September 16, 2022 04:45 PM UTC

Hi Sune,


We have checked your shared video and prepared an sample as per your shared video. But we could not able to replicate the reported issue at our end. Kindly check the attached sample for additional information.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/EVENTH~31378243100.zip


If  the reported issue still persist then kindly share the below details to validate further at our end.


  1. Share us the entire Grid code snippet along with customized code in the Toolbar and RowSelected event.
  2. If possible share us an simple issue reproduceable sample or try to reproduce the reported issue on the above mentioned sample


The above-requested details will be very helpful for us to validate the reported query at our end and provide the solution as early as possible.


Regards,

Monisha



SS Sune Sorgenfrei September 20, 2022 07:21 AM UTC

Hi
Thanks for your help. I got it to work now but seems there needs to be local references in the @code section of the Blazor page for the Grid to work seemlessly. I can live with that.

Best Regards,

Sune



MS Monisha Saravanan Syncfusion Team September 21, 2022 03:57 PM UTC

Hi Sune,


Welcome.


We are glad to hear that the reported query has been resolved. Kindly get back to us if you have further queries. As always we will be happy to help you.


Regards,

Monisha


Loader.
Up arrow icon