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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ItemsSource changes, content grid doesn't change all the column values accordingly

Thread ID:

Created:

Updated:

Platform:

Replies:

143216 Mar 10,2019 01:07 AM UTC Mar 14,2019 12:24 PM UTC Xamarin.Android 6
loading
Tags: SfDataGrid
Luis
Asked On March 10, 2019 01:07 AM UTC

Hi all,

 1st thing, thanks for the controls, I'm doing a personal project and its nice to have a complete set of controls :)
 1st time caller, not 1st time developer.
  So, this is the scenario I'm facing.
  I'm got a sfDataGrid control being used to show the channel number\order and the channel name, I'using the drag n drop feature to change the order of the channels.
 
   My data source of the grid is an ObservableCollection<T>, so, when I move the channel up or down, I'm moving the item inside the ObservableCollection (using the move method) and switching the channel number.

   The item changes its position inside the ObservableCollection, but the grid doesn't update its content.

    I already tried to to clear the observable collection and add all the items again by the order I want and the result is the same.

    This is a snippet of the code I'm using, pretty standard (mth for the event: QueryRowDragging).


  if (e.Reason == QueryRowDraggingReason.DragEnded)
            {

                if (e.From == e.To)
                { 
                    e.Cancel = true;
                    return;
                }

               int fromIndex = e.From - 1;
               int toIndex = e.To - 1;

((sender as SfDataGrid).ItemsSource as ObservableCollection<ChannelInformation>).Move(fromIndex, toIndex)

What happens is that the observable collection is changed, but the grid stays the same, even after calling the dfDataGrid method Refresh().

What am I doing wrong?

Thanks,
Luís Pinho

Subburaj Pandian Veluchamy [Syncfusion]
Replied On March 11, 2019 12:24 PM UTC

Hi Luis, 
 
Thank you for contacting Syncfusion support. 
 
Currently, we are checking on the reported query “Grid content not updated when column values updating” in DataGrid Xamarin.Android. We will validate and update you the related details in one business day (March 12, 2019). We appreciate your patience until then. 
 
Regards,
Subburaj Pandian V 


Pradeep Kumar Balakrishnan [Syncfusion]
Replied On March 12, 2019 05:26 PM UTC

Hi Luis, 
 
Thank you for your patience. 
 
We checked the reported issue “DataGrid Items is not moved when we moved the items in underlaying datagrid collection.” In Xamarin Android and it is working fine from our side. we also attached the tested sample in following link : 
 
 
Could you please check and if you still face the issue please revert us by modifying the provided the sample with replication procedure, It will be helpful for us to check on it and give you a better solution earlier.  
 


Luis
Replied On March 12, 2019 05:57 PM UTC

Hi Pradeep,

 thanks for the example, it works just the way I would like my code to work, if I compile using Oreo.
 If I compile using Marshmallow version (the device that will be used to run application that I'm developing, is still running Android 6.0), it doesn't work correctly.
 Can you still help me out?

Thanks,
Luís Pinho

Pradeep Kumar Balakrishnan [Syncfusion]
Replied On March 13, 2019 02:07 PM UTC

Hi Luis, 
 
Thank you for the update. 
 
We checked the reported issue “DataGrid Items is not moved when we moved the items in underlaying datagrid collection” in Lenovo device Android version is 6.0 . and it is working fine on our side.  can you please provide issue reproducing video for our reference to check the issue further on our side . 
 
Regards, 
Pradeep Kumar B 
 
 


Luis
Replied On March 13, 2019 05:38 PM UTC

Hi sorry for the incomplete explanation,

 I had two problems, 1st one, is that changes in the observable collection were not reflected on the grid, that one seems to be correct.
 The other one (that I didn't report), and that I only visible after compiling for version 6 of Android, is:
 - When I try to drag items from one position to another, it wont move the correct position.

 Example, move the 3rd to the 1st position (drop above while over the 1st item), it will move the 3rd item to the 2nd row.
 The same code works fine if I compile with Android 8.

Thanks,
Luís Pinho

Subburaj Pandian Veluchamy [Syncfusion]
Replied On March 14, 2019 12:24 PM UTC

Hi Luis, 
  
Thank you for the update. 
  
We have checked the queries “When we do CRUD action in underlying data DataGrid is not reflects based on the items change” and “Items is dropped in wrong position” both the cases are working fine at our end. In sample, you have manually moved the collection and collection is changed through drag and drop. Also, we have checked the provided sample in (Android 6.0, 7.0) and behavior is same in both the versions. 
  
In your example you have mentioned, if you drag and 3 to 1 it is placed in 2rd place. It is because, initially record collection is changed 3rd row is placed in first row. Now the order is 3,2,1 and we have changed underlying collection now the order is 2,3,1. 
  
If you want to avoid this, you have to skip DataGrid Drag and drop changes or underlying collection change in event. Please refer the following code, 
  
[C#] 
if (e.Reason == QueryRowDraggingReason.DragEnded) 
{ 
    if (e.From == e.To) 
    { 
        e.Cancel = true; 
        return; 
    } 
  
    int fromIndex = e.From - 1; 
    int toIndex = e.To - 1; 
    e.Cancel = true; 
    ((sender as SfDataGrid).ItemsSource asObservableCollection<OrderInfo>).Move(fromIndex, toIndex); 
} 
  
Note: If you set e.cancel as true then DataGrid Drag and Drop collection changed will be skip. 
  
If the given solution doesn’t meet your requirement, please elaborate your query in detail. We will check on it and provide you the solution. 
 
Regards,
Subburaj Pandian V  


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

;