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

Add record to the grid from another record

I have two grids one is empty and the another one with data the second one is in dialoge,

I want when I add a record in the empty grid and press "+" in the field the dialoge opening and when I select a row from the grid which is in the dialge and press Enter button the selected row added in the empty grid

I will send a sample file.


Note: after adding a record successfully I want it become in edit state dynamically.


4 Replies 1 reply marked as answer

HA Haneen Alfakhry January 15, 2023 08:55 PM UTC

this is a sample file 


Attachment: Blazoserver2311_b9f75124.rar



MS Monisha Saravanan Syncfusion Team January 17, 2023 01:26 PM UTC


Hi Haneen,


Greetings from Syncfusion support.


We suspect that you need to insert the selected record in the empty Grid and expecting it to be in Edited state after clicking the Enter button. We have modified the shared sample to achieve your requirement using SelectRowAsync and StartEditAsync methods. Kindly refer the below attached sample and code snippet for your reference.


<SfGrid DataSource="@Orders" @ref="Grid" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" Height="315">

    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>

    <GridSortSettings>

        <GridSortColumns>

            <GridSortColumn Field="OrderID" Direction="SortDirection.Ascending">

            </GridSortColumn>

        </GridSortColumns>

    </GridSortSettings>

    <GridKeySettings MoveDownCell="ArrowDown" MoveUpCell="ArrowUp" MoveLeftCell="ArrowRight" MoveRightCell="ArrowLeft"></GridKeySettings>

    <GridEvents OnActionComplete="ActionComplete" OnActionBegin="ActionBegin" TValue="Order"></GridEvents>

   

</SfGrid>

 

@code{

 

 

    public void ActionBegin(ActionEventArgs<Order> args)

    {

        if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Save))

        {

            if (args.Action == "Add" || addRecordAfterEdit)

            {

                Orders.Remove(OrdersSelected);

               

                addRecordAfterEdit = false;

            }

        }

    }

   

async Task OkClick()

    {

        if (OrdersSelected is not null)

            Orders.Add(OrdersSelected);

        Grid.Refresh();

        VisibleDialog = false;

      

        double index1 = (Grid.DataSource.Count()) - 1;

        await Task.Delay(1000);

        await Grid.SelectRowAsync(index1);

        await Task.Delay(1000);

        await Grid.StartEditAsync();

    }

}



Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Blazoserver2311-1484076056.zip


Please get back to us if you have any difficulties or if you have further queries.


Regards,

Monisha



Marked as answer

HA Haneen Alfakhry January 24, 2023 08:24 AM UTC

Thanks a lot for your solving it works very well,

with my full respect for syncfusion




MS Monisha Saravanan Syncfusion Team January 25, 2023 04:01 AM UTC

Hi Haneen,


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


Loader.
Up arrow icon