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

Grid doesn't refresh after insert and update (using RemoteAdapter)

I successfully insert and update entities using the RemoteAdapter functions insert and update, but my grid is not refreshing after that, i have to press f5 to refresh the grid.
My functions are in HomeController and the Grid is in the index view.

  public ActionResult Update([FromBody]CRUDModel<Customer> value)
        {
            var customer = value.value;
            dbContext.Customers.Update(customer);
            dbContext.SaveChanges();

            var customers = dbContext.Customers.ToList();

            return Json(value);

        }
        public ActionResult Insert([FromBody]CRUDModel<Customer> value)
        {
            var cust = value.value;
            dbContext.Customers.Add(cust);
            dbContext.SaveChanges();

            var customerLast = dbContext.Customers.Last();

            return Json(value);
        }



I also tried passing the updated entity after dbsave to the Json function and also the entire list but its not working.
I would be very happy if somebody can tell me why is not refreshing. I attached the whole project.
Thank you in advance!

Attachment: WebApplication2_1c915714.rar

3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team March 1, 2019 09:28 AM UTC

Hi Elena, 

Greetings from the Syncfusion.  

We have analyzed your query provided sample and we have suspect that update/insert code format is not properly in the server end. In below code example, we have explained the required code format in update and insert methods in server end. You can achieve your requirement by using below way code example. Please refer below code example and sample for more information. 

[HomeController.cs] 
    public ActionResult Update([FromBody]CRUDModel<OrdersDetails> value) 
        { 
            var ord = value.value; 
            OrdersDetails val = OrdersDetails.GetAllRecords().Where(or => or.OrderID == ord.OrderID).FirstOrDefault(); 
            val.OrderID = ord.OrderID; 
            val.EmployeeID = ord.EmployeeID; 
            val.CustomerID = ord.CustomerID; 
            val.Freight = ord.Freight; 
            val.OrderDate = ord.OrderDate; 
            val.ShipCity = ord.ShipCity; 
 
            return Json(value.value);  // return a edited data alone 
        } 
        //insert the record 
        public ActionResult Insert([FromBody]CRUDModel<OrdersDetails> value) 
        { 
 
            OrdersDetails.GetAllRecords().Insert(0, value.value); 
            return Json(value.value); 
        } 


The below screenshot to know details about the update method returned value and browser is shown updated data in result. 

Screenshot: 
 

 

Please get back to us, if you need further assistance. 

Regards, 
Thavasianand S. 



EP Elena Popova March 5, 2019 10:04 AM UTC

Hi Thavasianand Sankaranarayanan,

It turned out that the properties of my entity and the properties in the grid itself need to be in lower cases, otherwise it doesn't work. I suppose it is some kind of issue with the components working with core 2.2.

Regards,
Elena


TS Thavasianand Sankaranarayanan Syncfusion Team March 6, 2019 10:51 AM UTC

Hi Elena, 

Thanks for your update. 

We have already discuss about the above mention query in the following documentation. 


Regards, 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon