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

Refreshing DataGrid model records

Hi,
I've installed Sync Fusion controls today to use it in Xamarin PCL Project. 
I did everything like in THIS TUTORIAL. I've got variable with model (viewModel) and Data Grid (dataGrid) and my testing records from GenerateOrders() method is showing up indeed (Android test app). However if I try to modify records like for example in THIS TUTORIAL so I change OrderInfoCollection but it seems to not refresh in grid UI. Collection length changed fine. I didn't find any refresh method. How should I do it?

Regards, Maciek.

5 Replies

VP Vimal Prabhu Manohkaran Syncfusion Team March 16, 2017 05:55 AM UTC

Hi Maciek,

Thanks for contacting Syncfusion support. We understand your requirement is to perform the pull to refresh function and refresh the data in SfDataGrid. We have modified the GettingStarted sample that you have downloaded from the GettingStarted UG page and have added the pull to refresh functionality to it. Please find the sample from the below link.

 
Sample Link : http://www.syncfusion.com/downloads/support/forum/129384/ze/GettingStarted-1216346838

Regards,
Vimal Prabhu



MO Maciej Orlowski March 16, 2017 08:41 AM UTC

I didn't mean exactly Pull To Refresh function but any change of Grid Collection in model.
So in your example method ItemsSourceRefresh is changing collection OrderInfoCollection by executing Insert() function on it. As a result of this OrderInfoCollection is changing (expanding by one record) and also grid have one more row (in UI) and we physically can see the difference in our collection. But i doesn't work like that in my project. I can modify collection and it's changing indeed. I can debug it and see that OrderInfoCollection have more records, but it doesn't change view of grid. I cannot see this in my app.


By the way your project doesn't work on my PC - App.cs:20 - LoadApplication(new App()); (I cleaned solution but didn't help)


//EDIT
I got SOME result. I tried create OrderInfoCollection = new ObservableCollection() each time instead of changing it. So now it's better but not exactly.
On start I've got 14 rows from GenerateOrders method and execute code behind on test button click:
this.OrderInfoCollection.Clear(); //It clear grid indeed
this.OrderInfoCollection.Insert(0, new OrderInfo(0, "1", "2", "3", "4")); //add 1234 row to OrderInfoCollection but shows Maria Anders rows (first row from GenerateOrders)

So what the hell should I do to make OrderInfoCollection and SfDataGrid show exact the same things?
It's little crappy if you spent 2 days on it...


PS Pavithra  Sivakumar Syncfusion Team March 17, 2017 02:27 PM UTC

Hi Maciek, 
Thanks for the update. We have checked your query. We have prepared a sample based on your requirements, where we have loaded the grid initially with some data(OrderInfoCollection). In the button click we have  
1.     Cleared the collection and inserted a new item, 
2.     Inserted a new item directly 
 
In both the cases, we were not able to replicate the issue and the data is updated both in OrderInfoCollection (record collection) and in SfDataGrid (UI). We have attached the sample which we tested for your reference and you can download the same from the below link.  
 However, if you have enabled sorting, and if your issue is that the inserted record is not ordered based on sorting, then you should set the SfDataGrid.View.LiveDataUpdateMode property to AllowDataShaping, so that the record would get updated in the UI.  
Refer the below code example to update sorting for newly added record. 
dataGrid.GridViewCreated += DataGrid_GridViewCreated;
private void DataGrid_GridViewCreated(object sender, GridViewCreatedEventArgs e)
{
     dataGrid.View.LiveDataUpdateMode = LiveDataUpdateMode.AllowDataShaping
}
 
 
In case if the issue still persists at your end, please revert us the with a sample replicating the issue to proceed further. 
Regards, 
Pavithra S 



MO Maciej Orlowski March 23, 2017 02:21 PM UTC

Well...
I've got sample for you.
Try these steps on it:
1. Click button "Add new empty row" - it will add row with only one column filled. You can click it more than once.
2. Click button "Clear rows" - it will make ItemSource empty and indeed - grid too.
3. Click button "Add new empty row" now again - you will see that now "Empty row" was added but just first row of old array shows up. 

So what the hell is going on here?
Please explain me this o.O

Thanks guys.

Attachment: sample_57c13a8a.rar


PS Pavithra  Sivakumar Syncfusion Team March 24, 2017 09:23 AM UTC

Hi Maciek, 
 
We have checked your sample and noticed that the reported issue happens when adding a new item to the observable collection. However, on checking in detail we noticed that this is not our side issue and happens due to Framework problem. We will try to reproduce this in a simple scenario to report it in the Bugzilla to get a permanent solution. 
 
Meanwhile, the reported problem can be overcome by setting a default value for all the underlying properties of the bound collection in the constructor. 
 
Refer the below code example for more details. 
 
public notifs() 
{ 
      KLIENT= String.Empty; 
      NR = String.Empty; 
      TYP = String.Empty; 
      OPIS= String.Empty; 
} 
 
 
Regards, 
Pavithra S 
 


Loader.
Live Chat Icon For mobile
Up arrow icon