How to use keyboard arrow keys for navigation

5 posts, 0 answers
  1. Juan
    Juan avatar
    13 posts
    Member since:
    Jun 2010

    Posted 11 Nov 2010 Link to this post

    Hi!
    I am using TreeListView Q2 2010. I can't find in documentation how to use keyboard arrow keys for navigation. Can you give an example ?

    I also want TreeListView to input 0 in int field when its value is deleted. Because now validator shows error when no value is entered in a field.

    Thanks in Advance.
    Juan.
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 11 Nov 2010 Link to this post

    Hi Juan,

    You can use the Up / Down / Left / Right arrows to navigate in RadTreeListView. You can test this in our online demo.

    As for your second question - you can subscribe to the CellValidating event and define its handler as below:

    private void clubsGrid_CellValidating(object sender, GridViewCellValidatingEventArgs e)
    {
        if (e.Cell.Column.Header.ToString() == "Stadium" && e.NewValue == "")
        {
            (e.Row.DataContext as Club).StadiumCapacity = 0;
            e.IsValid = true;
        }
    }

    Hope this helps.

    Greetings,
    Veselin Vasilev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Juan
    Juan avatar
    13 posts
    Member since:
    Jun 2010

    Posted 11 Nov 2010 Link to this post

    Hi Veselin,
    I've seen your demo and navigition works fine. But i've forgotten to mention that I also have to made a certain cell active for editing in selected row when I use arrow keys for navigation. I am not sure which event handler should I use for it. Will it affect the selection of next row's  cell on Enter button ?

    I've set breakpoints in  CellValidating event handler but they don't fire. It seems that it doesn't work.
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 17 Nov 2010 Link to this post

    Hi Juan,

    You can easily override the default behavior of the special keys like Enter. You can check this help topic which targets RadGridView, but as you probably know RadTreeListView inherits GridViewDataControl, so the approach will work there as well.

    Best wishes,
    Veselin Vasilev
    the Telerik team
    See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
  6. Juan
    Juan avatar
    13 posts
    Member since:
    Jun 2010

    Posted 23 Nov 2010 Link to this post

    Hi Veselin,

    It's turned out that some additional code is required to make it work.
    i've added this to your code:

    e.Cell.Value = 0;
    TextBox tb = (TextBox)e.EditingElement;
    tb.Text = "0";
    e.Handled = true;

    Thanks for help.
    Juan

    TextBox tb = (TextBox)e.EditingElement;
                        //if (tb.Text == "") 
                            tb.Text = "0";
                        e.Handled = true;
    TextBox tb = (TextBox)e.EditingElement;
                        //if (tb.Text == "") 
                            tb.Text = "0";
         TextBox tb = (TextBox)e.EditingElement;
                            tb.Text = "0";
                        e.Handled = true;

Back to Top
DevCraft banner