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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Refresh grid data issue with getCurrentViewData

Thread ID:

Created:

Updated:

Platform:

Replies:

128674 Feb 4,2017 09:10 PM UTC Feb 13,2017 12:51 PM UTC ASP.NET Core 4
loading
Tags: Grid
dsapo
Asked On February 4, 2017 09:10 PM UTC

Hi Support

We have a button outside the grid that when is click do the following:


function Refresh()
{
   $.post('/Home/GetData',
                    {
                        start: $("#startDate").val(),
                        end :  $("#endDate").val(),
                    },
                    function (data, status) {
                        var gridObj = $("#grid").data("ejGrid");
                        gridObj.refreshContent(); 

                    }
                );

}

This invoke a method in the controller that updates an static collection.

Our issue is evident in this complete event handler of the grid:


        function complete()
        {
            var gridObj = $("#grid").ejGrid("instance");
            var data = gridObj.getCurrentViewData();    
         }


The issue is that the getCurrentViewData is returning the current data and not the latest server data.  But after the complete method ends, the grid shows the proper data.  But we need to have the latest data available inside the method to do data extractions to invoke a third party service.

Thanks in advanced


David 








Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On February 6, 2017 12:12 PM UTC

Hi David, 
 
We are unable to reproduce any problem at our end. We have bound remote data to the Grid and refreshed the Grid content in the Ajax success event. Before refreshing the Grid, we have updated the records in the server end. The same changes has been the reflected in the model.currenteViewData of the Grid’s ActionComplete event. Refer to the following code example and screenshot. 
 
<ej-button id="button_button" click="Refresh" type="Button" text="click" /> 
<ej-grid id="grid" allow-paging="true" action-complete="onActionComplete"> 
    <e-datamanager url="/Home/AdrTypDataAll" adaptor="UrlAdaptor" /> 
          . . .  
                  . . . 
</ej-grid> 
 
<script> 
    function Refresh() { 
        //button click sent the POST for modification 
        $.ajax({ 
            type: "POST", 
            url: "/Home/GetData", 
            success: function (data) { 
                var gridObj = $("#grid").ejGrid("instance"); 
                //refreshed the Grid. 
                gridObj.refreshContent(); 
            }, 
        }); 
    } 
    function onActionComplete(args) { 
        var gridObj = $("#grid").ejGrid("instance"); 
        //Complete action shows the current set of Records with modification 
        console.log(gridObj.getCurrentViewData()[0].CustomerID); 
    } 
</script> 
 
        public ActionResult GetData()//POST method for Button Click 
        { 
            IEnumerable DataSource = order; 
            order[0].CustomerID = "VINET";//update the record manually 
            return Json("success"); 
        } 
 
 
 
We have also prepared a sample that can be downloaded from the following location. 
 
 
If you are still facing any problem, please share the following details to analyze the problem at our end. 
 
1)      Code example of the Grid and code behind 
2)      If possible, modify the attached sample and replicate the issue 
3)      Screenshot with replication procedure/video demo for the issue 
4)      Version of Essential Studio 
 
Regards, 
Seeni Sakthi Kumar S. 


dsapo
Replied On February 6, 2017 04:37 PM UTC

Hi Seeni:

I tested your sample, but I did an small change to reproduce my problem:

 public ActionResult GetData()
        {
            IEnumerable DataSource = order;
            //  order[0].CustomerID = "VINET";

            var id = "YYYYY";
            order = order.Where(o => o.CustomerID == id).ToList();

            return Json("success");
        }


You will see that the grid shows the correct data, but the following line is not retrieving the correct data:

var data = gridObj.getCurrentViewData();    


Based on the customer Id "YYYYY" that I provided, the console.log should display an empty string, but instead is printing out the value of  ALFKI.

Best Regards,

David

dsapo
Replied On February 7, 2017 04:11 PM UTC

Hi Seeni:

I tested your sample, but I did an small change to reproduce my problem:

 public ActionResult GetData()
        {
            IEnumerable DataSource = order;
            //  order[0].CustomerID = "VINET";

            var id = "YYYYY";
            order = order.Where(o => o.CustomerID == id).ToList();

            return Json("success");
        }


You will see that the grid shows the correct data, but the following line is not retrieving the correct data:

var data = gridObj.getCurrentViewData();    


Based on the customer Id "YYYYY" that I provided, the console.log should display an empty string, but instead is printing out the value of  ALFKI.

Best Regards,

David

Hi Seeni:

I think that the issue could be a minor issue in your api, because this property is retrieving the correct data:

var data = args.model.currentViewData;

But when you run this function, you dont get the latest data:

var gridObj = $("#grid").ejGrid("instance");
var data = gridObj.getCurrentViewData();


Remember that this issue is evident when there is no data in the datasource, so using the last function, you will get phantom data from the prior query.

Regards,

David






Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On February 13, 2017 12:51 PM UTC

Hi David,  
 
We have considered this as a bug, “getCurrentViewData is not updated after updating the empty dataSource” and fix for this issue will be included with the Volume 1 Service Pack 1, 2017.  
 
Regards, 
Seeni Sakthi Kumar S. 


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.

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

;