title: How to use Kendo UI MVC Extensions with require js?
body: <p>I have a controller that looks like this:</p>
  
  <pre><code>using System.Collections.Generic;
  using System.Web.Mvc;
  
  using Kendo.Mvc.Extensions;
  using Kendo.Mvc.UI;
  
  namespace KendoMvcApplication.Controllers
  {
      public class HomeController : Controller
      {
          public ActionResult Index()
          {
              return View();
          }
  
          public ActionResult GetData([DataSourceRequest] DataSourceRequest req)
          {
              var products = CreateProducts();
              var result = products.ToDataSourceResult(req);
              return Json(result);
          }     
  
          private static IEnumerable&lt;Product&gt; CreateProducts()
          {
              for (int i = 1; i &lt;= 20; i++)
              {
                  yield return new Product
                  {
                      ProductId = i,
                      ProductName = "Product " + i,
                      ProductPrice = i * 2.5
                  };
              }
          }
      }
  
      public class Product
      {
          public int ProductId { get; set; }
          public string ProductName { get; set; }
          public double ProductPrice { get; set; }
      }
  }
  </code></pre>
  
  <p>And a view that looks like this:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;link href="~/Content/kendo.common.min.css" rel="stylesheet" /&gt;
      &lt;link href="~/Content/kendo.default.min.css" rel="stylesheet" /&gt;
      &lt;script type="text/javascript" src="~/Scripts/require.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;            
  &lt;div id="grid"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;            
      require.config({
          baseUrl : '@Url.Content("~/Scripts")',
          paths: {
              'jquery': 'jquery-2.0.3.min',
              'kendo': 'kendo-ui'
          },
          shim: {
              'jquery': {
                  exports: 'jQuery'
              }
          }            
      });           
      require(['jquery', 'kendo/kendo.grid.min'], function ($) {
          $(document).ready(function () {
              $('#grid').kendoGrid({
                  dataSource: {
                      schema: {
                          data: 'Data',
                          total: 'Total',
                          aggregates: 'AggregateResults',
                          model: {
                              id: "ProductId",
                              fields: {
                                  ProductName: { type: "string" },
                                  ProductPrice: { type: "number" }
                              }
                          }
                      },
                      transport: {
                          read: {
                              url: "@Url.Action("GetData", "Home")",
                              dataType: "json",
                              method: "post"
                          }
                      },
                      pageSize: 10,
                      serverPaging: true,
                      serverSorting: true,
                      type: "aspnetmvc-ajax"
                  },
                  sortable: {
                      mode: "single"
                  },
                  columns: ["ProductName", "ProductPrice"],
                  scrollable: false,
                  pageable: true
              });
          });            
      });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And my directory structure is:</p>
  
  <ul>
  <li>Scripts/kendo-ui/* (all the kendo files, including the mvc one)</li>
  <li>Scripts/require.js</li>
  <li>Scripts/jquery-2.0.3.min.js</li>
  </ul>
  
  <p>which <em>nearly</em> works except that server-side sorting doesn't get applied.  </p>
  
  <p>This is because the <strong>kendo.aspnet.mvc.min.js</strong> file is never downloaded (of course, as require JS doesn't know anything about it) so to remedy that I tried this:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;link href="~/Content/kendo.common.min.css" rel="stylesheet" /&gt;
      &lt;link href="~/Content/kendo.default.min.css" rel="stylesheet" /&gt;
      &lt;script type="text/javascript" src="~/Scripts/require.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;            
  &lt;div id="grid"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      require.config({
          baseUrl: '@Url.Content("~/Scripts")',
          paths: {
              'jquery': 'jquery-2.0.3.min',
              'kendo': 'kendo-ui',
              'kendo-mvc': 'kendo/kendo.aspnetmvc.min'
          },
          shim: {
              'jquery': {
                  exports: 'jQuery'
              }
          }
      });
      require(['jquery', 'kendo-mvc', 'kendo/kendo.grid.min'], function ($) {
          $(document).ready(function () {
              $('#grid').kendoGrid({
                  dataSource: {
                      schema: {
                          data: 'Data',
                          total: 'Total',
                          aggregates: 'AggregateResults',
                          model: {
                              id: "ProductId",
                              fields: {
                                  ProductName: { type: "string" },
                                  ProductPrice: { type: "number" }
                              }
                          }
                      },
                      transport: {
                          read: {
                              url: "@Url.Action("GetData", "Home")",
                              dataType: "json",
                              method: "post"
                          }
                      },
                      pageSize: 10,
                      serverPaging: true,
                      serverSorting: true,
                      type: "aspnetmvc-ajax"
                  },
                  sortable: {
                      mode: "single"
                  },
                  columns: ["ProductName", "ProductPrice"],
                  scrollable: false,
                  pageable: true
              });
          });
      });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But that produced this error:</p>
  
  <p><img src="https://i.stack.imgur.com/10FVX.png" alt="split configuration error"></p>
  
  <p>And attempted to load the js files thus:</p>
  
  <p><img src="https://i.stack.imgur.com/J5JaP.png" alt="try 1 files"></p>
  
  <p>The red spots are 404 not found as it is looking for the js files in a folder called kendo under the scripts folder.</p>
  
  <p>So then I thought I would try including the all version instead so I tried this:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;link href="~/Content/kendo.common.min.css" rel="stylesheet" /&gt;
      &lt;link href="~/Content/kendo.default.min.css" rel="stylesheet" /&gt;
      &lt;script type="text/javascript" src="~/Scripts/require.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;            
  &lt;div id="grid"&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      require.config({
          baseUrl: '@Url.Content("~/Scripts")',
          paths: {
              'jquery': 'jquery-2.0.3.min',
              'kendo': 'kendo-ui/kendo.all.min',
              'kendo-mvc': 'kendo-ui/kendo.aspnetmvc.min'
          },
          shim: {
              'jquery': {
                  exports: 'jQuery'
              }
          }
      });
      require(['jquery', 'kendo', 'kendo-mvc'], function ($) {
          $(document).ready(function () {
              $('#grid').kendoGrid({
                  dataSource: {
                      schema: {
                          data: 'Data',
                          total: 'Total',
                          aggregates: 'AggregateResults',
                          model: {
                              id: "ProductId",
                              fields: {
                                  ProductName: { type: "string" },
                                  ProductPrice: { type: "number" }
                              }
                          }
                      },
                      transport: {
                          read: {
                              url: "@Url.Action("GetData", "Home")",
                              dataType: "json",
                              method: "post"
                          }
                      },
                      pageSize: 10,
                      serverPaging: true,
                      serverSorting: true,
                      type: "aspnetmvc-ajax"
                  },
                  sortable: {
                      mode: "single"
                  },
                  columns: ["ProductName", "ProductPrice"],
                  scrollable: false,
                  pageable: true
              });
          });
      });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But that produced these errors:</p>
  
  <p><img src="https://i.stack.imgur.com/Jn7Dr.png" alt="ASP NET MVC Errors"></p>
  
  <p>And attempted to load the js files thus:</p>
  
  <p><img src="https://i.stack.imgur.com/bEA2m.png" alt="case 2 files"></p>
  
  <p>In this case - the red spots are 404 not found as it is looking for the files directly under the Scripts folder.</p>
  
  <p>So here is my question:</p>
  
  <blockquote>
    <blockquote>
      <p>How can I include said file in a require JS type scenario?  </p>
    </blockquote>
  </blockquote>
  
  <p>Aside:  <em>I would like to be using the kendo.all.min file and not the separate ones as I want to use knockout-kendo in the future and that seems to not work with the separate file but if the only way to make this work is to use the separate file approach, that is fine.</em></p>