This is a migrated thread and some comments may be shown as answers.

Help, ComboBox Column is empty?

11 Answers 131 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 23 Mar 2010, 01:04 PM
I'm having trouble populating my ComboBox Column. In short, it is remaining empty.
I've also tried using a Datacolumn with a datatemplate with a combo box in it, but it is not working either



I'm trying to do everything in XAML, so I've created a domain data source

<riaControls:DomainDataSource x:Name="Staff_Data" QueryName="GetStaffs" AutoLoad="True"
            <riaControls:DomainDataSource.DomainContext> 
                <ds:CashSale_DomainContext/> 
            </riaControls:DomainDataSource.DomainContext> 
        </riaControls:DomainDataSource> 

Which works fine and does load the requested data.
In a separate section of my app (in the details section, of my master-details sort of view) I'm using just a regular combo box in a canvas/stackpanel and it works fine. (The combobox is a child of the tab item, so it is inheriting the datacontext from the tabitem)
<telerikNavigation:RadTabItem DataContext="{Binding ElementName=gv_cashsale, Path=SelectedItem, Mode=TwoWay}"
 
 
... 
 
 <telerikInput:RadComboBox x:Name="cb_saleby" HorizontalAlignment="Left" Margin="10" Canvas.Left="96" Height="22"  
                                                              Width="207" IsEditable="True" Canvas.Top="20" IsFilteringEnabled="True" IsReadOnly="True"  
                                                              OpenDropDownOnFocus="True" ItemsSource="{Binding ElementName=Staff_Data, Path=Data}" 
                                                              SelectedValue="{Binding staffid, Mode=TwoWay}" SelectedValuePath="staffid" DisplayMemberPath="name"




