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

Losing values when cell loses focus

15 Answers 280 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Kucharski
Top achievements
Rank 1
David Kucharski asked on 10 Jul 2012, 07:48 PM
I have a RadGridView in my xaml. It allows an insert row every time. It has 3 columns, 1 combo boxes and 2 data columns. The combo box I bind to a source in my ViewModel. I do get the entries I expect. When I click on an entry in the combo box and tab off, I lose what I just selected. When I enter information into either of the 2 data columns and tab off the cell, I lose the information. What am I missing?

<telerik:RadGridView x:Name="demographicList" ShowGroupPanel="False" ShowInsertRow="True" Height="300" Width="800" AutoGenerateColumns="False">
    <telerik:RadGridView.Columns>
        <telerik:GridViewComboBoxColumn Header="Name" ItemsSource="{Binding DemographicsList}" DisplayMemberPath="Demographic" DataMemberBinding="{Binding DemographicID}" SelectedValueMemberPath="DemographicID" UniqueName="DemographicsName" />
        <telerik:GridViewDataColumn Header="Value 1" UniqueName="Value1" />
        <telerik:GridViewDataColumn Header="Value 2" UniqueName="Value2" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

15 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 11 Jul 2012, 05:58 AM
Hi,

May I ask you to check this help article about GridViewComboBoxColumn and try the approach suggested there? 

As to your question related to the two data columns, I do not see their DataMemberBinding set. Would you please share more details on how are they bound?

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
David Kucharski
Top achievements
Rank 1
answered on 11 Jul 2012, 01:46 PM
Didie

I am a little confused by your response in regards to the GridViewComboBoxColumn. I do not have empty cells when I click in the cell and the drop-down shows. It is after I choose an entry in the drop-down and then tab away from that cell. The selection no longer appears to the user. It is still in the drop-down but is no longer selected.

Thanks and let me know.
0
Dimitrina
Telerik team
answered on 11 Jul 2012, 02:17 PM
Hi,

 I apologize for this misunderstanding. I am still not able to reproduce such an issue locally. May I ask you to check whether you have set the appropriate settings as suggested in our documentation about GridViewcomboBoxColumn? Do you have a property "DemographicID" defined for the objects in the "DemographicsList" collection? If you have such a property, would it be possible for you to isolate the issue in a demo project which we could debug locally?

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
David Kucharski
Top achievements
Rank 1
answered on 11 Jul 2012, 04:07 PM
Didie,

If we can, I would like to take a step back and describe what I am trying to do.

My grid view will have 4 columns. 2 with gridviewcomboboxcolumns and 2 with gridviewdatacolumns.

The 2 columns with the comboboxes, I want to have the ItemsSource to 2 different ObservableCollections that consist of 2 different Models.

Example of Demographics Model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.ComponentModel;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Events;
using System.Diagnostics;
  
namespace Geomentum.MediaReach.Infrastructure.Models
{
    public class DemographicsModel
    {
        private int _demographicID = 0;
        private string _demographic = "";
  
        public int DemographicID
        {
            get { return _demographicID; }
            set
            {
                _demographicID = value;
            }
        }
        public string Demographic
        {
            get { return _demographic; }
            set
            {
                _demographic = value;
            }
        }
  
    }
}

I then call a function that in turn calls a wcf service to populate the ObservableCollection of the DemographicsModel
private void LoadDemographics()
{
    DemographicsServiceClient service = new DemographicsServiceClient();
    service.GetDemographicsCompleted += new EventHandler<GetDemographicsCompletedEventArgs>(DisplayDemographics);
    service.GetDemographicsAsync();
}
void DisplayDemographics(object sender, GetDemographicsCompletedEventArgs e)
{
    this.DemographicsList.Clear();
    DemographicsDetails serviceResponse = e.Result;
    ObservableCollection<DemographicsModel> oc;
    oc = new ObservableCollection<DemographicsModel>(serviceResponse.DemographicsDetail.DemographicsDetails);
    this.DemographicsList = oc;
    OnPropertyChanged("DemographicsList");
}

