or
public ActionResult Index() { return View(); } public ActionResult Customers([DataSourceRequest] DataSourceRequest request) { var customers = Context.Customers.ToDataSourceResult(request); return Json(customers); }@(Html.Kendo().Grid<Customer>() .Name("CustomersGrid") .Columns(columns => { columns.Bound(c => c.ID).Groupable(false); columns.Bound(c => c.FName); columns.Bound(c => c.LName); columns.Bound(c => c.Rate); }) .Groupable() .Pageable() .Sortable() .Scrollable() .Filterable() .DataSource(dataSource => dataSource.Ajax().Read(read => read.Action("Customers", "Customer")) ))Line 19: .Scrollable()
Line 20: .Filterable()
Line 21: .DataSource(dataSource => dataSource.Ajax().Read(read => read.Action("Customers", "Customer"))
Line 22: )
Line 23: )
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index] System.ThrowHelper.ThrowArgumentOutOfRangeException() +72 System.Collections.ObjectModel.Collection`1.set_Item(Int32 index, T value) +10419142 System.Web.Mvc.ControllerContext.get_RequestContext() +25 Kendo.Mvc.UI.NavigatableExtensions.GenerateUrl(INavigatable navigatable, ViewContext viewContext, IUrlGenerator urlGenerator) +52 Kendo.Mvc.UI.Fluent.CrudOperationBuilder.SetUrl() +81 Kendo.Mvc.UI.Fluent.CrudOperationBuilder.Action(String actionName, String controllerName, Object routeValues) +66 Kendo.Mvc.UI.Fluent.CrudOperationBuilder.Action(String actionName, String controllerName) +47 ASP._Page_Views_Customer_Index_cshtml.<Execute>b__1(CrudOperationBuilder read) in c:\Users\a.rezaei\Desktop\MVCWebApp\MVCWebApp\Views\Customer\Index.cshtml:21 Kendo.Mvc.UI.Fluent.AjaxDataSourceBuilderBase`2.Read(Action`1 configurator) +131 ASP._Page_Views_Customer_Index_cshtml.<Execute>b__0(DataSourceBuilder`1 dataSource) in c:\Users\a.rezaei\Desktop\MVCWebApp\MVCWebApp\Views\Customer\Index.cshtml:21 Kendo.Mvc.UI.Fluent.GridBuilder`1.DataSource(Action`1 configurator) +212 ASP._Page_Views_Customer_Index_cshtml.Execute() in c:\Users\a.rezaei\Desktop\MVCWebApp\MVCWebApp\Views\Customer\Index.cshtml:7
public ActionResult GetPeopleData([DataSourceRequest] DataSourceRequest request) { return Json(db.People.ToDataSourceResult(request));}@(Html.Kendo().Grid<Models.Person>() .Name("PeopleGrid") .Columns(columns => { columns.Bound(p => p.Id).Groupable(false).Visible(true); columns.Bound(p => p.LastName); columns.Bound(p => p.FirstName); }) .Selectable(selectable => selectable.Mode(GridSelectionMode.Single)) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("GetPeopleData", "People")) ) .Events(events => events.Change("PeopleGrid_RowSelected")))@model Datamart.Models.FileSpec@{ ViewBag.Title = "Upload Datamart File";}<h2>Upload Excel File</h2><script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script><script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>File must be less than 16MB and must be an Excel spreadsheet<br />@(Html.Kendo().Upload().Name("files").ShowFileList(true).Multiple(true).Messages(msg => msg .StatusUploaded("Response Status Goes Here?") .StatusFailed("statusFAiled") .StatusUploading("Uploading").Async(a => a .AutoUpload(true) .Save("Save","FileUpload") ) .Events(e => e .Success("onSuccess") ) )<div> @Html.ActionLink("Back to List", "Index")</div><script type="text/javascript">function onSuccess(e) { alert("Status: " + e.response.status);}</script>public ActionResult Save(IEnumerable<HttpPostedFileBase> files){ foreach (var file in files) { string UPLOADSDIRECTORY = Server.MapPath("~/App_Data/uploads"); // Verify that the user selected a file if (file != null && file.ContentLength > 0) { // extract only the filename var fileName = Path.GetFileName(file.FileName); /* check the first three letters of the extension for xls - there are far too many endings for Excel to check all of them */ if (Path.GetExtension(file.FileName).Substring(1, 3) == "xls") { // store the file inside ~/App_Data/uploads folder var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName); FileInfo fInfo = new FileInfo(path); if (!(fInfo.Exists)) { file.SaveAs(path); var dataFile = new FileSpec { FileName = fileName }; db.FileSpec.Add(dataFile); db.SaveChanges(); // if successful, then redirect to the Edit page so the user can fill in the tab name while it's still fresh in their mind return Json(new { status = "OK" }, "text/plain"); } // TODO: redirect to error message because the file already exists return Json(new { status = "Overwritten" }, "text/plain"); } // TODO: redirect to error message because the file was not an Excel file (as determined by extension) return Json(new { status = "Rejected" }, "text/plain"); } } // default to Default status return Json(new { status = "Default" }, "text/plain");}
function myFunction(){ var gridChoosenValues = $('#MyGrid').data("kendoGrid"); var choosenItems = gridChoosenValues.items(); for (var i = 0; i < choosenItems.length; i++) //delete every row { grid.removeRow(choosenItems[i]); //this triggers delete confirmation :( }}