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

Altering behavior of grid/editors

3 Answers 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 09 Jun 2009, 11:38 AM
Hi,

I want to achieve following behavior of RadGridView. I have grid with some 6 columns and preloaded rows. User is suppose to edit 2 columns in these rows. Other columns are read-only. One of editable columns is multi-column combo box.

User wants to edit rows one by one, going through values in that combo column using following approach:

edit (by writing value, e.g. 'X' or 'N' into combo) - down arrow (to move to next row) - edit - down arrow

However, default behavior of combo is that once user presses down arrow (or up arrow for that matter), it just lists through values of combo (dropdown) an/or displays dropdown. I want to change that and use up/down arrows just for moving up/down the grid's row collection.

I've tried hooking up on numerous events of grid, editor (multi-combo column), but with no result. Closest I've been was when I called grid.EndEdit() in grid's ValueChanged event handler. Problem with this is that it works only when user always enters value to the column (i.e. presses 'X' or 'N'), otheriwse down arrows just selects next value in the list, then editing ends. Another problem with this 'solution' is that when default value in the column is 'N' and user enters it, presses 'N', ValueChanged event isn't notified and down arrow moves to next value just as if he didn't press the 'N' before.

I need to solve this ASAP as it is very important for the client not to have press more keys then there is necessary (understand VALUE - MOVE). I know it is possible by VALUE - ENTER - MOVE, but that ENTER is what bothers my client and subsequently me too.

I'll be glad if you give me hints where to look and what to change.

Thanks a lot

Daniel

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 10 Jun 2009, 12:33 PM
Hi Daniel,

If I understand your requirement correctly, you want to change the default multi-column combo box behavior and when pressing Down key to navigate to the next row. This is possible by handling KeyDown event of RadMultiColumnComboBoxElement. Here is a sample:

void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) 
    RadMultiColumnComboBoxElement editor = this.radGridView1.ActiveEditor as RadMultiColumnComboBoxElement; 
    editor.KeyDown += new KeyEventHandler(editor_KeyDown); 
 
void editor_KeyDown(object sender, KeyEventArgs e) 
    if (e.KeyCode == Keys.Down) 
    { 
        RadMultiColumnComboBoxElement editor = (RadMultiColumnComboBoxElement)sender; 
        editor.KeyDown -= new KeyEventHandler(editor_KeyDown); 
        this.radGridView1.EndEdit(); 
        this.radGridView1.GridNavigator.SelectNextRow(1, falsefalse); 
    } 

Should you have any questions, I will be glad to answer.

Best wishes,
Jack
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
Daniel
Top achievements
Rank 1
answered on 10 Jun 2009, 05:12 PM
Hi Jack, the only problem with this solution is that down key before it navigates to next row also changes value in the column to next value in the list. I've tried setting 

e.SuppressKeyPress =

true;

but it has no effect. Any idea how to solve this? If we manage to do it, it'll be it.

Thx so far

Daniel

 

 

 

 

 

0
Jack
Telerik team
answered on 11 Jun 2009, 08:02 AM
Hi Daniel,

Perhaps using the little trick below will do the job. You should call SelectPreviousRow method for the multi column combo box. Please check the code snippet below:

void editor_KeyDown(object sender, KeyEventArgs e) 
    if (e.KeyCode == Keys.Down) 
    { 
        RadMultiColumnComboBoxElement editor = (RadMultiColumnComboBoxElement)sender; 
        editor.KeyDown -= new KeyEventHandler(editor_KeyDown); 
        editor.EditorControl.GridNavigator.SelectPreviousRow(1, falsefalse); 
        this.radGridView1.EndEdit(); 
        this.radGridView1.GridNavigator.SelectNextRow(1, falsefalse); 
    }  

If you need further assistance, please write me back.

All the best,
Jack
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
Daniel
Top achievements
Rank 1
Answers by
Jack
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or