How to add hyperlink inside ClientTemplate with IF condition- Ajax Bound Kendo UI for ASP.NET MVC -


i using asp.net mvc. want make account_number column html link in ajax bound kendo ui grid, when not searched account_number previous page. , when clicked on account_number link, should pass account_number customer controller method 'quickchecksearch'.
below code not populate grid in view , not call/pass value controller. please correct following code?

thanks in advance.

  columns.bound(p => p.account_number)  .clienttemplate("<#if (item.account_number == model.accountnumber){>account_number <# }" + "else{#><a href='" + url.action("quickchecksearch", "customer") + "?account_number=#=account_number#'>#= account_number #</a> <# } #>")  .title("account number"); 

  1. read http://docs.telerik.com/kendo-ui/framework/templates/overview
  2. you have way many angle brackets on place. should have them on actual html markup of template, not part of template syntax itself. try:

    .clienttemplate(     "# if (account_number ==" + @model.accountnumber + "){ #" +         "#= account_number #" +     "# }" +     "else { #" +          "<a href = '" + url.action("quickchecksearch", "customer") + "?account_number=#=account_number#'>#= account_number#</a>" +     "# } #" ) 

i find helps format on separate lines write actual code instead of on 1 line can see structure visually.

you way, may cleaner:

.clienttemplate("#= accountlinktemplate(data) #") .... <script>      function accountlinktemplate(data) {         var template = data.account_number;         if (data.account_number == " + @model.accountnumber + ") {             template = "<a href = '" + "@url.action("quickchecksearch", "customer")" + "?account_number=" + data.account_number+ "'>" + data.account_number+ "</a>";         }          return template;     } </script> 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -