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

How can I use action links (Ajax bound grid) to get a POST?

3 Answers 406 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Francois
Top achievements
Rank 1
Veteran
Francois asked on 16 Nov 2020, 02:47 AM

I used the instructions from here: https://docs.telerik.com/aspnet-mvc/html-helpers/data-management/grid/faq#how-can-i-use-action-links

... and the code below works just fine, however this creates a GET. How can change it to create a POST?

Here is my code:

columns.Bound(c => c.InvoiceAmount)
    .Format("{0:C}")
    .Width(100)
    .Title("Invoiced")
    .HtmlAttributes(new { @style = "text-align:right;color:blue;" })
    .ClientGroupHeaderColumnTemplate("#= kendo.format('{0:C}',sum)#")
    .ClientTemplate("<a href='/PurchaseInvoice/Index?StatusIDFrom=1&StatusIDTo=250&ProjectID=#=ProjectID#&SupplierID=#=SupplierID#&DateFrom=#= kendo.toString(DateFrom,'yyyy-MM-dd') #&DateTo=#= kendo.toString(DateTo,'yyyy-MM-dd') #'>#= kendo.format('{0:C}',InvoiceAmount)#</a>")
    .ClientFooterTemplate("<div style='text-align:right;color:blue;'><a href='" + Url.Action("Index", "PurchaseInvoice?ProjectID=#=projectID#")+"'>#= kendo.format('{0:C}',sum)#</a></div>");

 

... the ClientTemplate creates a GET, I need a POST.

Note: I want to display the InvoicedAmount as a link to a POST.

 

Thanks

3 Answers, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 17 Nov 2020, 04:16 PM

Hello Francois,

You can achieve this requirement by using Url.ActionLink.

There are several ways of achieving this requirement. You can find them with working samples in the following posts:

- https://stackoverflow.com/a/38089090/6509119 

- https://stackoverflow.com/a/44436506/6509119 

- https://www.telerik.com/forums/mvc-grid-custom-command-to-call-actionlink-with-parameter-from-grid 
 

And if you want to call only a client-side function instead of Controller Action, you can use the Click() event:

- https://demos.telerik.com/aspnet-core/grid/custom-command 


I hope this will prove helpful. Feel free to try these approaches and let me know about the result.

Kind Regards,
Anton Mironov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Francois
Top achievements
Rank 1
Veteran
answered on 17 Nov 2020, 07:01 PM

 

 

 

 

Thank you very much for your help. Here's what I did (it may help someone/a newbie like me :) ):

.ClientTemplate("<form action='/PurchaseInvoice/Index?StatusIDFrom=1&StatusIDTo=250&ProjectID=#=ProjectID#&SupplierID=#=SupplierID#&DateFrom=#= kendo.toString(DateFrom,'yyyy-MM-dd') #&DateTo=#= kendo.toString(DateTo,'yyyy-MM-dd') #' method='post'> <button type='submit' class='linkBtn'>#= kendo.format('{0:C}',InvoiceAmount)#</button></form>")

... and I styled the button as a link:

.linkBtn {
    border: none;
    outline: none;
    background: none;
    cursor: pointer;
    color: #0000EE;
    padding: 0;
    text-decoration: underline;
    font-family: inherit;
    font-size: inherit;
}

 

Regards,

0
Anton Mironov
Telerik team
answered on 18 Nov 2020, 09:25 AM

Hello Francois,

I am glad to hear that the issue you were facing is now resolved.

Let me know if further assistance is needed, or this ticket thread should be closed.

 

Best Regards,
Anton Mironov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

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