Access Grid Template value in Razor Syntax

4 posts, 0 answers
  1. Ali
    Ali avatar
    17 posts
    Member since:
    Aug 2013

    Posted 18 Jun 2019 Link to this post

    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>

  2. Eyup
    Admin
    Eyup avatar
    4046 posts

    Posted 20 Jun 2019 Link to this post

    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.
  3. Ali
    Ali avatar
    17 posts
    Member since:
    Aug 2013

    Posted 20 Jun 2019 in reply to Eyup Link to this post

    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.

  4. Eyup
    Admin
    Eyup avatar
    4046 posts

    Posted 25 Jun 2019 Link to this post

    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.
Back to Top