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

[Solved] Help with Combobox in GridView

4 Answers 195 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
John
Top achievements
Rank 2
Iron
John asked on 30 Sep 2009, 02:13 PM
Hi,
I am having trouble with my particualr scenario. I have an Item object with the following properties...
ItemNumber, Description, CategoryID, ProductGroupID, ModifiedDate

Category and ProductGroup object has ID(long) and Description(string) properties and are "Attributes" of Item

The Attribute was added on another screen, and now I want to edit or add the association of the Attribute to the Item

I need a grid that pulls all the Items by the customer and populates the entire item if any exist to look like this

ItemNumber    Description    Category    ProductGroup        ModifiedDate
00001             my item          4                My Product Grp     09/25/09

I want comboboxes on Category and ProductGroup....On Category i want the ID of the Category Object to be displayed. On ProductGroup, I want the Product Group Description to be displayed and be able to click the cell on either to put into edit mode at which point, the combobox is displayed. The Category combobox needs to display all the Category IDs available, and the ProductGroup needs to display all the descriptions of product groups available, but when selected it needs to update the complete item with just the ids because the table for my item just contains the ids of these attributes and my constructor for item only takes the ids of the attributes being assigned. How do I create a grid to have the correct bindings to these items and how does the Item Object get updated with the correct ids?

<telerikGrid:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False" Width="Auto" HorizontalAlignment="Stretch" > 
                            <telerikGrid:RadGridView.Columns> 
                                <telerikGrid:GridViewDataColumn Header="Item #" DataMemberBinding="{Binding ItemNumber, Mode=TwoWay}" > 
                                    <telerikGrid:GridViewDataColumn.CellTemplate> 
                                        <DataTemplate> 
                                            <TextBlock Text="{Binding ItemNumber}" /> 
                                        </DataTemplate> 
                                    </telerikGrid:GridViewDataColumn.CellTemplate> 
                                    <telerikGrid:GridViewDataColumn.CellEditTemplate> 
                                        <DataTemplate> 
                                            <TextBox Text="{Binding ItemNumber, Mode=TwoWay}" /> 
                                        </DataTemplate> 
                                    </telerikGrid:GridViewDataColumn.CellEditTemplate> 
                                </telerikGrid:GridViewDataColumn> 
                                <telerikGrid:GridViewDataColumn Header="Item Description" DataMemberBinding="{Binding Description, Mode=TwoWay}" Width="*">  
                                    <telerikGrid:GridViewDataColumn.CellTemplate> 
                                        <DataTemplate> 
                                            <TextBlock Text="{Binding Description}" /> 
                                        </DataTemplate> 
                                    </telerikGrid:GridViewDataColumn.CellTemplate> 
                                    <telerikGrid:GridViewDataColumn.CellEditTemplate> 
                                        <DataTemplate> 
                                            <TextBox Text="{Binding Description, Mode=TwoWay}" /> 
                                        </DataTemplate> 
                                    </telerikGrid:GridViewDataColumn.CellEditTemplate> 
                                </telerikGrid:GridViewDataColumn> 
                                <telerikGrid:GridViewDataColumn HeaderText="Category" DataMemberBinding="{Binding CategoryId, Mode=TwoWay}" TextAlignment="Right">  
                                    <telerikGrid:GridViewDataColumn.CellTemplate> 
                                        <DataTemplate> 
                                            <TextBlock Text="{Binding CategoryId}" /> 
                                        </DataTemplate> 
                                    </telerikGrid:GridViewDataColumn.CellTemplate> 
                                    <telerikGrid:GridViewDataColumn.CellEditTemplate> 
                                        <DataTemplate> 
                                            <ComboBox DisplayMemberPath="{Binding CategoryId, Mode=TwoWay}" /> 
                                        </DataTemplate> 
                                    </telerikGrid:GridViewDataColumn.CellEditTemplate> 
                                </telerikGrid:GridViewDataColumn> 
                                <telerikGrid:GridViewDataColumn HeaderText="Product Group" DataMemberBinding="{Binding ProductGroupId, Mode=TwoWay}" TextAlignment="Right">  
                                    <telerikGrid:GridViewDataColumn.CellTemplate> 
                                        <DataTemplate> 
                                            <TextBlock Text="{Binding Description}" /> <!--need productgroup objects description here --> 
                                        </DataTemplate> 
                                    </telerikGrid:GridViewDataColumn.CellTemplate> 
                                    <telerikGrid:GridViewDataColumn.CellEditTemplate> 
                                        <DataTemplate> 
                                            <ComboBox DisplayMemberPath="{Binding Description, Mode=TwoWay}" /> 
                                        </DataTemplate> 
                                    </telerikGrid:GridViewDataColumn.CellEditTemplate> 
                                </telerikGrid:GridViewDataColumn> 
                                <telerikGrid:GridViewDataColumn HeaderText="ModifiedDate" DataMemberBinding="{Binding Date, Mode=TwoWay}">  
                                    <telerikGrid:GridViewDataColumn.CellTemplate> 
                                        <DataTemplate> 
                                            <TextBlock Text="{Binding Date}" /> 
                                        </DataTemplate> 
                                    </telerikGrid:GridViewDataColumn.CellTemplate> 
                                    <telerikGrid:GridViewDataColumn.CellEditTemplate> 
                                        <DataTemplate> 
                                            <telerikInput:RadDatePicker SelectedDate="{Binding ModifiedDate, Mode=TwoWay}" /> 
                                        </DataTemplate> 
                                    </telerikGrid:GridViewDataColumn.CellEditTemplate> 
                                </telerikGrid:GridViewDataColumn> 
                                  
                            </telerikGrid:RadGridView.Columns> 
                        </telerikGrid:RadGridView> 

I am completely lost on how to accomplish what im trying to do in both xaml and C#...

4 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 01 Oct 2009, 07:05 AM
Hi John,

The article here  demonstrates a scenario similar to yours ( with the IDs in the main table  and data displayed in the combo from a secondary table with relation by ID) .

In case you have further troubles , you may just send me your project and I will set the Combo columns for you.

Kind regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
John
Top achievements
Rank 2
Iron
answered on 01 Oct 2009, 08:11 PM
Thank! I'll give this a shot and let you know how it turns out.
0
John
Top achievements
Rank 2
Iron
answered on 05 Oct 2009, 03:43 PM
Here is a rough sample project. The MainPage.xaml.cs file is where the columns must be dynamically generated with edit templates, and bound to the grid. Please let me know if you need any more info. I left some documentation inside MainPage.xaml.cs, under the bnManageProductsA_Click event.

Thanks again for taking the time to help!

Well i tried to attach the zip file but it told me:

Incorrect file type

2MB: the max total size of all attached files
Allowed extensions: .gif, .jpg, .jpeg, .png


How can I get you the project???
0
Vlad
Telerik team
answered on 06 Oct 2009, 05:58 AM
Hi John,

Please open support ticket where you can attach bigger files.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
John
Top achievements
Rank 2
Iron
Answers by
Pavel Pavlov
Telerik team
John
Top achievements
Rank 2
Iron
Vlad
Telerik team
Share this question
or