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
close icon

How to update grid data when using Urladaptor

Hi! I add record to database using Ajax. How do I refresh the grid (used Urladaptor) after that?

In EJ1 I used grid.refreshContent:
..........
                        $.ajax({
                            url: "Admin/Role_Add",
                            type: "POST",
                            beforeSend: function (xhr) {
                                xhr.setRequestHeader("XSRF-TOKEN", $('input:hidden[name="__RequestVerificationToken"]').val());
                            },
                            data: { roleName: inputText }
                        }).done(function (data) {
                            gridRoles.refreshContent();
                        });

In EJ2, refreshContent seems not working

Thanks.

3 Replies

MF Mohammed Farook J Syncfusion Team November 26, 2018 12:15 PM UTC

Hi Costa, 
 
Thanks for contacting Syncfusion support. 
 
By default the Grid ‘addRecord’ method is automatically refresh the automatically.  Please find code example and the documentation for your reference. 
 
 
var gridObj = document.getElementById('Grid')['ej2_instances'][0]; 
gridObj.editModule.addRecord({ OrderID: 10247, CustomerID: 'VINET' }); 
 
 
 
 
Note : You must enable ‘allowAdding’ as true in Grid editSettings when using addRecord method. Please find the code example. 
 
 
 
<ejs-grid id="Grid"    toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" allowPaging="true"> 
            <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings> 
 
. . . 
 
 
 
This is not meet your requirement could you please explain more details about your requirement. 
 
Regards, 
J Mohammed Farook 



CO Costa November 27, 2018 11:06 AM UTC

All right, thanks for correcting me)
However, if someone needs to refresh the data anyway, the method 'grid.refresh()' works to refresh the data in the grid.


MF Mohammed Farook J Syncfusion Team November 27, 2018 12:50 PM UTC

Hi Costa,  
 
Thanks for your update. 
 
We are happy to hear that the provided solution has been resolved your problem.  The “refresh()” method of Grid will refresh the Grid header and content. 
 
Please get back to us if you need further assistance. 
 
Regards, 
J Mohammed Farook 


Loader.
Live Chat Icon For mobile
Up arrow icon