Grid - Select row after changing list order

Hi, 

I am trying to make a list with Sfgrid where the user can change the order of the elements with arrows inside the grid. 

The first thing I done is prevent the row of selecting when user click on arrow or plus button, after that I have tried to select the row that have moved up or down with RowDataBound Diapositivas funcion but doesnt work correctly. 

Button First and Last works fine.


Attachment: SfGrid_390da22e.rar

1 Reply 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team April 13, 2022 08:48 AM UTC

Hi Cristian,


Greetings from Syncfusion support.


We suggest you to call the SelectRowAsync method inside DataBound event handler to achieve this requirement. Please refer and modify as like the codes below. We have also attached a modified sample in this ticket.


 

<GridEvents DataBound="DataBound" ... TValue="Diapositiva"></GridEvents>

 

    public async Task DataBound()

    {

        if(IsSelectRows)

        {

            IsSelectRows = false;

            await SfDiapositivas.SelectRowAsync(RowIndexVal, true);

        }

    }

    public int RowIndexVal { get; set; }

    public bool IsSelectRows = false;

    public async Task RowDataBoundSfDiapositivas(RowDataBoundEventArgs<Diapositiva> args)

    {

        try

        {

            if (DiapositivaSeleccionada is not null && args is not null && args.Data is not null && DiapositivaSeleccionada.SlideID == args.Data.SlideID)

            {

                if (Diapositivas is not null && SfDiapositivas is not null)

                {

                    RowIndexVal = Diapositivas.IndexOf(args.Data);

 

                    if (RowIndexVal > -1) {

                        PrevenirAccionPorDefecto = false;

                        IsSelectRows = true;

                        //await SfDiapositivas.SelectRowAsync(RowIndexVal, true);

                    }

                }                    

            }

        }

        catch (Exception ex)

        {

            Console.WriteLine($"Excepción en la funcion RowDataBoundSfPermisos en ModalPermisos: {ex.Message}");

        }

    }

 


Please get back to us if you need further assistance.


Regards,

Renjith R


Attachment: SfGrid_d5fbd231.zip

Marked as answer
Loader.
Up arrow icon