Adding a new record on the bottom of a grid and retrieving the grid data

Hi, we have a requirement to add records at the bottom of a grid, and i found this thread although cant make it to work. The grid has a datamanager UrlAdaptor that retrieves a json and assigns it to the grid. We also need to access the newly added row or rows and send it by an ajax call, although accessing grid.datasource does not seem to get the list of data. Thanks for the help!

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team September 10, 2018 08:40 AM UTC

Hi Merrylin, 

Thanks for contacting Syncfusion support. 

Based on your requirement you need to add a new record at the bottom of the grid. In thread(https://www.syncfusion.com/forums/131930/how-to-position-new-rows-at-the-bottom-of-the-grid) the grid has local data, so we have added a record as a last record of Grid’s dataSource and we can view it while go to the last page.  
 
In this you have mentioned that you are using URL Adaptor(Remote Data) in Grid. While using URL Adaptor if you need to display the new record at last page, then we need to handle it in server-side.  
 
Find the code example:  
 

<div id="Grid"></div> 
<script type="text/javascript"> 
    
    $(function () {  
        $("#Grid").ejGrid({  
            dataSource: ej.DataManager({  
                url: "/Grid/UrlDataSource", 
                insertUrl: "/Grid/Insert",  
                updateUrl: "/Grid/Update",  
                removeUrl: "/Grid/Delete",  
                adaptor: "UrlAdaptor"  
            }),  
            allowPaging: true,             
            editSettings: {  
                ----------------------------------- 
             
            },  
            ----------------------- 
            columns: [  
                     -------------------------- 
            ]  
        });  
    });  
 
</script> 
 
--------------------------------------------------------------- 

public ActionResult Insert(EditableOrder value) 
        { 
            var totalRecrods = OrderRepository.GetAllRecords().Count; 
            OrderRepository.GetAllRecords().Insert(totalRecrods, value); 
            var data = OrderRepository.GetAllRecords(); 
            return Json(data, JsonRequestBehavior.AllowGet); 
        } 

For your convenience we have attached the sample and please download the sample from the following link 

  
If we misunderstood your query, please confirm that you want to add new record at the bottom of the current page. 

Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon