In my last question, I asked about dynamically added layouts. Turns out I didnt need to and thanks to Rob, he got me going. Now I have another design modification where they want to add lookup data to a specific fields so this means I need to add a dropdown to the field(5 fields in all so 5 dropdowns) in the grid. Can this be done dynamically? Or do I need to produce a specialized template of some sort to call?
Constraints is I have various data sources that utilize the same grid so I need to be able to programmatically alter the FieldLayout based on the datasources. I suppose if worse comes to worse I can add another grid to handle the specialized nature of this one datasource and just invis or vis the grids as needed depending on whether or not the datasource is being used. Not sure I want to go that route though...
Hi,
Thank you for your post. I have been looking into your requirement and it seems that you need to enable record filtering. For more information about record filtering you could look into the following link from our online documentation:
http://help.infragistics.com/doc/WPF/2014.2/CLR4.0/?page=xamDataPresenter_About_Record_Filtering.html
The link below shows how to activate it:
http://help.infragistics.com/doc/WPF/2014.2/CLR4.0/?page=xamDataPresenter_Enable_Record_Filtering.html
Let me know, if you need any further assistance on this matter.
?? I dont know where you get record filtering out of what I am asking for. You missed the mark entirely.
I need to create a combo/dropdown in the grid for cells of 5 columns to allow the users to be able to pick values for the cell they are editing. So each of those cells will have a combobox. My guess is that I need to create a style that has a combobox and associate it with a field and have a collectionviewsource bound to the combobox. I havent figured out how to do this. THis is what I need help with....
thanks
Thank you for your reply. I have been looking into your requirement and you can see how Krasimir has added a XamComboEditor in a field of the XamDataGrid:
http://es.infragistics.com/community/forums/t/63525.aspx
Also you could look into the following link from our online documentation how to use our new ComboBoxField in vol. 14.2:
http://help.infragistics.com/doc/WPF/2014.2/CLR4.0/?page=xamDataPresenter_Configuring_Specific_Editor_Fields.html
Thank you for the links... somewhat helpful.
My grid does not have defined fields. The fields are autogenerated based on the supplied data source. Below is the XAML for my grid:
<igWPF:XamDataGrid x:Name="GrdMaint" Margin="10" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" DataSource="{Binding Source={StaticResource cvsDataGrid}}" BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" VerticalAlignment="Top" Theme="Office2k7Blue" GroupByAreaLocation="None" FieldLayoutInitialized="GrdMaint_OnFieldLayoutInitialized"> <igWPF:XamDataGrid.FieldSettings> <igWPF:FieldSettings AllowRecordFiltering="True" FilterOperandUIType="TextBox"/> </igWPF:XamDataGrid.FieldSettings> <igWPF:XamDataGrid.FieldLayoutSettings> <igWPF:FieldLayoutSettings HighlightAlternateRecords="True" FilterClearButtonLocation="FilterCell" FilterRecordLocation="OnTop" FilterUIType="FilterRecord" AutoGenerateFields="True" /> </igWPF:XamDataGrid.FieldLayoutSettings> </igWPF:XamDataGrid>
My window resource :
<Window.Resources> <CollectionViewSource x:Key="cvsDataGrid" Source="cvsDataGrid"/> <CollectionViewSource x:Key="cvsTaskList" Source="cvsTaskList"/> <CollectionViewSource x:Key="cvsPickList1" Source="cvsPickList1" /> <CollectionViewSource x:Key="cvsPickList2" Source="cvsPickList2" /> <CollectionViewSource x:Key="cvsPickList3" Source="cvsPickList3" /> <CollectionViewSource x:Key="cvsPickList4" Source="cvsPickList4" /> <Style x:Key="EditableColumn" TargetType="{x:Type igWPF:CellValuePresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsEditingAllowed}" Value="True"> <Setter Property="Background" Value="LightYellow"/> </DataTrigger> </Style.Triggers> </Style> <Style x:Key="DropDownPicker1" TargetType="{x:Type igWPF:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igWPF:CellValuePresenter}"> <ig:XamComboEditor x:Name="cboPickList1" ItemsSource="{Binding Source={StaticResource cvsPickList1}}" DisplayMemberPath="DisplayLabel" SelectedValuePath="ProductLineID" /> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="DropDownPicker2" TargetType="{x:Type igWPF:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igWPF:CellValuePresenter}"> <ig:XamComboEditor x:Name="cboPickList1" ItemsSource="{Binding Source={StaticResource cvsPickList2}}" DisplayMemberPath="DisplayLabel" SelectedValuePath="ProductLineID" /> </ControlTemplate> </Setter.Value> </Setter> </Style> ...
In my code behind i want to do this:
private void GrdMaint_OnFieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e) { foreach (Field fld in e.FieldLayout.Fields) { fld.Settings.AllowEdit = false; if (_hideColumns != null && _hideColumns.Any()) { if (_hideColumns.Contains(fld.Name)) fld.Visibility = Visibility.Collapsed; } if (_editColumns == null || !_editColumns.Any()) continue; if (!_editColumns.Contains(fld.Name)) continue; fld.Settings.AllowEdit = true; fld.Settings.CellValuePresenterStyle = Resources["EditableColumn"] as Style; // if this is CE then we need to add combo box to the fields... if (_cboColumns == null || !_cboColumns.Any()) continue; if (SvcModel.Equals("CE")) { switch (fld.Name) { case "ProductLineName": fld.Settings.CellValuePresenterStyle = Resources["DropDownPicker1"] as Style; break; case "TradeElement": //fld.Settings.CellValuePresenterStyle = Resources["DropDownPicker2"] as Style; break; case "ActivityCode" : fld.Settings.CellValuePresenterStyle = Resources["DropDownPicker3"] as Style; break; case "LaborType" : //fld.Settings.CellValuePresenterStyle = Resources["DropDownPicker4"] as Style; break; } } } }This is so I can dynamically define the layout... and when I load a particular datasource the grid will reflect the correct layout. However none of the combobox show up. Any ideas?
On a side note editing this message then posting wiped out some of the content.... I have had to re-enter it again.
Hello,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
wow thats a bit of difference... Looks like I had things a little backwards. So with it set to the EditorStyle the combo is bound the field? Or does a binding need to be set from the selected value to the actual field? This is what confuses me a bit.
*edit* I ran it and did some checks. It does automatically bind it to the field. very nice!
Thank you very much for the help!!
I have modified the sample you have sent, so now it works correctly. Basically, instead of creating ContentTemplate for the CellValuePresenter and put a XamComboEditor inside, I created Styles for the XamComboEditor itself and set it to the FieldSetting's EditorStyle Property. Please let me know if this helps you or you have further questions on this matter. Looking forward for your reply.
None of links helps me as I am programmatically setting the styles. The sample I sent shows this. I dont predefine any fields in the xaml xamDataGrid so I have to do all the binding on the code side. You have offered no comment to the sample project I sent to indicate what I have done wrong so far or needed to correct. Could you please provide help relevant to the sample project I uploaded? If what I am trying to do cannot be done the way I am doing it I need to know so I can refactor.
Thank you for your reply. I have been looking into your question and you need to bind the selected item of the XamComboEditor in order to have a selected value on loading. You could look into the following links where it is whown how to do it:
http://es.infragistics.com/community/forums/t/90677.aspx
http://es.infragistics.com/community/forums/t/62824.aspx?PageIndex=2
Now the selection is lost because of the virtualization of the XamDataGrid. Once the binding to the selected item is applied, you will not lost it any more.