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. Image for the cookie policy date
close icon

Access the view model from a column template

Hi,
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>
    {{/if}}
</script>

Thank you in advance!

Cristian

1 Reply

MF Mohammed Farook J Syncfusion Team 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> 
} 
else 
{ 
    <script type="text/x-jsrender"> 
        <div> message</div> 
    </script> 
} 
 
 
 
To construct jsrender template based on its model values   
 
Regards, 
J.Mohammed Farook 
 


Loader.
Live Chat Icon For mobile
Up arrow icon