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

GridHyperlinkColumn or GridButtonColumn

2 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 05 Oct 2012, 04:19 PM
Hi,

I have a RadGrid that is created dynamically in the code-behind file from the Page_Init event stage, so everything is constructed here.

The grid contains several columns of data, and three hyperlink columns on the far right side of the grid. Each has a javascript function assigned to the NavigateUrl property in the ItemDataBound event handler in the code behind page.

I need to capture the onkeypress javascript event when the user tabs past the last column in the row being edited to trigger an ajax postback so the row being added can be processed and added to the grid's underlying datasource, and a new row automatically added to the end of the grid.

I have no problems getting this behavior out of a GridBoundColumn or a GridDropdownColumn by assigning the onkeypress javascript event to the edit controls in those columns, but cannot get it to work with the hyperlink controls.

I had zero luck in getting the GridHyperlinkColumn to capture the Tab key. Pressing the Tab key simply moved the focus from this control to the next control (in this case, the address bar).

So, then I thought I'd use the GridButtonColumn, using a LinkButton as the button type. I got the onkeypress event to fire when pressing the Enter key, but not the Tab key. The other problem I noticed is that if I set the ShowInEditForm property to true, then the buttons do not render for the GridDataItems (rows not being edited), and if I do not set the ShowInEditForm property, they do not render in the row being edited. I cannot figure out how to get the buttons to display in BOTH types of rows.

Is what I am wanting to accomplish even possible? Optimally, I would like to get the GridHyperlinkColumn to work as I describe above, but I cannot figure out how to get the rendered hyperlink to behave as expected.

2 Answers, 1 is accepted

Sort by
0
Charles
Top achievements
Rank 1
answered on 05 Oct 2012, 04:22 PM
Also note: I've also tried creating a GridTemplateColumn dynamically using a LinkButton as the underlying control in both the ItemTemplate and the EditItemTemplate containers, but this control behaves even worse as it always renders a javascript__dopostback address in the href property of the rendered anchor tag, even though I am assigning the associated javascript functions to both the OnClientClick event handler of the linkbutton control and adding an onkeypress event handler attribute to the control's attribute collection.
0
Antonio Stoilkov
Telerik team
answered on 10 Oct 2012, 06:31 AM
Hello,

You could achieve your scenario by subscribing to the GridHyperlinkColumn onkeydown event instead of onkeypress because the key press event is not consistent through browsers and does not ensure firing the event when the Tab key is pressed.

Note that your questions have been answered in the support ticket you have opened. If you have any additional please decide where to continue the discussion so we could avoid duplicate posts.

Regards,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Charles
Top achievements
Rank 1
Answers by
Charles
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Share this question
or