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

Access Grid Template value in Razor Syntax

3 Answers 527 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ali
Top achievements
Rank 1
Ali asked on 18 Jun 2019, 04:50 PM

Hello, I am trying to access client template values in Razor syntax like the below. pay.ID always return "#= data.ID #" instead of value. But @id inside html return the correct value.

<script id="GridCommandTemplate" type="text/x-kendo-template">

    @{
        var id = "#= data.ID #"
        var s = "#= data.StatusStr #";
        var userid = "#= data.UserId #";
        var data = ("#= data #");

        object pay = new Payment() { ID = id, UserId = userid };
    }

    <a class="dropdown-toggle k-button k-primary" data-toggle="dropdown">
        <i class="k-icon k-i-more-horizontal">@id</i>
    </a>

<ul class="dropdown-menu dropdown-user">
        <li>
            <a href="Payment/Details?id=#= data.id#" class="dropdown-item"><i class="k-icon k-i-eye"></i> Details</a>
        </li>

        @if ((await AuthorizationService.AuthorizeAsync(
       User, pay,
       PaymentOperations.Update)).Succeeded)
        {
            <li class="dropdown-divider"></li>
            <li>
                <a href="Payment/Edit?id=#= data.id#" class="dropdown-item"><i class="k-icon k-i-edit"></i> Edit</a>
            </li>
        }
     
    </ul>
</script>

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 20 Jun 2019, 11:39 AM
Hello Ali,

This can be related to escaping the value literals. If the grid holding the template is placed within another binding container (like another grid), you will need to use escaping as demonstrated in the Hash Literal section of this article:
https://docs.telerik.com/kendo-ui/framework/templates/overview#hash-literals

Also, you can check the article for other beneficial information.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Ali
Top achievements
Rank 1
answered on 20 Jun 2019, 12:25 PM

Hello. Thank you for the reply.

I have already gone through the article and that did not solve my problem. I wanted to render the values without the hash literal. As at now it only renders in a html tags.

Thank you.

0
Eyup
Telerik team
answered on 25 Jun 2019, 09:09 AM
Hi Ali,

In this case, could you open a formal support thread to send us a runnable project to demonstrate the issue? This will enable us to replicate the problem locally and provide more accurate and precise solutions, so you can continue with your implementation.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Ali
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Ali
Top achievements
Rank 1
Share this question
or