Hi,
i am trying to use two dependant xamcomboeditors in xamdatagrid,first combo contains City kist and secod is county list depending on selected city on first combobox,and i use first combobox's selecteditemchange event to set county combo's itemssource for changed city.I can access the editor of county field with :
(In first City xamcombo's selecteditemchanged routedevent)
DataRecord
record = grid.ActiveRecord as DataRecord;
CellValuePresenter presenter = CellValuePresenter.FromRecordAndField(record, "FieldName");
XamComboEditor editor = presenter.Editor as XamComboEditor;
by activerecord of grid and name of county field,and then update the itemssource of accessed editor.(County)
it's ok when user selects city on UI ,because i can get grid's activerecord,but can't get the editor of County when i set the city manually on codebehind.
Is there a way to get editor when grid's activerecord is null or is there a better way to use cascade xamcombobox in xamdatagrid and set the selected item ?
Hello,
I am just checking your progress on the issue.
If you require any further assistance please do not hesitate to ask.
Sincerely,
Ekaterina
Developer Support Engineer
Infragistics
www.infragistics.com/support
Thank you for your answer.
You can replace:
CellValuePresenter.FromCell((xamDataGrid1.ActiveRecord as DataRecord). …
With
CellValuePresenter.FromCell((xamDataGrid1.Records[2] as DataRecord). …
for example.
That way instead of the potentially active record, you will get the second one.
In case of future concerns, please do not hesitate to ask
Infragistics, Inc.
Hello Ekaterina,
Thank you very much for your answer,but you use
CellValuePresenter
.FromCell and this method expects grid's
xamDataGrid1.ActiveRecord ,how can be accessed to editor when ActiveRecord is null ? (if user sets the value of comboeditor manually without using UI,ActiveRecord becomes null)
Thanks you for your answer, after your new explanations I think I better understood your requirements.
I have created a sample project in order to demonstrate the new solution. Notice that you can create a new ComboBoxItemsProvider and ObjectDataProvider in the events handler, instead of declaring them in the xaml, in order to pass different instance on every editor.
In the handler you can add some conditions and declare different source objects according to them.
Please let me know if my sample meets your requirements or I have misunderstand you at some point.
Hi Ekaterina,
Thank you for your reply.I investigeted your solution,i tried a solution like your solution,but in your solution itemssources not changing,converter changing value in the same sources ,so selected value can be changed with no problem.
In my case source of combo2(county) is changing depending on to selected value in combo1(City),i wrote a converter like your solution :
PseudoCode :
CityToCountyConverter : IValueConverter
{
convert()
return getCountyListByCityId(cityId);
}
xaml side pseudecode :
<igDP:Field Name="CityId"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource CityList}"></Setter> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="CountyId"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource DataItem.CityId,Converter={StaticResource CityToCountyConverter}}"></Setter> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
It works like this but the problem is that the selecteditem not changing when itemssource is updated ,
for example:
Combo1 's source
text :City1 value : 1
text :City2 value :2
Countys of City1
County1.1 1
County1.2 2
County1.2 3
Countys of City2
County2.1 4
County2.2.5
County2.3 6
user selected City1 in combo1 then County1.1,County1.2,County1.3 is listed in combo2 ,also user selected County2 in combo2,then when user selected City2 in combo1 ,the itemssource of Combo2 is changed to County2.1,Count2.2,County2.3 but displaytext of combo2 is 2,because selected item County County1.2 and its value not containing in new combo2 itemssource ,so display text is 2.