We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Access the view model from a column template

Thread ID:





128269 Jan 11,2017 03:13 PM UTC Jan 16,2017 10:22 AM UTC ASP.NET MVC (Classic) 1
Tags: Grid
Cristian Bellotto
Asked On January 11, 2017 03:13 PM UTC

I've a grid with a column that has a template; in this template I want to visualize a button depending not from the row but from a property in the model of the view.
Is it possible to achieve this behaviour with something like this?

<script type="text/x-jsrender" id="approveTemplate">
    {{if Model.Approver == true}}
    <a rel='nofollow' href="/Request/Approve/{{:Id}}" class="btn btn-default" role="button"><img src="/Content/Images/Security_Approved.png" align="middle" /></a>

Thank you in advance!


Mohammed Farook J [Syncfusion]
Replied On January 16, 2017 10:22 AM UTC

Hi Cristian,  
We have validated your provided code example  and we cannot access model values  in jsrender . So we suggest to use the following code example. 
@if (Model.EmployeeID ==1) 
    <script type="text/x-jsrender"> 
     <div> {{:EmployeeID}}</div> 
    <script type="text/x-jsrender"> 
        <div> message</div> 
To construct jsrender template based on its model values   
J.Mohammed Farook 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon