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

RadGrid - pressing enter (return) key forces refresh/rebind

4 Answers 462 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saumil
Top achievements
Rank 1
Saumil asked on 19 Sep 2011, 07:30 AM
Hi,

Radgrid details:
- I have setup only one column in the grid as a text box in item template. I need to implement something like excel, where user can enter/edit data in this cell, and press enter or down key to move to the cell on the row below.
- I have registered double click event on the row to redirect the user to a different page.

Can you please help me out with the problems below:
- On pressing enter in the cell (text box), a refresh / rebind happens. How can I avoid it? I tried putting in a default invisible button as well, but even that didn't work.
- On Double click of the cell (text box), the redirect happens. How can I avoid it? I tried having an "ondblclick" return false, but it didn't work.

Regards,
Saumil

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 19 Sep 2011, 08:15 AM
Hello Saumil,

The following code library shows the Implementation of excel like grid.
Excel-like RadGrid.

Thanks,
Princy.
0
Saumil
Top achievements
Rank 1
answered on 21 Sep 2011, 02:11 AM
Hi Princy,

Thanks for your help!

I was able to implement navigation from the example you provided, but the refresh issue was something wierd and different. I had a navigation panel on the master page, with a button on it. Even though the button was not defined as defaultbutton, the enter key was calling the button click event (this doesnot happen with content pages which don't have telerik controls like grids and panels on it). I fixed the issue by adding a button with display style as none, and using it in the rad panel as default button.

Regards,
Saumil
0
Steven
Top achievements
Rank 1
answered on 05 Jul 2012, 01:52 PM
Not sure if my issue is related or not.  My application needs to have paging and I've got that working to some extent using the rebind.  My problem is that if the enter key is used instead of tab or down arrow, the grid automatically selects the first button on the radgrid.  I've setup my grid to allow filters and after the first rebind any time the enter key is hit it triggers the drop down filter at the point on the screen that the mouse is.  If I removed the filters, the button it triggers was the first page button and moves back to the first page.

I was able to recreate this issue with the sample Telerik Excel Like Grid code (both an older version and newer version).  If I change the grid to allow filter by column and then force a rebind of the grid, I'm able to edit the grid in Excel like mode but if the enter key is hit, the filter button on the first column is fired.

I've tried debugging and tried to have the onclick javascript return false (to try and cancel the enter key) - which it did on the grid but it still fired the filter box.

My application just has one single column to edit for multiple rows so this looked like the perfect solution to avoid having to "edit" each row using the normal grid.  If I could just hit the enter button to go to the row below automatically that would be perfect - is there another way to do that if we can't get around the rebind issue?

Thanks,
Steve
0
Princy
Top achievements
Rank 2
answered on 06 Jul 2012, 03:41 AM
Hi Steven,

On pressing the enter key, filter dropdown triggers when the filter button of the first RadGrid column turns out to be the first button rendered in the form the grid resides in. That is why it is set as the form's default (submit) button. In order to work around this, you can declare an invisible inactive button and set it to be the default one.

ASPX:
<form id="form1" defaultbutton="Button2" runat="server">
<asp:Button ID="Button2" runat="server" Text="" style="display: none;" OnClientClick="return false;" />

Thanks,
Princy.
Tags
Grid
Asked by
Saumil
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Saumil
Top achievements
Rank 1
Steven
Top achievements
Rank 1
Share this question
or