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

Group Header Key Intercept

2 Answers 45 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 04 Jan 2013, 03:55 PM

Using: SL5 with Telerik controls v2012.2.912.1050

I'm attempting to use a RadGridView to present a fully interactive edit window honoring specific grouping elements.  The caveat is that the group headers are also editable.  The template for the header looks like so:
<Telerik:RadGridView.GroupHeaderTemplate>

    <DataTemplate>
        <TextBox Text="{Binding Path=Header, Mode=TwoWay}"
                 DataContext
="{Binding Path=Group.Key}"
                
MaxLength="1000" />
    </DataTemplate>
</telerik:RadGridView.GroupHeaderTemplate>

The problem posed is that when editing the Header value, I cannot use the space character.  It seems that the group header is intercepting the key stroke and not allowing it to tunnel down to the text box.  The effect of presssing space in this textbox is a toggling of the visibility of the group's children.  Do you have any suggestions to remedy this behavior so that the Textbox takes prescedence on input?

Thanks,
-Ryan

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 04 Jan 2013, 04:19 PM
Hi Ryan,

I can suggest you to add handler to the KeyDown event of the page and perform some additional logic there:

private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Space)
    {
        var tb = sender as TextBox;
        if (tb != null)
        {
            int selStart = tb.SelectionStart;
            tb.Text = tb.Text.Insert(tb.SelectionStart, " ");
            tb.SelectionStart = selStart + 1; //put the caret back in the right place
            e.Handled = true;
        }
    }
}

That way the TextBox will accept the "Space". Please let me know how this works for you.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ryan
Top achievements
Rank 1
answered on 04 Jan 2013, 04:35 PM
This works perfectly.  Thank you.
Tags
GridView
Asked by
Ryan
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or