hi,
I am trying to filter the contents of a dropdown, based on another dropdown in the same row.
I can do filtering using a ValueConverter , however, i don't know how to get a reference to the value of the other field (also a dropdown).
Here is my grid field definition (this is the column that has a dropdown that should be filtered based on another columns selected value):
<igDP:Field Label="Category" Width="100"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" AllowEdit="True"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type v:AdjustmentsView_EditGrid}}, Converter={StaticResource CategoryConverter}}" /> <Setter Property="DisplayMemberPath" Value="Name" /> <Setter Property="ValuePath" Value="Name" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
The only way i thought of doing this, was if i could somehow update record on every selection of the other dropdown. If i can update record immediately after changing a selection, my converter would know how to filter the list.
nope, i was not aware of that setting, so i did not set it at all. thanks!
curiously it is not set on the example app either, but that one works correctly.
Hello,
I assume that you have set the ‘UpdateMode’ property of the XamDataGrid to ‘OnRecordChange’. You need to set it to ‘OnCellChange’. This way the converter should trigger when you change the value in the cell.
If this does not help you please modify the provided application.
in my case, the converter expects string:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var vm = UnityUtil.Resolve<AdjustmentsViewModel>(); if (vm != null) { return vm.Categories; } return null; }
i'm actually not even doing anything with the passed in value yet.. the problem is that the value comes in null now. even though something is selected in first dropdown..
The deference is that in the two styles as a ‘ValuePath’ you are using “Name” instead of “Id”. The converter excepted integer value not string.
this is part of a huge solution.. would be tricky to isolate.. anything you could suggest based on posted code snippets?
i have the sample application you pointed me to loaded side by side and working correctly.
the difference i am seeing is that in my app, when i change the left dropdown it does trigger the converter to execute on my right dropdown.. but it is called with a null value. and it only executes on first change.. nothing happens on subsequent changes.
i understand if this is not enough info to go on :)