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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add new record to the end of grid

Thread ID:

Created:

Updated:

Platform:

Replies:

142625 Feb 12,2019 03:16 PM UTC Feb 14,2019 03:53 AM UTC ASP.NET MVC 3
loading
Tags: Grid
Tomislav Tustonic
Asked On February 12, 2019 03:16 PM UTC

Hello

I have a grid and the new added records should be the last item in the grid. I my case a grid is short (less than 10 records) and not sorted.
When I add a new records, they always become a first row.
How can I add a new record to the end of the grid?

Thanks, Tom

Vignesh Natarajan [Syncfusion]
Replied On February 13, 2019 05:25 AM UTC

Hi Tomislav, 
 
Thanks for using Syncfusion products. 
 
Query: “How can I add a new record to the end of the grid?” 
 
From your query, we understand that you need to insert the record at last position of ejGrid. We have achieved your requirement using ActionComplete event and RowPosition property of ejGrid. By default, clicking on add icon will insert empty record (edit form) in top position. You can change the position new row by using Property RowPosition of EditSettings. 
  
Refer the below code example 
 
@(Html.EJ().Grid<object>("FlatGrid") 
        .Datasource((IEnumerable<object>)ViewBag.dataSource2) 
        .AllowPaging() 
        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().RowPosition(RowPosition.Bottom); }) 
        .ToolbarSettings(toolbar => 
        { 
            toolbar.ShowToolbar().ToolbarItems(items => 
            { 
                items.AddTool(ToolBarItems.Add); 
                items.AddTool(ToolBarItems.Edit); 
                items.AddTool(ToolBarItems.Delete); 
                items.AddTool(ToolBarItems.Update); 
                items.AddTool(ToolBarItems.Cancel); 
            }); 
        }) 
…………………………………………………………………………………………………………………………………… 
        }).ClientSideEvents(e => e.ActionComplete("onActionComplete")) 
) 
 
<script type="text/javascript"> 
 
    function onActionComplete(args) { 
        if (args.requestType == "save") { 
            this.model.dataSource.shift();// Remove the newly added record from first position 
            this.model.dataSource.push(args.data)// Push the newly added record in data source 
            this.refreshContent(); 
        } 
    } 
 
</script> 
 
For your convenience we have prepared a sample which can be downloaded from below link 
 
 
Note: Provided solution will work only for local data. if you are using remote please get back to us with details regarding your dataSource. 
 
Refer our API documentation for your reference 
 
 
 
 
Regards, 
Vignesh Natarajan 


Tomislav Tustonic
Replied On February 13, 2019 06:44 PM UTC

This is fine, thank you.

Tom

Vignesh Natarajan [Syncfusion]
Replied On February 14, 2019 03:53 AM UTC

Hi Tomislav, 
 
Thanks for the update. 
 
We are glad to hear that your query has been resolved by our solution.  
 
Please get back to  us if you have further queries. 
 
Regards, 
Vignesh Natarajan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;