At this point when the program runs, the system goes through these functions and populates the grid. I click on the line that states 'Click here to add new item'. The line clears and a click in the first cell. I see my drop down of Demographic entries. I click on one and then tab to the next cell. My selection is unselected and the cell is blank. (It still has all the entries.)

Now the other wrinkle to what I am trying to do. I want the gridview to have a seperate ItemsSource that will be a different ObservableCollection filled with a different Model. This Model will also have a DemographicID as a property. This model will be filled in with saved information so that when the user comes back to the page, they should see the lines they previously entered, with the Demographic value they previously selected, automatically selected. That way they can change if needed or leave it the same. Can this be done. Can this be done?
0
David Kucharski
Top achievements
Rank 1
answered on 11 Jul 2012, 04:50 PM
Didie,

I have a small application that I can send you to show you the behaviour. It is a zip file that is 13mb. How do I get it to you?
0
Dimitrina
Telerik team
answered on 11 Jul 2012, 04:54 PM
Hi,

 You can open a support thread and attach it there. It would be better if you clean it from all the code not related to the problem so that we could concentrate on the problem.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
David Kucharski
Top achievements
Rank 1
answered on 11 Jul 2012, 05:09 PM
Didie,

If you are interested and have access, I just submitted a Support Thread with the following as my ticket number.


564244
0
David Kucharski
Top achievements
Rank 1
answered on 11 Jul 2012, 07:47 PM
Didie,

I might have found part of the issue. I was never setting the ItemsSource of the gridview to a source. In the test application I create another object that had 3 properties: DemographicID, Value1, Value2. I created 5 objects and added them to an ObservableCollection. Upon running the program, it looks like my grid is populated correctly with the objects and their values and the selections in the 1st column (combo box) are selected correctly. You see 5 rows in the gridview.

Here is the issue still: When it first comes up the columns that are combo boxes don't show anything to the user, but upon hightlighting one of the cells all 5 show the correct selections. I then tab off of the cell and all 5 disappear again, but do retain any changes. So I guess my question is why is the information only showing when I click in the cell or on a row header?

I have attached screen prints.
0
Dimitrina
Telerik team
answered on 12 Jul 2012, 12:39 PM
Hello,

Thank you for that update.

Please, lets continue the further communication into the support thread. 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Madhu
Top achievements
Rank 1
answered on 19 Feb 2013, 02:14 PM
Hi,

Any response for this ticket # 564244, even I have the same issue and no where I get the answer in any blogs.

If you hear from any one or if you resolve the issue could you please share the solution. It would be great help.

Thank You,
Madhu Rao
mrao0179@gmail.com
0
Dimitrina
Telerik team
answered on 19 Feb 2013, 02:23 PM
Hello,

In the support thread I suggested him to predefine the CellTemplate for the column and place a ComboBox as a DataTemplate. Then set its ItemsSource appropriately.
Hopefully that way the values will be populated as expected.
 

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Madhu
Top achievements
Rank 1
answered on 19 Feb 2013, 02:29 PM
Thank You for the response,

 Can you share some code snippet please.

Regards,
Madhu Rao
0
Dimitrina
Telerik team
answered on 19 Feb 2013, 02:32 PM
Hello,

You can check this help article on how to predefine the CellTemplate for a column. Then you should configure the ComboBox having in mind that the DataContext for it will be the data item bound for the parent GridViewRow.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Samra
Top achievements
Rank 1
answered on 16 Jun 2017, 03:47 AM

I am facing the same issue. Did you get this working?

0
Dinko | Tech Support Engineer
Telerik team
answered on 20 Jun 2017, 11:46 AM
Hi Samra,

Can you confirm that you have tried the approaches suggested from Dimitrina? It will be great if you can send us isolated project from your application reproducing this behavior. This way we can directly investigate it on our side.

Regards,
Dinko
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
David Kucharski
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
David Kucharski
Top achievements
Rank 1
Madhu
Top achievements
Rank 1
Samra
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or