This question is locked. New answers and comments are not allowed.
Nishad Pillai
Top achievements
Rank 1
Nishad Pillai
asked on 21 Oct 2009, 09:06 AM
Like the insert key functionality to insert new row in teleric gridview ,is there any functionality to invoke the delete key on a teleric grid view row in silverlight instead of the context menu.Expect for a postive reply.
Thanks in advance
Thanks in advance
4 Answers, 1 is accepted
0
Jax
Top achievements
Rank 2
answered on 21 Oct 2009, 02:32 PM
Handle the KeyUp event on the grid, and do the delete action there:
private void Grid_KeyUp(object sender, KeyEventArgs e)
{
//if the user presses the delete button, then delete the currently selected records
if (e.Key == Key.Delete)
{
//psuedocode...
Grid.Items.Remove(Grid.SelectedItem);
return;
}
}
private void Grid_KeyUp(object sender, KeyEventArgs e)
{
//if the user presses the delete button, then delete the currently selected records
if (e.Key == Key.Delete)
{
//psuedocode...
Grid.Items.Remove(Grid.SelectedItem);
return;
}
}
0
Nishad Pillai
Top achievements
Rank 1
answered on 22 Oct 2009, 06:06 AM
thanks for your reply jax.But to get the keyup event we have to click in the cell.I need to get the event after selecting the entire row and pressing the delete button.I checked with key up event for the row,it wiil not get fired.
0
sreeraj
Top achievements
Rank 2
answered on 13 Jan 2010, 02:37 PM
Hi Nishad,
Me too facing the same issue . I am surprised to see why this basic feature is not supported by telerik.
The grid is not firing key events until we do it at the cell level.
Regards
Sreeraj
Me too facing the same issue . I am surprised to see why this basic feature is not supported by telerik.
The grid is not firing key events until we do it at the cell level.
Regards
Sreeraj
0
Hi guys,
I believe you may use the following code snippet. RadGridView here is bound to a List<Person> collection.
If you bind to a collection capable of change notifications ( e.g. ObservableCollection) you may ommit the .Rebind() call.
All the best,
Pavel Pavlov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I believe you may use the following code snippet. RadGridView here is bound to a List<Person> collection.
If you bind to a collection capable of change notifications ( e.g. ObservableCollection) you may ommit the .Rebind() call.
public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); this.RadGridView1.ItemsSource = Person.GetSampleListOfPersons(); this.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(MouseDownOnCell), true); } private void MouseDownOnCell(object sender, KeyEventArgs args) { if (args.Key == Key.Delete && this.RadGridView1.SelectedItem!= null) { ((List<Person>)this.RadGridView1.ItemsSource).Remove((Person)this.RadGridView1.SelectedItem); this.RadGridView1.Rebind(); } } }All the best,
Pavel Pavlov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.