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.
Unfortunately, activation email could not send to your email. Please try again.

Access the view model from a column template

Thread ID:

Created:

Updated:

Platform:

Replies:

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

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

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

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 
 


CONFIRMATION

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.

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.

;