or
<div id="example" class="k-content"> <p> <label for="categories">Catergories:</label> <input id="categories" /> </p> <p> <label for="products">Products:</label> <input id="products" disabled="disabled" /> </p> <p> <label for="orders">Orders:</label> <input id="orders" disabled="disabled" /> </p> <style scoped> .k-readonly { color: gray; } </style> <script> $(document).ready(function () { var productsDataSource = new kendo.data.DataSource({ serverFiltering: true, transport: { read: { url: "WebForm1.aspx/GetProductsList", //specify the URL which data should return the records. This is the Read method of the Products.asmx service. contentType: "application/json; charset=utf-8", // tells the web method to serialize JSON type: "POST" //use HTTP POST request as the default GET is not allowed for web methods }, parameterMap: function (options) { return JSON.stringify(options); } }, schema: { // the data which the data source will be bound to is in the "results" field data: "d" } }); var ordersDataSource = new kendo.data.DataSource({ serverFiltering: true, transport: { read: { url: "WebForm1.aspx/GetOrdersList", //specify the URL which data should return the records. This is the Read method of the Products.asmx service. contentType: "application/json; charset=utf-8", // tells the web method to serialize JSON type: "POST" }, parameterMap: function (options) { return JSON.stringify(options); } }, schema: { // the data which the data source will be bound to is in the "results" field data: "d" } }); $("#categories").kendoComboBox({ placeholder: "Select category...", dataTextField: "CategoryName", dataValueField: "CategoryID", dataSource: { serverFiltering: true, transport: { read: { url: "WebForm1.aspx/GetCategoryList", //specify the URL which data should return the records. This is the Read method of the Products.asmx service. contentType: "application/json; charset=utf-8", // tells the web method to serialize JSON type: "POST" //use HTTP POST request as the default GET is not allowed for web methods }, parameterMap: function (options) { return JSON.stringify(options); } }, schema: { // the data which the data source will be bound to is in the "results" field data: "d" } }, change: function () { var value = this.value(); if (value) { value = parseInt(value); if (isNaN(value)) { return; } products.data("kendoComboBox").dataSource.filter({ field: "ProductID", operator: "eq", value: parseInt(value) }); products.enable(); } else { products.enable(false); } products.value(""); orders.value(""); orders.enable(false); } }) var products = $("#products").kendoComboBox({ autoBind: false, placeholder: "Select product...", dataTextField: "ProductName", dataValueField: "ProductID", dataSource: productsDataSource, change: function () { var value = this.value(); if (value) { value = parseInt(value); if (isNaN(value)) { return; } ordersDataSource.filter({ field: "ProductID", operator: "eq", value: parseInt(value) }); orders.enable(); } else { orders.enable(false); } orders.value(""); } }).data("kendoComboBox"); var orders = $("#orders").kendoComboBox({ autoBind: false, placeholder: "Select order...", dataTextField: "OrderID", dataValueField: "OrderID", dataSource: ordersDataSource }).data("kendoComboBox"); }); </script> </div>[WebMethod] public static IEnumerable GetCategoryList() { return dbContext.Categories.Select(e => new { CategoryID = e.CategoryID, CategoryName=e.CategoryName }).ToArray(); } [WebMethod] public static IEnumerable GetProductsList(int filter) { return dbContext.Products.Select(e => new { ProductID = e.ProductID, ProductName = e.ProductName, CategoryID = e.CategoryID }).ToArray(); } [WebMethod] public static IEnumerable GetOrdersList(int filter) { return dbContext.Orders.Select(e => new OrderViewModel { OrderID = e.OrderID, OrderName = e.OrderID, ProductID = e.ProductID }).ToArray(); } } public class ProductViewModel { public int ProductID { get; set; } public string ProductName{ get; set; } [ScriptIgnore] public int CategoryID { get; set; } } public class OrderViewModel { public int OrderID { get; set; } public int OrderName{ get; set; } [ScriptIgnore] public int ProductID { get; set; } } var pagesize = $("#PageSizeSelect").data("kendoDropDownList").value(); alert("page size is now: " + pagesize); searchData.pageSize(parseInt(pagesize));// makes a second request - which works and has the new pagesize set // searchData is a kendo dataSource object searchData.read(searchBox);
var dataSourceStatistics = new kendo.data.DataSource({ batch: true, transport: { read: { data: { f:'getOrderSuggestion' } } }, schema: { data: function(data) { return data.result.custStats.Record; }, total: function(data) { return data.result.custStats.Record.length; }, model:{ // TODO: id should be EmployeeId id: "Employee", fields: { Employee: { }, EmployeeId: { }, ValueCultureAndExercise: { type: "number", defaultValue: "0", validation: { } }, ValueExercise: { type: "number", defaultValue: "0" }, Company: { editable: false, defaultValue: function() { return "apa"; } }, CompanyNo: { editable: false }, Department: { }, Total: function () { return this.ValueExercise * 10; } } } }});$("#orderGrid").kendoGrid({ dataSource: dataSourceStatistics, editable: { update: true, destroy: true }, sortable: true, selectable: true, toolbar: [{name: "create", text: "Lägg till rad"}], columns: [ { field: "Employee", title: "Namn" }, { field: "EmployeeId", title: "Anställningsnummer" }, { field: "ValueExercise", title: "Värde träning" }, { field: "ValueCultureAndExercise", title: "Värde träning och kultur" }, { field: "null", title: "Totalt", template: "#= ValueCultureAndExercise + ValueExercise#" }, { command: "destroy", title: "Ta bort" } ]});