However, when I try to do it in a gridviews column, it does not work. (Granted the selected value's binding is different, as the above binds to the selected item in the gridview, but the items list in the combo boxes is null)

<telerikGridView:RadGridView Name="gv_cashsale" Height="336" ShowGroupPanel="False" ShowGroupFooters="True"  
                                                                     AutoGenerateColumns="False" ShowInsertRow="True" IsReadOnly="True" 
                                                                     ItemsSource="{Binding PagedSource, ElementName=dp_cashsale}"
... 


<!--<telerikGridView:GridViewDataColumn Header="Sale By" Width="100" DataMemberBinding="{Binding staffid}"
                                                    <telerikGridView:GridViewDataColumn.CellTemplate> 
                                                        <DataTemplate> 
                                                            <StackPanel> 
                                                               <telerikInput:RadComboBox  IsEditable="True" Canvas.Top="20" IsFilteringEnabled="True"  
                                                                                          IsReadOnly="True" OpenDropDownOnFocus="True"  
                                                                                          ItemsSource="{Binding ElementName=Staff_Data, Path=Data}" 
                                                                                          DisplayMemberPath="name" 
                                                                                          SelectedValue="{Binding staffid, Mode=TwoWay}"  
                                                                                          SelectedValuePath="staffid" /> 
                                                            </StackPanel> 
                                                        </DataTemplate> 
                                                    </telerikGridView:GridViewDataColumn.CellTemplate> 
                                                </telerikGridView:GridViewDataColumn>--> 
 
                                                <telerikGridView:GridViewComboBoxColumn   
                                                        ItemsSource="{Binding ElementName=Staff_Data, Path=Data}"  
                                                        DataMemberBinding="{Binding staffid}"    
                                                        DisplayMemberPath="name"   
                                                        SelectedValueMemberPath="staffid"   /> 

I basically tried a data templated datacolumn, when that didn't work I commented it out and tried the... combobox column which also does not work. The grid view is working correctly (except for the combo boxes) and if I have just a normal data column pulling the staffid, it does retrieve the required number.






Am I doing something incorrectly?


11 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 23 Mar 2010, 01:19 PM
Hello Alexander Sun,

I am not sure if this is the only cause of the problem , but in your code I have noticed you try to set the ItemsSource of the GridViewComboBox column with binding.

Please use the ItemsSourceBinding property of the ComboBoxColumn instead  of the ItemsSource property when you need to set a binding.

Kind regards,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Alex
Top achievements
Rank 1
answered on 23 Mar 2010, 01:38 PM
I've tried changing it to use
<telerikGridView:GridViewComboBoxColumn   
                                                        ItemsSourceBinding="{Binding ElementName=Staff_Data, Path=Data}"  
                                                        DataMemberBinding="{Binding staffid, Mode=TwoWay}"    
                                                        DisplayMemberPath="name"   
                                                        SelectedValueMemberPath="staffid" Header="Sale By" /> 

But instead of giving a blank combo box drop down, it now crashes to a white screen. I've tried various other combinations such as changing the Mode, dropping the path.

And I'm rather stumped as to why it isn't working :S (as the actual binding I'm using for the regular combo box's items is identical, so why would this one crash :S)



0
Pavel Pavlov
Telerik team
answered on 23 Mar 2010, 02:10 PM
Hi Alexander Sun,

I believe the reason for the crash is the ElementName binding - Gridview cells are virtualized ( created dynamically on demand ) for memory and performance reasons. Therefore they do not participate in the visual tree the same way as other UIElements in the form and ElementBindings wil not work.

You may try exposing the items source as a static resource in XAML , or set it directly in code behind .
In case you still have troubles , please paste me the implementation of your underlying business objects and I will put together a small working sample for you.

Sincerely,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Alex
Top achievements
Rank 1
answered on 24 Mar 2010, 12:23 AM
Hi Pavel,

I working example would be greatly appreciated (If possible, with multiple methods of how to achieve the final implementation, preferably those that use more XAML then code behind).


My current setup is very rudimentry. I have an SQL database that I've created with a staff table
(name, datatype, allow nulls)
staffid    int    Unchecked (primary key)
name    nvarchar(200)    Checked

And a cashsale table (this is the main type) with a foreign key to the staffid
receipt    bigint    Unchecked (primary key)
...
staffid    int    Checked (foreign key)
...


From that, I've created a basic ado data model of the tables,

And then I have the default domain service (get insert update delete) on each of the tables

And finally I have the xaml in the previous post with the DomainDataSource.


0
Dominic
Top achievements
Rank 1
answered on 26 Mar 2010, 07:58 PM
Hello,

i have the same problem. Is there a working sample for a RadComboBox and/or a GridViewComboBoxColumn with declarative Binding of DomainDataSource?
0
Accepted
Pavel Pavlov
Telerik team
answered on 29 Mar 2010, 04:00 PM
Hi guys,

Please find the project attached .
Please note that in the constructor of the Home page we explicitly call the Load method of the DomainDataSource. This we do to avoid the problem with the initially blank combo column . The problem itself is caused by the nature of the DomainDataSource to load the items delayed  in certain situations.

The project demonstrates the workaround to the issue and meanwhile we are going to take the steps necessary to fix this and avoid the problem in future versions.

Best wishes,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Calin Calin
Top achievements
Rank 1
answered on 28 Apr 2010, 08:55 PM
Hi,

I am also facing this issue, it will be really helpful if you could give a possible target date for the fix or a link to track the issue.

Regards,
0
Alex
Top achievements
Rank 1
answered on 28 Apr 2010, 09:50 PM
Just do what Pavels example shows, and make the DomainDataSource a Resource (e.g. a grid resource in layoutroot) and then bind the column to that resource
0
Calin Calin
Top achievements
Rank 1
answered on 29 Apr 2010, 05:06 AM
Hi Alexander,

I already do that, it works very nice to populate the grid. But now, I have the column's SelectedValue bound to SubItemId, Mode = TwoWay. If I change this SubItemId from the ViewModel the combobox does not get changed until I click on it.
0
Pavel Pavlov
Telerik team
answered on 29 Apr 2010, 01:29 PM
Hello Calin Calin,
Your property should utilize the INotifyPropertyChanged  interface. This will allow RadGridView to sense changes and update the ui. Currently we have a known issue with this scenario not working for nested properties . This will be solved in the internal build tomorrow.

Regards,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Calin Calin
Top achievements
Rank 1
answered on 29 Apr 2010, 02:17 PM
Hi Pavel,

I am perfectly aware of the INotify.... interface, and I implemented it. Most probably is the known issue I will wait for the internal build.

Regards,
Tags
GridView
Asked by
Alex
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Alex
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Calin Calin
Top achievements
Rank 1
Share this question
or