title: assigning Datasource of kendo grid in Javascript part. (Asp.net MVC-Razor Engine)
body: <p>I want to assign the datasource of the kendo grid in Javascript part of the View, as i want to display it in response to selecting another object from another kendogrid on the same page, so i want to pass the value of this object to the controller back and then view the grid.</p>
  
  <p>I found the best way is to assign the datasource in the javascript function related to the selection part, if there is better ideas, please suggest it.</p>
  
  <p>Kendo grid :</p>
  
  <pre><code>@(Html.Kendo().Grid&lt;dynamic&gt;()
  .Name("StatusGrid")
  //.HtmlAttributes(new { style="width:50%;" })
  .Columns(columns =&gt;
  {
      foreach (System.Data.DataColumn c in Model.GridStatus.Columns)
      {
          columns.Bound(c.ColumnName).EditorTemplateName("String");
      }
  })
  .DataSource(dataSource =&gt; dataSource
      .Ajax()
      .Events(events =&gt; events.Error("error_handler"))
      .Model(model =&gt;
      {
          foreach (System.Data.DataColumn column in Model.GridStatus.Columns)
          {
              model.Field(column.ColumnName, column.DataType);
              model.Id("Id");
          }
      })
      //.Read(read =&gt;
  
      //  read.Action("ActivityGridDisplay", "Configuration")
      //)
  ))
  </code></pre>
  
  <p>So how to write this part in the javascript:( assigning the read and the model) ?</p>
  
  <pre><code>    .DataSource(dataSource =&gt; dataSource
      .Ajax()
      .Events(events =&gt; events.Error("error_handler"))
      .Model(model =&gt;
      {
          foreach (System.Data.DataColumn column in Model.GridStatus.Columns)
          {
              model.Field(column.ColumnName, column.DataType);
              model.Id("Id");
          }
      })
      .Read(read =&gt;
  
          read.Action("ActivityGridDisplay", "Configuration")
      )
  ))
  </code></pre>