)
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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to refresh the Grid after record changes on client-side?

Platform: jQuery |
Control: ejGrid |
Published Date: February 23, 2015 |
Last Revised Date: February 26, 2020
Tags: editing, ejgrid

Problem

Adding or removing a record from client-side and refreshing the changes in the Grid content.

Solution

The Grid records can be manually added from the client-side by using the model.dataSource.push function and you can also remove a record by using the model.dataSource.splice function. After adding or removing a record from the Grid data source, the Grid can be refreshed using the refreshContent function.

JS

    <button id="Add">Add</button>&nbsp;
    <button id="Remove">Remove</button><br />
    <div id="Grid"></div>
    <script type="text/javascript">        
        $("#Add").ejButton({
            type: "button",
            click: function (args) {
                var gridObj = $("#Grid").ejGrid("instance");
                var data = { OrderID: 10247, CustomerID: "ASDFG", EmployeeID: 4 };
                gridObj.model.dataSource.push(data);
                gridObj.refreshContent();
            }
        });
        $("#Remove").ejButton({
            type: "button",
            click: function (args) {
                var gridObj = $("#Grid").ejGrid("instance");
                var selectedRow = gridObj.selectedRowsIndexes[0];
                if (selectedRow != undefined)
                    gridObj.model.dataSource.splice(selectedRow, 1);
                else
                    alert("No records selected for delete operation");
                gridObj.refreshContent();
            }
        });                                 
    </script>

Screenshot

Adding Record

Figure 1: After adding a record

 

Remove Record

Figure 2: After removing a record

ADD COMMENT
You must log in to leave a comment
Comments
Victor Flamenco
Dec 02, 2015
Worked perfectly for me. Thanks. Reply
Marcelo Blank
Aug 27, 2017

sdvdvd

Reply
Mani Sankar Durai [Syncfusion]
Aug 28, 2017

     Hi Marcelo,

 

      We cannot understand your comment. Please raise a query if you need any further assistance related to this Knowledge Base document.

 

Regards,

Manisankar Durai.

Habeebin Ali
Apr 25, 2018

dddd

Reply

Please sign in to access our KB

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

Up arrow icon

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

Live Chat Icon For mobile
Live Chat Icon