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

Grid command and href="#"

3 Answers 1392 Views
Grid
This is a migrated thread and some comments may be shown as answers.
SLM
Top achievements
Rank 1
SLM asked on 03 Dec 2015, 10:55 AM

When adding a new command in a grid column, the generated button-styled link includes an href="#" attribute. This is problematic when using any kind of client-side routing framework (angular routing for example). Is there any way to disable this behavior, apart from completely overriding the button template ?

 

Thank you in advance.

3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 07 Dec 2015, 08:32 AM
Hi,

One possible way to prevent this is to use a custom template, e.g. to completely overriding the button template. Alternatively you may hook up to the dataBound event of the Grid which fires after the rows are rendered and manually remove the href attributes with jQuery.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Saquib
Top achievements
Rank 1
answered on 24 Jul 2017, 09:18 PM

@Alexander Valchev

Is ther not a simple way to do that. I want to do that for all the grid in my project, I do not want to hook up databound event for all the grids.

Other problem with having href='#' is when you click on it, it takes you to the top of the page before executing the javascript or redirecting to other page.

0
Alex Hajigeorgieva
Telerik team
answered on 26 Jul 2017, 03:28 PM
Hello Saquib,

An easier way to prevent the page shift is to call preventDefault() in the click handler of the command button:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.command.click

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
Tags
Grid
Asked by
SLM
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Saquib
Top achievements
Rank 1
Alex Hajigeorgieva
Telerik team
Share this question
or