title: Kendo UI Grid: Configuration of the DataSource with Context Model
body: <p>I am using ASP.Net Mvc 4 with Kendo UI grid.
  I would like to perform more advanced features on the kendo UI grid (like exporting the sorted data from the grid to excel, adding filters, etc.). I need to configure the DataSource in my View and the "Read" method in the Controller. The grid is populated from a LINQ query and stored in the ViewBag.</p>
  
  <p>Here is the razor code in my view Index.cshtml</p>
  
  <pre><code>@(Html.Kendo().Grid((IEnumerable&lt;Reports.Models.Company&gt;)ViewBag.ActComp)
        .Name("grid")     
        .Columns(columns =&gt;
        {
            columns.Bound(comp =&gt; comp.Name);
            columns.Bound(comp =&gt; comp.DateCreated);
            columns.Bound(comp =&gt; comp.Quarter).Sortable(false);
            columns.Bound(comp =&gt; comp.Code);
            columns.Bound(comp =&gt; comp.Enabled).Column.Title = "Active";
        })
        .Sortable()
        .Groupable()
        .Scrollable(src =&gt; src.Height(500))            
        )
  </code></pre>
  
  <p>Here is the Controller ActiveCompController.cs</p>
  
  <pre><code>    namespace Reports.Controllers
  {
      public class ActiveCompController : Controller
      {
          private FSLContext fslData = new FSLContext();
  
          public ActionResult Index()
          {
              ViewBag.ActComp = from b in fslData.Companies
                                where b.Enabled == true
                                orderby b.Name
                                select b;
  
              return View();
          }
  </code></pre>
  
  <p>I have seen a couple of different examples with .Ajax() like:</p>
  
  <pre><code>      .DataSource(dataSource =&gt; dataSource // Configure the grid data source
        .Ajax() // Specify that ajax binding is used
        .Read(read =&gt; read.Action("Products_Read", "Home")) // Set the action method which will return the data in JSON format
  </code></pre>
  
  <p>However, it didn't work as my data is from a LINQ query not formatted in JSON. Also, I don't know what to write in the "Read" method.</p>
  
  <p>Any thoughts on how to configure the Datasource and the controller with my configuration ?</p>