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

Refresh grid not working

Hi,

This is my grid:

 @(Html.EJ().Grid<ClienteVM>("ClientiGrid").Datasource(ds => ds.Json(Model).CrudURL(Url.Action("CrudClienti", "Admin")).Adaptor(AdaptorType.RemoteSaveAdaptor))

After an import of data in the grid I use this code:
function create(args) {
                var nomeRuolo="Cliente";
                $("#UplImportAnagrafica").ejUploadbox({
                    height: "0px",
                    width:"0px",
                    autoUpload: false,
                    showFileDetails: true,
                    extensionsAllow: ".uwr",
                    locale: "it-IT",
                    cssClass: "impAnagrafica",
                    multipleFilesSelection: false,
                    dialogAction: { closeOnComplete: true },
                    dialogPosition: { X: 1, Y:1 },
                    begin: function (args) {
                        args.data = nomeRuolo;
                    },
                    success: function (args) {
                        var gridObj = $("#ClientiGrid").data("ejGrid");
                        gridObj.refreshData();
                        var response = JSON.parse(args.responseText);
                        if (response.success) {
                            var actionUrl = '@Url.Action("CheckAlertImport", "Admin")';
                            $.ajax({
                                url: actionUrl,
                                contentType: 'application/json; charset=utf-8',
                                dataType: 'json',
                                type: 'POST',
                                data: JSON.stringify({ nomeRuolo: nomeRuolo }),
                                success: function (d) {
                                    if (d.success) {
                                        if (d.value > 0) {
                                            $("#ErrorList").ejDialog("setContent", "@PLV.Web.Resources.Menu.AlertNoPassword");
                                            $("#ErrorList").ejDialog("open");
                                        }
                                    }
                                },
                            });
                        }
                        else {
                            $("#ErrorList").ejDialog("setContent", response.alerts);
                            $("#ErrorList").ejDialog("open");
                        }
                    },
                    error: function (args) {
                         if (args.action == "Files Processing") {
                             $("#ErrorList").ejDialog("setContent", "@PLV.Web.Resources.Common.ErroreTipoFile" + args.model.extensionsAllow);
                             $("#ErrorList").ejDialog("open");
                         }
                         else {
                             str = args.error;
                             $('#ErrorList').html("");
                             $('#ErrorList').html("<p>" + str + "</p>");
                             $('#ErrorList').ejDialog("open");
                         }
                    }
                });
         }

but the grid does not update.

3 Replies

PK Padmavathy Kamalanathan Syncfusion Team August 8, 2019 01:24 PM UTC

Hi Pio, 

Thanks for contacting Syncfusion Forums. 

QUERY: Refresh grid no working 
 
From the shared code, we understand that you need to refresh grid’s dataSource, we suggest you to use “dataSource” method. 

Please refer the below help documentations,  


If you need to refresh entire grid and its properties, we suggest you to use “refreshContent” method.  
 
Please refer the below help documentations, 

If we have misinterpreted your query, please share us the below details, 
  1. Please explain us your requirement with clarity (like what you are trying to do by refreshing)
  2. Please tell us where you have called create method or to which event you have binded to it.
  3. Screenshots of error (if any)

If you have further queries, please get back to us. 

Regards, 
Padmavathy Kamalanathan 



PL Pio Luca Valvona replied to Padmavathy Kamalanathan August 8, 2019 05:02 PM UTC

Hi Pio, 

Thanks for contacting Syncfusion Forums. 

QUERY: Refresh grid no working 
 
From the shared code, we understand that you need to refresh grid’s dataSource, we suggest you to use “dataSource” method. 

Please refer the below help documentations,  


If you need to refresh entire grid and its properties, we suggest you to use “refreshContent” method.  
 
Please refer the below help documentations, 

If we have misinterpreted your query, please share us the below details, 
  1. Please explain us your requirement with clarity (like what you are trying to do by refreshing)
  2. Please tell us where you have called create method or to which event you have binded to it.
  3. Screenshots of error (if any)

If you have further queries, please get back to us. 

Regards, 
Padmavathy Kamalanathan 


I tried to use the "dataSource" method, as suggested it seems to work as expected.
The only problem left is the sorting of the columns, how can I translate this code 

.OrderBy(u => u.Password).ThenBy(u => u.Cognome)

 using the sortColumn method?
Thank you for your support.


PK Padmavathy Kamalanathan Syncfusion Team August 9, 2019 05:53 AM UTC

Hi Pio, 
 
Thanks  for the update, 
 
QUERY: The only problem left is the sorting of the columns 
 
From your query we understand that you need assistance regarding sorting the columns of grid. From your code, we can understand that you are using local data with remotesave adaptor and handle CRUD actions in server side. 
 
For client side sorting, we have inbuilt property called allowSorting. You just need to set allowSorting to true for sorting your columns. When you click on the header of the column which you need to sort, the column will be sorted.  
 
Please refer the below code snippet, 
 
 
<script> 
                $("#Grid").ejGrid({ 
                dataSource: window.gridData, 
                allowPaging: true, 
                allowSorting: true, 
                columns: [ 
                    -------- 
                ] 
            }); 
</script> 
 
 
 
Please refer the below sample, 
 
Please refer the below help documentation, 
 
If you need to perform sorting by other actions, for example, if you need to perform sorting button click , you can use sortColumn method with column name and sort direction as parameters. 
 
Please refer the below code snippet, 
 
 
    <script> 
            // Create grid object. 
            var gridObj = $("#Grid").data("ejGrid"); 
            gridObj.sortColumn("OrderID", "ascending"); // Sends a sorting request to the grid with specified columnName and sortDirection 
    </script> 
 
 
 
If you use remote data and need to perform server side sorting, you can use URL adaptor. In URL adaptor, we have method for sorting called PerformSorting. 
 
Please refer the below help documentation, 
 
If you have further queries, please get back to us. 
 
Regards, 
Padmavathy Kamalanathan 


Loader.
Live Chat Icon For mobile
Up arrow icon