title: How to use client template expressions in ajax binding of a mvc kendo grid?
body: <p>I have a two-layer hierarchical grid that I am moving from server side binding to using ajax. The ajax reads for both layers of data are working correctly however I am having difficulty using the ClientTemplate to render my columns based on conditional logic.</p>
  
  <p>Below is the server-side binding version. I understand I have to use ClientTemplate and expressions #=# for the same effect but I am having two problems:</p>
  
  <ol>
  <li>How to increment variable 'i' for each row so I can use CheckBoxFor and like html helper methods?</li>
  <li>How to convert the @ to use the ClientTemplate expression. Note the conditional logic uses properties of the Model of the View and also properties of the bound element (MyViewModel) with the conditional logic using a mixture of properties from the Model</li>
  </ol>
  
  <p>Converting this to an expression would be most helpful.</p>
  
  <pre><code>var i = -1;
  
  @(Html.Kendo().Grid&lt;MyViewModel&gt;()
    .Name("grid")
    .Columns(columns =&gt;
    {
      columns.Bound(c =&gt; c.Selected).Title("")
        .Template(
          @&lt;text&gt;
            @{i++;}
            @if (Model.Permissions.HasInsertAccess &amp;&amp; item.Status == Status.Created)
            {
              &lt;input type="hidden" name="MyViewModels.Index" value="@i" /&gt;
              @Html.CheckBoxFor(m =&gt; m.MyViewModels[i].Selected)
            }
            &lt;/text&gt;);
  
            columns.Bound(c =&gt; c.Id)
              .Template(@&lt;text&gt;@Html.HiddenFor(m =&gt; m.MyViewModels[i].Id)@item.Id&lt;/text&gt;)
  </code></pre>