Generating SFDataGrid with GroupedSource
Thank you for contacting Sycnfusion Support.
We have analyzed your queries and find the details below,
You have stated that your source data is the result of a LINQ group-by query so the type is IEnumerable<IGrouping>. We couldn’t get your type of source that you have used. Please share your viewmodel collection with us.
Regarding query: For the datagrid I'm setting the ItemsSource myself, but I can't figure out programmatically how to tell the sfdatagrid that the feed is grouped. I believe I need a way to set the IsSourceGrouped flag on sfdatagrid similar to the xaml above.
We couldn’t get the scenario clearly. In SfDataGrid, we have a flag to check the datagrid is grouped or not. But you have mentioned that the sfdatagrid gets flag that feed is grouped or not. Please share it in more detail.
Please share your requirement clearly with us. Also please share the datacollection from view model. It would be helpful for us to provide a solution.
Regards,
Jayapradha
Attachment: App1_6c11753.zip
Thank you for your update.
You can add a new column in code behind and you can set the CellTemplate like below,
|
private void Sfdatagrid_Loaded(object sender, RoutedEventArgs e) { viewModel = this.sfdatagrid.DataContext as ViewModel; this.sfdatagrid.ItemsSource = viewModel.EmployeeDetails; this.sfdatagrid.Columns.Add(new GridTextColumn() { MappingName = "EmployeeID", CellTemplate = App.Current.Resources["cellTemplate"] as DataTemplate }); |
Find the sample below,
Sample Link: http://www.syncfusion.com/downloads/support/forum/123630/ze/UWP-2059594062
Regarding query: My question is how can I bind the grid to create 2 columns with 3 rows each (one for each SubCategory1).
We couldn’t get your requirement clearly. Could you please share it clearly. It would be helpful for us to provide a better solution.
Regards,
Jayapradha
Is it possible to modify these lines from your example to bind at the A1.attValue level into the EmployeeID column?
this.sfdatagrid.ItemsSource = viewModel.EmployeeDetails;
this.sfdatagrid.Columns.Add(new GridTextColumn() { MappingName = "EmployeeID", CellTemplate=App.Current.Resources["cellTemplate"] as DataTemplate });
thanks again!
Thank you for your update.
Yes. It is possible to bind the attValue Name to the CustomerName Column by using ComplexProperty with DisplayBinding. We have prepared a sample for your reference.
Code Example:
|
private void Sfgrid_Loaded(object sender, RoutedEventArgs e) { sfgrid.ItemsSource = viewModel.MyProperty; Binding disBinding = new Binding(); disBinding.Path = new PropertyPath("NameAttr.Name"); sfgrid.Columns.Add(new GridTextColumn() { MappingName = "CustomerName", DisplayBinding = disBinding, CellTemplate = App.Current.Resources["cellTemplate"] as DataTemplate }); |
Sample Link: http://www.syncfusion.com/downloads/support/forum/123630/ze/SfDataGrid_ComplexProperty-152222226
Regards,
Jayapradha
- 5 Replies
- 2 Participants
-
DD Deanna Delapasse
- Apr 5, 2016 01:40 PM UTC
- Apr 11, 2016 06:15 AM UTC