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

CellEditEnded from extended GridViewColumn

1 Answer 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 10 Jan 2012, 08:28 PM
I'm extending a GridViewComboBoxColumn, setting IsComboBoxEditable to true, and trying to provide code to add typed text as items into the ItemsSource collection.

I hooked the CellEditEnded event of the GridView and added some test code to play with this idea:

private void TestGrid_CellEditEnded(object sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e)
{
    var comboBoxColumn = e.Cell.Column as Telerik.Windows.Controls.GridViewComboBoxColumn;
   
    // only continue if its a cell for the column we're interested in
    if ((comboBoxColumn == null) || (comboBoxColumn.UniqueName != "Lookup"))
        return;

    // get back the object used to represent the row
    var gridItem = e.Cell.DataContext as GridItem;
           
    // only continue if the text typed is not in the list
    if (gridItem.SelectedLookupItem != null)
        return;

    var cellComboBox = (RadComboBox)e.EditingElement;
    var lookupItemCollection = cellComboBox.ItemsSource as ObservableCollection<LookupItem>;

    var newItem = new LookupItem() { Name = cellComboBox.Text };
    lookupItemCollection.Add(newItem);

    //set the typed item as the selected item
    gridItem.SelectedLookupItem = newItem;
}

Works great. Now I want to move that code into my extended GridViewComboBoxColumn. How could I hook/override the CellEditEnded from inside the extended column?

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 12 Jan 2012, 08:41 AM
Hello,

 You could override the appropriate methods of GridViewColumnBase so that to achieve the same functionality.
Please review how you could use them, particularly the CreateCellEditElement and UpdateSourceWithEditorValue methods.

Greetings,
Didie
the Telerik team

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

Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or