Add button on window (custom command)

2 posts, 0 answers
  1. alveiro
    alveiro avatar
    4 posts
    Member since:
    Apr 2020

    Posted 06 Aug 2020 Link to this post

    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?

     

  2. Petar
    Admin
    Petar avatar
    459 posts

    Posted 11 Aug 2020 Link to this post

    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

Back to Top