Unplanned
Last Updated: 25 Apr 2023 06:05 by ADMIN
Martin Leclerc
Created on: 24 Apr 2023 17:59
Category: Grid
Type: Feature Request
4
Grid SetStateAsync method should not fire OnRead when not necessary

Hello,

I'm having issues trying to figure out how to change values (from the model) when I'm Incell Mode without triggers the OnRead events after.  The actual code is working great since I was able to remove the Incell mode on the OnChangeModel event below,  but OnRead is keeps call after (which I didn't need and slow user experience)

Is there a way to cancel the OnRead ?

 <TelerikGrid OnRead="ReadItems" EditMode="GridEditMode.Incell"
                     @ref="@GridRef">
    <GridColumns>
      <GridEditDropDownColumn Field="Test1" Data="@Eval?.ListEvaluationTypes" Title="Title" Width="130px" OnChange="OnChangeModel" />
    </GridColumns>
</TelerikGrid>

 

   private TelerikGrid<EvaluationListDTO> GridRef { get; set; }

   protected async Task OnChangeModel(object model)
        {
            var item = (EvaluationListDTO)model;

            var state = GridRef?.GetState();

           //Save in the Database  

                // use the state to remove the edited item (close the editor)
                state.EditItem = null;
                state.OriginalEditItem = null;
                await GridRef.SetStateAsync(state);
        }

1 comment
ADMIN
Dimo
Posted on: 25 Apr 2023 06:05

Hello Martin,

Currently, OnRead fires automatically when the Grid state changes. It is possible to optimize this and I am converting your ticket to a public feature request.

In the meantime, it is possible to do this:

  1. Cache the data collection in the OnRead handler to some variable that you can access later.
  2. Before calling GridRef.SetStateAsync(), raise a boolean flag in the Razor component.
  3. Check the flag in the OnRead handler and if it's true, set the previously cached collection to args.Data. This will spare an actual remote request.

Regards,
Dimo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.