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

Cell Editing Combo Box Changes All Rows

9 Answers 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Etienne
Top achievements
Rank 1
Etienne asked on 16 Mar 2009, 12:13 PM

Hi,

I have a grid that i am populating Programmatically. I create the Columns and add them in code. I have changed the edit type of one of the columns to use a combo box. Everything works cool and the grid loads and the combo box on the cell is populated. The problem comes in when selecting a value in the combobox. That selected value updates not only the current cell, butt all cells of the column in the other rows.

P.S.

It seems like it updates all cell with a similar value before the change.

If anybody can help with this i would be every gratefull. I have been trying to sort this problem out for the last week. 

Below is the code in my app. 

    DataGridResults.AutoGenerateColumns = false;

            GridViewDataColumn columnID = new GridViewDataColumn();

            columnID.DataType = typeof(string);

            columnID.UniqueName = "ID";

            columnID.DataMemberPath = "ID";

            columnID.HeaderText = "ID";

            columnID.IsVisible = false;

            GridViewDataColumn columnBarcode = new GridViewDataColumn();

            columnBarcode.DataType = typeof(string);

            columnBarcode.UniqueName = "Barcode";

            columnBarcode.DataMemberPath = "Barcode";

            columnBarcode.HeaderText = "Barcode";

    GridViewDataColumn columnStatus_ID = new GridViewDataColumn();

            columnStatus_ID.DataType = typeof(string);

            columnStatus_ID.UniqueName = "Status";

            columnStatus_ID.DataMemberPath = "Status.Name";

            columnStatus_ID.HeaderText = "Status";

            columnStatus_ID.Width = new System.Windows.GridLength(200);

      DataGridResults.Columns.Add(columnID);

            DataGridResults.Columns.Add(columnBarcode);

            DataGridResults.Columns.Add(columnName);

    DataGridResults.Columns.Add(columnStatus_ID);

            //Status Combo and Column

            ComboBoxEditorSettings comboBoxEditorSettings = new ComboBoxEditorSettings();

            Granite.Objects.Status _stat = new Granite.Objects.Status();

            comboBoxEditorSettings.ItemsSource = _stat.GetAll(Granite.Objects.AppliesTo.LOCATION);

            comboBoxEditorSettings.DisplayMemberPath = "Name";

            comboBoxEditorSettings.SelectedValuePath = "Name";

            ((GridViewDataColumn)DataGridResults.Columns["Status"]).EditorSettings = comboBoxEditorSettings;


9 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 18 Mar 2009, 01:32 PM

Hi Etienne,

I have been trying to reproduce the problem here, but with no success so far.  
Can you please attach a project or a piece of code to help me reproduce the issue?  What I need to know actually is the kind of data you bind to, the way you bind and the way you update the data.

Best wishes,

Pavel Pavlov
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Etienne
Top achievements
Rank 1
answered on 20 Mar 2009, 07:41 AM
Hi,
Below is code that reproduces the issue.
All you need is a Window or UserControl (i have a User Control) that has a RadGridView on Named "DataGridResults"

Hope you get the problem reproduced.

    //Setup Columns
            DataGridResults.AutoGenerateColumns = false;

            GridViewDataColumn _columnID = new GridViewDataColumn();
            _columnID.DataType = typeof(string);
            _columnID.UniqueName = "ID";
            _columnID.DataMemberPath = "ID";
            _columnID.HeaderText = "ID";
            _columnID.IsVisible = true;

            GridViewDataColumn _columnCode = new GridViewDataColumn();
            _columnCode.DataType = typeof(string);
            _columnCode.UniqueName = "Code";
            _columnCode.DataMemberPath = "Code";
            _columnCode.HeaderText = "Code";
            _columnCode.IsVisible = true;

            GridViewDataColumn _columnStatus = new GridViewDataColumn();
            _columnStatus.DataType = typeof(string);
            _columnStatus.UniqueName = "Status";
            _columnStatus.DataMemberPath = "Status.Name";
            _columnStatus.HeaderText = "Status";
            _columnStatus.IsVisible = true;

            DataGridResults.Columns.Add(_columnID);
            DataGridResults.Columns.Add(_columnCode);
            DataGridResults.Columns.Add(_columnStatus);


            //Status Combo and Column
            ComboBoxEditorSettings comboBoxEditorSettings = new ComboBoxEditorSettings();
            List<ClassOfStatusObject> _listOfStatus = new List<ClassOfStatusObject>();

            ClassOfStatusObject _item;
            _item = new ClassOfStatusObject() { ID = "1", Name = "Status1", Description = "Status Description 1" };
            _listOfStatus.Add(_item);
            _item = new ClassOfStatusObject() { ID = "2", Name = "Status2", Description = "Status Description 2" };
            _listOfStatus.Add(_item);
            _item = new ClassOfStatusObject() { ID = "3", Name = "Status3", Description = "Status Description 3" };
            _listOfStatus.Add(_item);

            comboBoxEditorSettings.ItemsSource = _listOfStatus;

            comboBoxEditorSettings.DisplayMemberPath = "Name";
            comboBoxEditorSettings.SelectedValuePath = "Name";
            ((GridViewDataColumn)DataGridResults.Columns["Status"]).EditorSettings = comboBoxEditorSettings;

            //Data Population
            List<ClassOfDataObject> _list = new List<ClassOfDataObject>();
            ClassOfDataObject _data;
            ClassOfStatusObject _dataStatus;

            _dataStatus = new ClassOfStatusObject() { ID = "1", Name = "Status1", Description = "StatusDescription1" };
            _data = new ClassOfDataObject() { ID = "1", Code = "test1", Status = _listOfStatus[0] };
            _list.Add(_data);

            _dataStatus = new ClassOfStatusObject() { ID = "2", Name = "Status2", Description = "StatusDescription2" };
            _data = new ClassOfDataObject() { ID = "2", Code = "test2", Status = _listOfStatus[0] };
            _list.Add(_data);

            _dataStatus = new ClassOfStatusObject() { ID = "3", Name = "Status3", Description = "StatusDescription3" };
            _data = new ClassOfDataObject() { ID = "3", Code = "test3", Status = _listOfStatus[0] };
            _list.Add(_data);

            DataGridResults.ItemsSource = _list;

