BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi Team
1)Is possible to add column dynamically when i click in add button in mvvm pattern.
2)Is possible to get all the row values of single column based on the column name provided.
3)Is Possible to binding column with different collection(Ex. column1 is filled NameRegister, column2 to is bind with some telephone collection.
Thanks
Sankar A
private static void OnAddColumn(object sender, ExecutedRoutedEventArgs args) { var sfDataGrid = sender as SfDataGrid; sfDataGrid.Columns.Add(new GridNumericColumn() { MappingName = "GradePointAverage", HeaderText = "GradePointAverage" }); } |
private static void OnGetRowValue(object sender, ExecutedRoutedEventArgs args) { var sfDataGrid = sender as SfDataGrid; var records=sfDataGrid.View.Records; List<object> columnvalue = new List<object>(); var provider = sfDataGrid.View.GetPropertyAccessProvider(); for (int i = 0; i < sfDataGrid.View.Records.Count; i++) { columnvalue.Add(provider.GetValue((records[i] as RecordEntry).Data, "Age")); } |
<!--StudentName collection with GridComboBoxColumn--> <syncfusion:GridComboBoxColumn HeaderText="Name" MappingName="Name" ItemsSource="{Binding StudentName,Source={StaticResource collection}}" /> <!--PhoneNumber collection with GridComboBoxColumn--> <syncfusion:GridComboBoxColumn HeaderText="Phone Number" MappingName="PhoneNumer" ItemsSource="{Binding PhoneNumber,Source={StaticResource collection}}"/> |
private static void OnAddColumn(object sender, ExecutedRoutedEventArgs args) { var sfDataGrid = sender as SfDataGrid; //columns added dynamically for DetailsViewDataGrid (sfDataGrid.DetailsViewDefinition[0] as GridViewDefinition).DataGrid.Columns.Add(new GridTextColumn() { MappingName = "ProductName", HeaderText = "Product Name" }); sfDataGrid.GetVisualContainer().InvalidateMeasure(); |
private static void OnGetRowValue(object sender, ExecutedRoutedEventArgs args) { var sfDataGrid = sender as SfDataGrid; //You can get corresponding DetailsViewDataGrid ,for accessing records count of Details View var detailsViewDataGrid = sfDataGrid.GetDetailsViewGrid(sfDataGrid.ResolveToRecordIndex(sfDataGrid.SelectionController.CurrentCellManager.CurrentCell.RowIndex), "ProductDetails"); var records = detailsViewDataGrid.View.Records; List<object> columnvalue = new List<object>(); var provider = detailsViewDataGrid.View.GetPropertyAccessProvider(); for (int i = 0; i < detailsViewDataGrid.View.Records.Count; i++) { columnvalue.Add(provider.GetValue((records[i] as RecordEntry).Data, "ProductId")); } |
<syncfusion:GridComboBoxColumn MappingName="PhoneNumber" ItemsSource="{Binding PhoneNumberCollection,Source={StaticResource collection} }"/>
|