var dsGalleryItem = new kendo.data.DataSource({ transport: { read: { url: '@Url.Content("~/Intranet/GalleryItem/SearchGalleryItems")', type: "POST", data: $("#fmSearch").serializeFormToJSON(), cache: false } }, schema: { model: { id: "galleryItemID", fields: { galleryItemID: { nullable: true }, imageName: {}, collectionName: {}, categoryName: {}, lastUpdatedOn: { type: "date" } } } } }); var gvResults = $("#gvResults").kendoGrid({ autoBind:false, columns: [{ field: "imageName", title: "Item Name", template: "<a href='@Url.Content("~/Intranet/GalleryItem/Details/")#=galleryItemID#'> #=imageName#</a>" }, { field: "collectionName", title: "Collection" }, { field: "categoryName", title: "Category" }, { field: "lastUpdatedOn", title: "Last Updated", format: "{0:M/d/yyyy}" } ], selectable: "row", change: onRowSelect, dataSource: dsGalleryItem }); $("#fmSearch").submit( function (event) { event.preventDefault(); dsGalleryItem.read({ data: $("#fmSearch").serializeFormToJSON() }); });[HttpPost] public JsonResult SearchGalleryItems(string keyword, int? category, int? collection, DateTime? startDate, DateTime? endDate) { var galleryItemList = (from g in db.GalleryItems //where g.imageName.Contains(keyword) select new GalleryItemViewModel { galleryItemID = g.galleryItemID, imageName = g.imageName, collectionName = g.collection.collectionName, categoryName = g.category.categoryName, lastUpdatedOn = g.lastUpdatedOn }); var galleryItemCount = Json(galleryItemList.ToList()); return Json(galleryItemList.ToList()); ; }var list=[{label:'tag1', value:'1'}, {label:'tag9', value:'9'}, {label:'tag8', value:'8'}, {label:'tag7', value:'7'}, {label:'tag6', value:'6'}, {label:'tag5', value:'5'}, {label:'tag4', value:'4'}, {label:'tag3', value:'3'}, {label:'tag2', value:'2'}];function fillData(tagIds){ var tagObj = $("#addTags").data("kendoMultiSelect"); if (tagObj == undefined) { // if not loaded $("#addTags").kendoMultiSelect({ dataTextField: "label", dataValueField: "value", dataSource: list, value: tagIds, placeholder: "Select from list", change: function() { // change } }); } else { // if already loaded only change the values. tagObj.value(tagIds); console.log(tagIds); console.log(tagObj.value()); }}function fillaList(){ var tagIds=[1,2,3]; fillData(tagIds);}function clearList(){ fillData([]);}$(document).ready(function () {
var grid = $("#itemList").kendoGrid({
toolbar: kendo.template($("#template").html()),
columns: ["Manufacturer", "Model", "Price", "Tags"],
dataSource: {
transport: {
read: {
url: "catalogadmin/_index",
dataType: "json",
type: "POST",
data: {
filter: ""
}
},
},
schema: {
data: "data", // records are returned in the "data" field of the response
total: "total" // total number of records is in the "total" field of the response
},
pageSize: 2,
serverPaging: true
},
pageable: true
});
This correctly calls my datasource and passes in the filters etc, but the paging controls don't work. The paging controls appear but have no page numbers or totals. When I click on a next/prev page button, a JS error is thrown saying "Object does not support property or method 'slice'". If I remove the "pageable" option on the grid setup, I don't see any paging controls at all.
As far as I know, I'm correctly returning the total in the JSON result so that the grid knows the data source size:
{"total":4,"data":[data is in here and is all correct]}
Any ideas what could be going wrong here?
Thanks,
Charles
<path style="display: block; " d="M 21.748 348.065 A230 230 0 1,1 448.252 348.065 L 434.345 342.445 A215 215 0 1,0 35.655 342.445 z" stroke-linecap="square" stroke-linejoin="round" fill-opacity="1" stroke-opacity="1" fill="#d2d3d6" stroke="#9c9b9b"></path>