ComboBoxColumn not editable

3 posts, 0 answers
  1. Josiah
    Josiah avatar
    3 posts
    Member since:
    Jan 2017

    Posted 03 Feb 2017 Link to this post


    I have a RadDataGrid with a ComboBoxColumn populated from a list of integers. Both the ItemsSource of my grid and the ItemsSourcePath of my ComboBoxColumn are dynamically populated from a database. I have set the SelectedValuePath and PropertyName of the column so that the default value is also dynamically chosen. The default values are populating as expected, however, when I try to edit a row, which would open the dropdown, I get an exception and an attached debugger is called.

    Here is my grid:

      ItemsSource="{Binding SpecialLocations}">
                         Header="Department #" />

    And here is my code:

    // In the DataContext of the page
    private ObservableCollection<AuditLocationViewModel> _specialLocations;
    public ObservableCollection<AuditLocationViewModel> SpecialLocations
        return _specialLocations;
        SetProperty(ref _specialLocations, value);
    // This method is called in the constructor of the page the grid sits in
    public async Task LoadSpecialLocationsData()
      _specialLocations = new ObservableCollection<AuditLocationViewModel>();
      var auditAccountDepartments = await AuditAccountDepartmentDataSource.AuditAccountDepartmentSyncTable.Select(n => new { n.AuditAccountDepartmentId, n.DepartmentNumber }).OrderBy(o => o.DepartmentNumber).ToListAsync(); // grab from db
      var auditLocationDetails = await AuditLocationDataSource.AuditLocationSyncTable.Select(n => new { n.AuditAccountDepartmentId }).ToListAsync(); // grab from db
      for (int i = 0; i < auditLocationDetails.Count; i++)
        AuditLocationViewModel auditLocations = new AuditLocationViewModel();
        Guid auditAccountDepartmentId = auditLocationDetails[i].AuditAccountDepartmentId;
        auditLocations.DepartmentNumber = auditAccountDepartments.Where(a => a.AuditAccountDepartmentId == auditAccountDepartmentId).Select(d => d.DepartmentNumber).First(); // set DepartmentNumber for this row
        auditLocations.DepartmentNumbers = auditAccountDepartments.Select(d => d.DepartmentNumber).ToList(); // DepartmentNumbers is just the list of all the values of DepartmentNumber in the db
      SpecialLocations = _specialLocations;
    // And finally, my object of the collection
    public class AuditLocationViewModel : ViewModelBase
      public int DepartmentNumber { get; set; }
      public List<int> DepartmentNumbers { get; set; }

    My question is, basically, why am I getting an exception when I try to open the dropdown and edit? In addition, am I using the SelectedValuePath and PropertyName properties of the ComboBoxColumn correctly?

    Thank you,


  2. Ves
    Ves avatar
    2926 posts

    Posted 08 Feb 2017 Link to this post

    Hi Josiah,

    I can confirm, that we were able to replicate an issue in a scenario like yours. While we investigate the possible fixes and a new build is released, please use the following workaround - wrap the ComboBox's ItemsSouce strings in objects and set SelectedValuePath property of the DataGrdiComboBoxColumn with the name of the property, holding the actual string.

    E.g. populate DepartmentNumbers in the viewmodel like this:

    auditLocations.DepartmentNumbers = auditAccountDepartments.Select(d => new MyData() { deptN = d.DepartmentNumber}).ToList();

    This way, the value for SelectedValuePath would be "deptN"

    I have attached an example to demonstrate this.

    Best regards,
    Telerik by Progress
    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 Feedback Portal and vote to affect the priority of the items
  3. Josiah
    Josiah avatar
    3 posts
    Member since:
    Jan 2017

    Posted 09 Feb 2017 in reply to Ves Link to this post

    Thanks, Ves. I've got it working now. Much appreciated.
Back to Top