Hope to hear from you guys soon.
Kind Regards.

0
Pavel Pavlov
Telerik team
answered on 20 Mar 2009, 04:26 PM
Hello Etienne,

The code you provided  populates each cell in the Status column with the same instance:

_listOfStatus[0]

So when you change it in one cell, the expected behaviour in this case is the other cells to update with the same value. The reason is that they are all displaying the same instance or in other words all the cells in the status column point to one and the same object in memory.

Best wishes,

Pavel Pavlov
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Etienne
Top achievements
Rank 1
answered on 23 Mar 2009, 06:25 AM
Hi

I understand, but what i have found in the interrim is that if you change the code to read  "_columnStatus.DataMemberPath = "Status";"
then it works without updating all the records. Even if the instances are the same.

My actual data that i use has an object within an object and the above problem needs to be resolved or i will have to redesign the interface or find a different control.

If you could try and give me a work around i would be forever gratefull.

Kind Regards
0
Pavel Pavlov
Telerik team
answered on 25 Mar 2009, 01:38 PM
Hello Etienne,

Please set

_columnStatus.DisplayMemberPath= "Status.Name"

and

_columnStatus.DataMemberPath = "Status"

I believe this will fix the trouble . The code above tells the RadGridView : "Display the name of the status , but update the whole status object rather than just the name".

Regards,

Pavel Pavlov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Etienne
Top achievements
Rank 1
answered on 26 Mar 2009, 06:23 AM
Hi,

I am pretty sure that the last reply will sort my problem out.
I have tried to use the code provided, but there is no DisplayMemberPath property linked to the GridViewDataColumn object.
There is one linked to the ComboBoxEditorSettings though and that is already set.

I am sorry if i missed the obvious.

Cheers.


0
Pavel Pavlov
Telerik team
answered on 30 Mar 2009, 12:05 PM

Hi Etienne,

Please excuse me for the inconvenience caused. It seems I have tested with an internal build of the RadGridView. You are right - indeed the property mentioned is not available publicly available. We are clearing some problems with editors and the fixed version with the property available publicly will be shipped around April/08/2009 with the Service Pack Q1 release.

I understand that this issue may slow down or stop your project development , that is why I am sending a small sample to you. If you find the approach applicable to your scenario please use it till we ship the service pack . We will do our best to ease the implementation and make it achievable with just few lines of code.

*Please note that the data used to populate the combobox implements INotifyPropertyChanged. ( it is needed for the proper functioning of the update logic for the cell value).

Best wishes,

Pavel Pavlov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Etienne
Top achievements
Rank 1
answered on 05 May 2009, 08:11 AM
Hi,

I have just downloaded the latest build and also the latest internal trial and there is still no DisplayMemberPath property linked to the GridViewDataColumn object.
I would like to know if this is going to get sorted anytime soon as this is actually holding back the development process on my side.
The solution provided on the last reply does not really sort the problem out.

If you could let me know what ( if any ) timeframe i am looking at.

Kind Regards

0
Pavel Pavlov
Telerik team
answered on 05 May 2009, 02:32 PM

Hello Etienne,

The latest build includes a new type of column - GridViewComboBox column. 
It  has the full set of "lookup" properties including DisplayMemberPath. I hope it will fit in your scenario.

I am attaching a sample project to illustrate a way to use it .

Best wishes,

Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Etienne
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Etienne
Top achievements
Rank 1
Share this question
or