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

GridViewComboBoxColumn - ComboBox Editor Changes all similar rows.

6 Answers 395 Views
GridView
This is a migrated thread and some comments may be shown as answers.
narim jacksimov
Top achievements
Rank 1
narim jacksimov asked on 23 Feb 2010, 09:17 AM
Hi, I've been working with Telerik controls for about 6 months.

I am having an issue where I have a RadGridView with a GridViewComboBoxColumn.  The GridViewComboBoxColumn is populated with a list of companies and the RadGridView is populated with a list of employees. 

If an employee has just been created in the system, they have default "N/A" company assigned to them until it is assigned to them using the RadGridView employees screen I am creating.  So I can have a RadGridView with 500 rows of employees and each has an "N/A" Company assigned to them. 

The issue I am having is, when I am editing the employees in the RadGridView with the GridViewComboBoxColumn, when I select a company for one employee, ALL the other rows that have "N/A" company assigned to them change to that combo box selection as well.

 peopleCardEntryGrid.MasterGridViewTemplate.AutoGenerateColumns = false
            peopleCardEntryGrid.MasterGridViewTemplate.AllowAddNewRow = false
            peopleCardEntryGrid.MasterGridViewTemplate.AllowDeleteRow = false
            peopleCardEntryGrid.MasterGridViewTemplate.AllowEditRow = true
            peopleCardEntryGrid.MasterGridViewTemplate.AllowAutoSizeColumns = true
            peopleCardEntryGrid.EnableGrouping = false
            peopleCardEntryGrid.CellValueChanged += peopleCardEntryGrid_CellValueChanged; 
 
GridViewComboBoxColumn companydLookUpColumn = new GridViewComboBoxColumn 
                                                              { 
                                                                  FieldName = "EMPLOYEE.COMP.Id"
                                                                  ValueMember = "Id"
                                                                  DisplayMember = "CompanyName"
                                                                  HeaderText = "Company"
                                                                  DataSource = _job.LoadCompanies() 
                                                              }; 
 
peopleCardEntryGrid.MasterGridViewTemplate.Columns.Add(companydLookUpColumn); 
 
IList<EMPLOYEE> employees = _job.GetEmployeeList(); 
 
IBindingList boundEmployees = new BindingList<EMPLOYEE>(employees); 
 
peopleCardEntryDataGrid.DataSource = boundEmployees; 

The above code shows that COMP is a company object that belongs to the EMPLOYEE Object.  The field name is the Id property of the Company.   "_job" is just a class that Populates and IList<T> of objects from the database and returns them to the form.

So if the employee had a default "N/A" company assigned to them the COMP.Id value would be 111.  So all new employees without a company, will actually have a default company assigned to them and that will be company Id 111, and CompanyName of "N/A".

I am attaching two screen shots of the grid which I hope will help explain the problem a little better.  This is kind of a difficult question to explain.

Thanks.



6 Answers, 1 is accepted

Sort by
0
AY
Top achievements
Rank 1
answered on 24 Feb 2010, 03:18 AM
I have the exact same problem.
0
Martin Vasilev
Telerik team
answered on 25 Feb 2010, 03:32 PM
Hi Narim,

I am not sure what exactly caused the described issue with the ComboBox column. However, you have to keep in mind that it is necessary to ensure right relation for your data. For example, you have to have a company id field in your grid data source so that you can save the chosen value to a particular record. Also, RadGridView does not support object built hierarchy (List of child objects included in parent object). Please, find more details and example on how to use ComboBox column in our documentation.

Regards,
Martin Vasilev
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
narim jacksimov
Top achievements
Rank 1
answered on 26 Feb 2010, 02:29 AM
Hi,

I am going to try to explain this better.  I really need an answer for this because this example was working perfectly when the objects contained null values instead of the duplicate default ones.  I am clearly not the only person having an issue with this.


I am not sure what exactly caused the described issue with the ComboBox column. However, you have to keep in mind that it is necessary to ensure right relation for your data. For example, you have to have a company id field in your grid data source so that you can save the chosen value to a particular record.

As my example shows I bind the FieldName  value to EMPLOYEE.COMP.Id.  My data source for the grid is a list of employees and each employee contains a single company object.  (Not a list).  The grid view combo box column is populated by a list of COMP objects.  The COMP.Id and EMPLOYEE.Comp.Id are the values used to link the two objects together.  My example above was working until I started having duplicate EMPLOYEE.Comp.Id properties in the list of the EMPLOYEE object I am binding to the RadGridView

Also, RadGridView does not support object built hierarchy (List of child objects included in parent object). Please, find more details and example on how to use ComboBox column in our documentation.

As stated above, there are no Lists of Child objects being used.  EMPLOYEE and COMP are a 1 to 1 relationship, and I am using the list of companies which I bind separately when I create the grid column.

Your help in resolving this issue is greatly appreciated.  Thank you.

0
Martin Vasilev
Telerik team
answered on 03 Mar 2010, 07:47 AM
Hi narim jacksimov,

I am afraid - since I have not seen your business objects -  I cannot  be sure what exactly causes the described issue. If you check that the relation between the grid data source and the combo box column data source is correct i.e. set using the ValueMember and FieldName properies, the ComboBoxColumn should works as expected. I have prepared a very simple sample on how to bind a grid and combo box column to custom objects. You can find it as an attachment to this message.

However , if you still experience any difficulties, please open a new support ticket and send me a small sample that demonstrates your case. This will help me investigate further and provide accurate assistance.

Kind regards,
Martin Vasilev
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
narim jacksimov
Top achievements
Rank 1
answered on 24 Apr 2010, 07:18 AM
Just wanted to let you know a few things about this issue.  I used your example and compared it to my code, building my own example and I still haven't been able to figure out as to why its happening (or replicate it) but I did notice a few things that I thought might be related.

When the user changes a combo box selection in the grid, it would only change the display text (not the actual value) of the similar rows. 

My business object collection contains duplicate objects (object with same ID but different parameters). 

I am also using Telerik Reports as a part of my solution, and I noticed that when binding the reports to a collection of business objects that contains duplicates, the reports would only display the first object for each it found in the collection.  I had to add a ROW_ID value to all my queries to act as a unique identifier in order for the report to bind and display the collection properly.

Could this be a similar issue to the one I am experiencing?  Could it be that the grid is only referencing the same business object for each duplicate row?  I would assume yes if its only updating the DisplayText. 

In spite of his issue I am still going to be purchasing your controls at the end of this month and hopefully when I get my hands on the source code I will be able to figure out (and replicate) this issue.  Thanks for all your help.
0
Martin Vasilev
Telerik team
answered on 29 Apr 2010, 09:01 AM
Hi narim jacksimov,

Again, I am not sure what exactly your scenario is, but in general you have to ensure a strong integrity in your relational data to allow ComboBox to work as expected. That means, you should have unique primary keys in your combo-box column's datasource. 

I am afraid that without a sample I can only guess what exactly causes the weird behavior in your project. Please, open a new support thread and send me a small project to allow me further assistance.

A bit off topic, please ask the person who has purchased our controls in your company to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our support ticketing system. Additionally, all your questions will be reviewed according to the license you have. More information on License Developers you can find here: www.telerik.com/account/faqs.aspx.

 
Regards,
Martin Vasilev
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.
Tags
GridView
Asked by
narim jacksimov
Top achievements
Rank 1
Answers by
AY
Top achievements
Rank 1
Martin Vasilev
Telerik team
narim jacksimov
Top achievements
Rank 1
Share this question
or