This question is locked. New answers and comments are not allowed.
Chris Moore
Top achievements
Rank 1
Chris Moore
asked on 16 Mar 2011, 10:37 PM
I have read several messages on this forum regarding the fact that a cell in a grid view combo box will not display the selected item until you click on the cell. I, too, am experiencing this. I am not using element binding, a domain datasource or anything complicated; I'm simply biding to a collection in my model. I know the binding is set up properly because the cell is displaying the appropriate value when it is clicked and selection changes are propagated to my model. Is there a fix for this other than some crazy workaround or hack? Or should I just accept that the GirdViewComboBoxColum is useless in simple MVVM databinding scenarios and create a custom template that includes a combo box?
Thanks.
Thanks.
DataMemberBinding="{Binding ValueTypeSelection, Mode=TwoWay}"
DisplayMemberPath="DisplayName"
ItemsSource="{Binding EditModel.FactorInfo.InstrumentValueTypePicklist}"
5 Answers, 1 is accepted
0
Hello Chris Moore,
Maya
the Telerik team
Generally, the reason that this behavior occurs is the difference between the DataContext of the column and that of the row. The solution however is the same as described here - no matter that you are not using ElementName binding.
Maya
the Telerik team
0
Chris Moore
Top achievements
Rank 1
answered on 18 Mar 2011, 03:21 PM
Neither of those workarounds are really appropriate to my situation and that is why I posted a message to the forum. I suppose I could set the itemssource from the code behind, but that is really ugly and everthing else on the page is bound in the traditional, declarative, way. In any event, consider the following evidence:
1. The correct list of items is displayed in the combo
2. Changes to the selection of the combo are correctly propagated to the model (via the DataMemberBinding)
In other words *everything* about the binding works *except* that the grid refuses to correctly display the item that is currently selected in the combo box *unless* the cell is clicked on. To me, this sounds like a problem with the grid and not with the binding. The grid should display the item that is currently selected in the combo shouldn't it? And if it doesn't, isn't that a bug?
1. The correct list of items is displayed in the combo
2. Changes to the selection of the combo are correctly propagated to the model (via the DataMemberBinding)
In other words *everything* about the binding works *except* that the grid refuses to correctly display the item that is currently selected in the combo box *unless* the cell is clicked on. To me, this sounds like a problem with the grid and not with the binding. The grid should display the item that is currently selected in the combo shouldn't it? And if it doesn't, isn't that a bug?
0
Rakesh
Top achievements
Rank 1
answered on 03 Aug 2011, 06:46 PM
The workaround wont suit my situation because I am using RIA services and my lookup comes from xaml. so I dont want to do it in code-behind,
How do I set it so that it works properly?
<riaControls:DomainDataSource x:Key="ChartAccountCodes" Name="ChartAccountDataSource" QueryName="GetLkCHARTACCT" AutoLoad="False">
<riaControls:DomainDataSource.DomainContext>
<domservice:domS_dms/>
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<telerik:RadGridView x:Name="dgChartAccts" ShowGroupPanel="False"
ShowGroupFooters="False" ShowColumnFooters="False" AutoExpandGroups="True"
AutoGenerateColumns="False" IsFilteringAllowed="False" RowIndicatorVisibility="Collapsed"
Margin="2,1,0,0" MinHeight="100" MaxHeight="100" >
<telerik:RadGridView.Columns>
<telerik:GridViewComboBoxColumn Header="Name" Width="150" DataMemberBinding="{Binding Path=CHARTACCTID}" SelectedValueMemberPath="CHARTACCTID" DisplayMemberPath="DESCRIP" ItemsSource="{Binding Path=Data,ElementName=ChartAccountDataSource}" />
<telerik:GridViewDataColumn Header="Amt" Width="100" DataMemberBinding="{Binding Path=AMT}" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
How do I set it so that it works properly?
<riaControls:DomainDataSource x:Key="ChartAccountCodes" Name="ChartAccountDataSource" QueryName="GetLkCHARTACCT" AutoLoad="False">
<riaControls:DomainDataSource.DomainContext>
<domservice:domS_dms/>
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<telerik:RadGridView x:Name="dgChartAccts" ShowGroupPanel="False"
ShowGroupFooters="False" ShowColumnFooters="False" AutoExpandGroups="True"
AutoGenerateColumns="False" IsFilteringAllowed="False" RowIndicatorVisibility="Collapsed"
Margin="2,1,0,0" MinHeight="100" MaxHeight="100" >
<telerik:RadGridView.Columns>
<telerik:GridViewComboBoxColumn Header="Name" Width="150" DataMemberBinding="{Binding Path=CHARTACCTID}" SelectedValueMemberPath="CHARTACCTID" DisplayMemberPath="DESCRIP" ItemsSource="{Binding Path=Data,ElementName=ChartAccountDataSource}" />
<telerik:GridViewDataColumn Header="Amt" Width="100" DataMemberBinding="{Binding Path=AMT}" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
0
Hello Rakesh,
All the best,
Maya
the Telerik team
You may still use the approach with defining the Source property of the binding:
<UserControl.Resources> <telerik:RadDomainDataSource x:Name="ordersDataSource" AutoLoad="True" QueryName="GetOrdersQuery" > <telerik:RadDomainDataSource.DomainContext> <local:CustomersDomainContext /> </telerik:RadDomainDataSource.DomainContext> </telerik:RadDomainDataSource></UserControl.Resources><telerik:GridViewComboBoxColumn DataMemberBinding="{Binding CustomerID}" UniqueName="Customer" DisplayMemberPath="ContactName" SelectedValueMemberPath="CustomerID" ItemsSource="{Binding DataView, Source={StaticResource customersDataSource}}"/>All the best,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Rakesh
Top achievements
Rank 1
answered on 05 Aug 2011, 04:41 PM
Maya,
Thanks for your help
Although there were issues in your code, "DataView" was the key for me to get it resolved.
Now my next question is
I have 2 tables say Funds and Fectypes. Funds has a property called FORM3 and Fectypes has a property called Form3
I have 2 ria controls domain source for Funds and Fectypes; I have 2 combo-boxes for fund AND Fectype in my business object say Money.
Now all i want to do is by selecting a value in first combobox , I want to dynamically filter the options available in Second combobox of fectypes.
My issue is the property that I want to filter for second combobox is neither DisplayMemberPath nor Selected Value. Form3 is a proprty in funds table but I dont display. So I tried using tag the binding of form 3 but it didnt help either.
1.I have used tag to store one propery usually from code-behind but I am not quite sure of how to bind a property in funds table to Tag
2. Here is the code for my domain data source and combo boxes
Resources:
<riaControls:DomainDataSource x:Key="Funds" Name="FundDataSource" QueryName="GetDmFUND" AutoLoad="False">
<riaControls:DomainDataSource.DomainContext>
<domservice:domS_dms/>
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<riaControls:DomainDataSource x:Key="FecTypeCodes" Name="FecDataSource" QueryName="GetLkFECTXNTYPE" >
<riaControls:DomainDataSource.DomainContext>
<domservice:domS_dms/>
</riaControls:DomainDataSource.DomainContext>
<riaControls:DomainDataSource.FilterDescriptors>
<riaControls:FilterDescriptor
PropertyPath="FORM3" Operator="IsEqualTo"
IgnoredValue="-1"
Value="{Binding Path=Tag.dmFUND.FORM3,ElementName=cbFundCode}" />
</riaControls:DomainDataSource.FilterDescriptors>
Comboboxes:
<telerik:RadComboBox x:Name="cbFundCode" DisplayMemberPath="FUNDDESC"
SelectedValue="{Binding FUNDID, Mode=TwoWay}"
SelectedValuePath="FUNDID"
ItemsSource="{Binding Data,ElementName=FundDataSource}"
IsEditable="True" IsReadOnly="True" Tag="{Binding FORM3}"
Width="190" SelectAllTextEvent="None" OpenDropDownOnFocus="True" />
<telerik:RadComboBox x:Name="cbAccountCode" DisplayMemberPath="DESCRIP"
SelectedValue="{Binding CENTERID, Mode=TwoWay}" SelectedValuePath="CENTERID"
ItemsSource="{Binding Data,ElementName=AccountCodeDataSource}"
IsEditable="True" IsReadOnly="True" Width="190" SelectAllTextEvent="None" OpenDropDownOnFocus="True" />
2 Questions:
1. How do i tag FORM3 property in first combobox cbFundCode
2. How do I retrieve that value in FecDataSource - Filter Value
Thanks
Thanks for your help
Although there were issues in your code, "DataView" was the key for me to get it resolved.
Now my next question is
I have 2 tables say Funds and Fectypes. Funds has a property called FORM3 and Fectypes has a property called Form3
I have 2 ria controls domain source for Funds and Fectypes; I have 2 combo-boxes for fund AND Fectype in my business object say Money.
Now all i want to do is by selecting a value in first combobox , I want to dynamically filter the options available in Second combobox of fectypes.
My issue is the property that I want to filter for second combobox is neither DisplayMemberPath nor Selected Value. Form3 is a proprty in funds table but I dont display. So I tried using tag the binding of form 3 but it didnt help either.
1.I have used tag to store one propery usually from code-behind but I am not quite sure of how to bind a property in funds table to Tag
2. Here is the code for my domain data source and combo boxes
Resources:
<riaControls:DomainDataSource x:Key="Funds" Name="FundDataSource" QueryName="GetDmFUND" AutoLoad="False">
<riaControls:DomainDataSource.DomainContext>
<domservice:domS_dms/>
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<riaControls:DomainDataSource x:Key="FecTypeCodes" Name="FecDataSource" QueryName="GetLkFECTXNTYPE" >
<riaControls:DomainDataSource.DomainContext>
<domservice:domS_dms/>
</riaControls:DomainDataSource.DomainContext>
<riaControls:DomainDataSource.FilterDescriptors>
<riaControls:FilterDescriptor
PropertyPath="FORM3" Operator="IsEqualTo"
IgnoredValue="-1"
Value="{Binding Path=Tag.dmFUND.FORM3,ElementName=cbFundCode}" />
</riaControls:DomainDataSource.FilterDescriptors>
Comboboxes:
<telerik:RadComboBox x:Name="cbFundCode" DisplayMemberPath="FUNDDESC"
SelectedValue="{Binding FUNDID, Mode=TwoWay}"
SelectedValuePath="FUNDID"
ItemsSource="{Binding Data,ElementName=FundDataSource}"
IsEditable="True" IsReadOnly="True" Tag="{Binding FORM3}"
Width="190" SelectAllTextEvent="None" OpenDropDownOnFocus="True" />
<telerik:RadComboBox x:Name="cbAccountCode" DisplayMemberPath="DESCRIP"
SelectedValue="{Binding CENTERID, Mode=TwoWay}" SelectedValuePath="CENTERID"
ItemsSource="{Binding Data,ElementName=AccountCodeDataSource}"
IsEditable="True" IsReadOnly="True" Width="190" SelectAllTextEvent="None" OpenDropDownOnFocus="True" />
2 Questions:
1. How do i tag FORM3 property in first combobox cbFundCode
2. How do I retrieve that value in FecDataSource - Filter Value
Thanks