ASP.NET Core Razor Pages Grid button/link column to navigate to another page

1 Answer 1228 Views
Grid
Bill
Top achievements
Rank 1
Bill asked on 11 Aug 2022, 04:51 PM | edited on 11 Aug 2022, 04:57 PM

I'm using the Grid component (ASP.NET Core Razor Pages).

 

I would like a column that when clicked will navigate to a specified Page within my application, passing along with it one or more of the column values in my model.

Ideally I'd like to avoid Templates, because it just seems like a lot of string to manage to get an HTML output that I like.

I did come across Commands with a custom Click, but I haven't been able to find documentation yet that shows how I can pass the row details along so I can access specific column values to use in a redirect via JavaScript.

I did get this working with

columns.Template("my anchor tag html goes here with template syntax for #:SomePropValue#")

But it doesn't come across as "clean" as I'd like.

So I'm hoping there's some way to access/pass along a given row's column values in a custom click so I can just use JS for a redirect?

columns.Command(action => {action.Custom("View Application").Click("myJavaScriptFunction")

 

If there's also a way to do this by using only Html Helpers/Razor syntax, I'm also okay with that! But I couldn't find what I'm looking for with just that either, so I started looking into custom clicks and JS.

 

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 16 Aug 2022, 12:12 PM

Hi Bill,

Thank you for the code snippets and details provided.

In order to achieve the desired behavior, I would recommend using the approach from the following demo:

  1. Use the "Click" Event handler of the Custom Command Button("ViewDetails").
  2. In the Event handler(the "showDetails" function), get the current dataItem as shown in the demo above.
  3. Redirect to the needed View using the properties of the dataItem.

I hope this information helps. Let me know if further assistance is needed.

Kind Regards,
Anton Mironov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Bill
Top achievements
Rank 1
Answers by
Anton Mironov
Telerik team
Share this question
or