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

How to set selected item to new row on insert button click event

4 Answers 314 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Swathi
Top achievements
Rank 1
Swathi asked on 17 Jan 2011, 11:01 AM
Hi 
Please  let me know how to set new row as selected item of the grid through AddingNewDataItem event as early as possible

Swathi.

4 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 17 Jan 2011, 05:01 PM
Hi Swathi,

 
You mause use ScrollIntoViewAsync method of RadGridView to scroll and to select the newly added item within AddingNewDataItem event of RadGridView:

private void RadGridView_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
{
    // TODO: Add event handler implementation here.
    var gridView=e.OwnerGridViewItemsControl;
    this.gridView.ScrollIntoViewAsync(this.gridView.Items[this.gridView.Items.Count - 1], //the row
                         this.gridView.Columns[this.gridView.Columns.Count - 1], //the column
                         new Action<FrameworkElement>((f) =>
                         {
                            (f as GridViewRow).IsSelected = true; // the callback method
                         }));
     
}

Regards,
Vanya Pavlova
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Swathi
Top achievements
Rank 1
answered on 18 Jan 2011, 06:02 AM
Hi ,
Many Thanks for the reply.
I still have an issue to use the code you have suggested.
When i click on new row button row is getting added on the top instead of bottom.
        can you suggest me how to get new row at botttom so that i can set the isselected property for the new row

Swathi.

0
gureumi
Top achievements
Rank 1
answered on 10 Jun 2011, 06:14 PM
1. Where can I reach the answer without questioning in this forum?
I am talking about specifically which part of the documentation. Because in addition to the practical answer given here, I'd like to understand better about class hierarchy of WPF tool form Telerik.

2. Is there any reason for deciding not to have this behavior as default for RadGridView_AddingNewDataItem()?
It seems a bit counterintuitive.
Especially when we use 'CanUserInsertRows' property is set to 'true' and 'SelectionMode' is 'Single'.


0
Vanya Pavlova
Telerik team
answered on 14 Jun 2011, 07:39 AM
Hello Gureumi,

 
Please refer to our online documentation for further info. 


Greetings,
Vanya Pavlova
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
Tags
GridView
Asked by
Swathi
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Swathi
Top achievements
Rank 1
gureumi
Top achievements
Rank 1
Share this question
or