Binding SfDataGrid to CollectionViewSource
Hello
By binding a SfDataGrid to a CollectionViewSource, I lose any sorting and column filtering functionality.
I am using EF6 and the CollectionViewSource is obtained from a DbSet.
It's possible to get all the functionality of the SfDataGrid with this type of binding.
Thanks
Michele
SIGN IN To post a reply.
5 Replies
SS
Susmitha Sundar
Syncfusion Team
March 24, 2020 04:41 PM UTC
Hi Michele,
Thank you for using Syncfusion controls.
You can achieve the sorting and filtering functionality of SfDataGrid with CollectionViewSource without any limitations. With EF6 and DbSet, you can get all the functionality with SfDataGrid.
Please let us know if you need further assistance on this.
Regards,
Susmitha S
Thank you for using Syncfusion controls.
You can achieve the sorting and filtering functionality of SfDataGrid with CollectionViewSource without any limitations. With EF6 and DbSet, you can get all the functionality with SfDataGrid.
Please let us know if you need further assistance on this.
Regards,
Susmitha S
MI
Michele
March 24, 2020 07:30 PM UTC
Thanks for your answer
But it only works if I set AutogenerateColumns to True.
Otherwise I can sort and apply filters only on the first column.
Am I doing something wrong?
Here im binding an ObservableCollection without using CollectionViewSource but anyway it doesn't work as expected.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
_context.vRooms.Load();
tRoomsDataGrid.ItemsSource = _context.vRooms.Local;
}
<sf:SfDataGrid x:Name="tRoomsDataGrid" AutoGenerateColumns="False" Margin="10"
AllowDraggingColumns="True"
AllowFiltering="True""
>
<sf:SfDataGrid.Columns>
<sf:GridTextColumn x:Name="RoomColumn" MappingName="idRoom" HeaderText="id Room" TextAlignment="Right" />
<sf:GridTextColumn x:Name="iDColumn" MappingName=" ID" HeaderText="ID" TextAlignment="Right" />
<sf:GridTextColumn x:Name="CategoryNameColumn" MappingName=" CategoryName" HeaderText="Category" />
</sf:SfDataGrid.Columns>
</sf:SfDataGrid>
SS
Susmitha Sundar
Syncfusion Team
March 25, 2020 07:46 AM UTC
Hi Michele,
Thank you for your update.
We have checked your reported issue “Sorting and Filtering works only for first column while AutoGeneratingColumn is false”. But unfortunately, we unable to replicate this from our end. Sorting and filtering work fine as expected for all the columns. Please check the below sample link,
Sample link: https://www.syncfusion.com/downloads/support/forum/152645/ze/SfDataGridDemobinding-1064461453
We have tested with Syncfusion version 17.4.0.46.
Please check the above sample and revert us if you still facing the same issue? If not, please modify the sample based on your scenario. It will be helpful for us to check on it and provide you the solution at the earliest.
Regards,
Susmitha S
MI
Michele
March 25, 2020 07:49 PM UTC
Hello Susmitha
Attachment: Test_sfDataGrid_666959ee.zip
I created a new solution by copying the code from your solution.
In this case no column can be ordered or filtered and the scrollbar doesn't work either.
Attached my solution
The one you gave me works fine.
Maybe a problem with Synfusion Versions?
I checked, but they look the same
Attachment: Test_sfDataGrid_666959ee.zip
SS
Susmitha Sundar
Syncfusion Team
March 26, 2020 06:55 AM UTC
Hi Michele,
Thank you for your update.
We have checked your provided sample. In this sample, you are initializing the empty SfDataGrid after the SfDataGrid definition. Please refer to the below code,
|
<Grid>
<syncfusion:SfDataGrid x:Name="sfDataGrid"
AllowFiltering="True"
AllowEditing="True"
AutoGenerateColumns="False">
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridTextColumn MappingName="OrderID"/>
<syncfusion:GridTextColumn MappingName="CustomerID" />
<syncfusion:GridTextColumn MappingName="CustomerName" />
<syncfusion:GridTextColumn MappingName="Country" />
<syncfusion:GridTextColumn MappingName="UnitPrice"/>
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
<syncfusion:SfDataGrid/> |
This empty SfDataGrid renderer on the first SfDataGrid. So you cant access the first SfDataGrid. Please check your sample by removing that empty SfDataGrid.
Please let us know if you need further assistance on this.
Regards,
Susmitha S
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
MI Michele
- Mar 23, 2020 05:19 PM UTC
- Mar 26, 2020 06:55 AM UTC