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

Add button on window (custom command)

1 Answer 252 Views
Grid
This is a migrated thread and some comments may be shown as answers.
alveiro
Top achievements
Rank 1
Veteran
alveiro asked on 06 Aug 2020, 11:44 PM

Hello.

 

I'm doing this example: https://demos.telerik.com/aspnet-core/grid/custom-command

I would like to add a button to the view, the button should redirect to a controller action with a parameter.
attached image

How could I do it?

 

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 11 Aug 2020, 12:21 PM

Hi Alveiro,

Attached to my reply, you will find a runnable example of how the targeted functionality in the popup Window can be implemented. 

Here are the modifications applied in the Window's template. In the below code, the yellow line defines the additional button added to the popup.

<script type="text/x-kendo-template" id="template">
    <div id="details-container">
        <h4>#= OrderID # #= OrderDate #</h4>
        <em>#= Freight #</em>
        <dl>
            <dt>City: #= ShipCity #</dt>
            <dt>Name: #= ShipName #</dt>
        </dl>
        <a class="k-button" href="/Grid/LoadPage?customParam=#= ShipCity #">Go To controller and load View</a>
    </div>
</script>

When the button is clicked, it will send the "customParam" to the LaodPage controller that is defined as follows:

public ActionResult LoadPage(string customParam) {
    return View("LoadView", new LoadViewModel { CustomParam = customParam });
}

The above controller will load the LoadView partial view.

I hope the provided example will help you implement the targeted functionality in the application you are working on.

Regards,
Petar
Progress Telerik

Tags
Grid
Asked by
alveiro
Top achievements
Rank 1
Veteran
Answers by
Petar
Telerik team
Share this question
or