// calculates total sum of unitPrice field's values.
[{ field: "unitPrice", aggregate: "sum" }]
data
: Array// bind the datasource to a local JavaScript array
var orders = [ { orderId: 10248, customerName: "Paul Smith" }, { orderId: 10249, customerName: "Jane Jones" }];
var dataSource = new kendo.data.DataSource({
data: orders
});
// returns only data where orderId is equal to 10248
filter: { field: "orderId", operator: "eq", value: 10248 }
// returns only data where orderId is equal to 10248 and customerName starts with Paul
filter: [ { field: "orderId", operator: "eq", value: 10248 },
{ field: "customerName", operator: "startswith", value: "Paul" } ]
// groups data by orderId field
group: { field: "orderId" }
// groups data by orderId and customerName fields
group: [ { field: "orderId", dir: "desc" }, { field: "customerName", dir: "asc" } ]
var dataSource = new kendo.data.DataSource({
page: 2 // displays the second page of data in the bound widget
});
var dataSource = new kendo.data.DataSource({
pageSize: 5 // 5 records per page of data
});
schema
: Objectvar dataSource = new kendo.data.DataSource({
transport: {
read: "Catalog/Titles",
},
schema: {
aggregates: function(data) {
// returns aggregates
},
data: function(data) {
return data.result;
},
total: function(data) {
return data.totalCount;
},
parse: function(data) {
return data;
},
type: "jsonp"
}
});
aggregates
: Function{
FIEL1DNAME: {
FUNCTON1NAME: FUNCTION1VALUE,
FUNCTON2NAME: FUNCTION2VALUE
},
FIELD2NAME: {
FUNCTON1NAME: FUNCTION1VALUE
}
}
{
unitPrice: {
max: 100,
min: 1
},
productName: {
count: 42
}
}
data
: Functiongroups
: Function[{
aggregates: {
FIEL1DNAME: {
FUNCTON1NAME: FUNCTION1VALUE,
FUNCTON2NAME: FUNCTION2VALUE
},
FIELD2NAME: {
FUNCTON1NAME: FUNCTION1VALUE
}
},
field: FIELDNAME, // the field name on which is grouped
hasSubgroups: true, // false if there are not sub group items and this is the top most group
items: [
// either the inner group items (if hasSubgroups is true) or the data records
{
aggregates: {
//nested group aggregates
},
field: NESTEDGROUPFIELDNAME,
hasSubgroups: false,
items: [
// data records
],
value: NESTEDGROUPVALUE
},
//nestedgroup2, nestedgroup3, etc.
],
value: VALUE // value of the field on which is grouped
}
// group2, group3, etc.
]
model
: Objectvar dataSource = new kendo.data.DataSource({
//..
schema: {
model: {
id: "ProductID",
fields: {
ProductID: {
//this field will not be editable (default value is true)
editable: false,
// a defaultValue will not be assigned (default value is false)
nullable: true
},
ProductName: {
validation: { //set validation rules
required: true
}
},
UnitPrice: {
//data type of the field {Number|String|Boolean|Date} default is String
type: "number",
// used when new model is created
defaultValue: 42,
validation: {
required: true,
min: 1
}
}
}
}
}
})
fields
: ObjectAvailable field attrbiutes:
var dataSource = new kendo.data.DataSource({
//..
schema: {
model: {
fields: {
UnitPrice: {
validation: {
required: true,
min: 1,
date: { message: "My custom message" }, // custom message
aCustomRule: function(input) { // custom validation rule
return input.val() === "foo"
}
}
}
}
}
}
})
id
: Number | Stringparse
: Functiontotal
: Functiontype
: Stringvar dataSource = new kendo.data.DataSource({
transport: {
read: "orders.json"
},
serverAggregates: true,
aggregate: { field: "orderId", operator: "eq", value: 10248 } // return only data where orderId equals 10248
});
The serverFiltering must be used in conjunction with the filter configuration. By default, a filter object is sent to the server with the query string in the following form:
Possible values for operator include:
It is possible to modify these parameters by using the parameterMap function found on the transport object (see transport in Configuration).
var dataSource = new kendo.data.DataSource({
transport: {
read: "orders.json"
},
serverFiltering: true,
filter: { field: "orderId", operator: "eq", value: 10248 } // return only data where orderId equals 10248
});
The serverGrouping must be used in conjunction with the group configuration. By default, a group object is sent to the server with the query string in the following form:
It is possible to modify these parameters by using the parameterMap function found on the transport object (see transport in Configuration).
var dataSource = new kendo.data.DataSource({
transport: {
read: "orders.json"
},
serverGrouping: true,
sort: { field: "orderId", dir: "asc" } // group by orderId descending
});
serverPaging must be used in conjunction with the pageSize configuration setting. The following options to the server as part of the query string by default:
It is possible to modify these parameters by using the parameterMap function found on the transport object (see transport in Configuration).
var dataSource = new kendo.data.DataSource({
transport: {
read: "orders.json"
},
serverPaging: true,
pageSize: 5 // 5 records per page
});
The serverSorting must be used in conjunction with the sort configuration. By default, a sort object is sent to the server with the query string in the following form:
It is possible to modify these parameters by using the parameterMap function found on the transport object (see transport in Configuration).
var dataSource = new kendo.data.DataSource({
transport: {
read: "orders.json"
},
serverSorting: true,
sort: { field: "orderId", dir: "asc" }
});
// sorts data ascending by orderId field
sort: { field: "orderId", dir: "asc" }
// sorts data ascending by orderId field and then descending by shipmentDate
sort: [ { field: "orderId", dir: "asc" }, { field: "shipmentDate", dir: "desc" } ]
transport
: Objectcreate
: Object | Stringvar dataSource = new kendo.data.DataSource({
transport: {
read: "orders.json",
create: {
url: "orders/create.json",
data: {
orderId: $("#input").val() // sends the value of the input as the orderId
}
}
}
});
dataType
: Stringurl
: Object | Stringdestroy
: Object | StringdataType
: Stringurl
: Object | StringparameterMap
: Functionvar dataSource = new kendo.data.DataSource({
transport: {
read: "Catalog/Titles",
parameterMap: function(options) {
return {
pageIndex: options.page,
size: options.pageSize,
orderBy: convertSort(options.sort)
}
}
}
});
read
: Object | String// settings various options for remote data transport
var dataSource = new kendo.data.DataSource({
transport: {
read: {
// the remote service URL
url: "http://search.twitter.com/search.json",
// JSONP is required for cross-domain AJAX
dataType: "jsonp",
// additional parameters sent to the remote service
data: {
q: function() {
return $("#searchFor").val();
}
}
}
}
});
// consuming odata feed without setting additional options
var dataSource = new kendo.data.DataSource({
type: "odata",
transport: {
read: "http://odata.netflix.com/Catalog/Titles"
}
});
data
: Object | FunctiondataType
: Stringurl
: Stringupdate
: Object | Stringvar dataSource = new kendo.data.DataSource({
transport: {
read: "orders.json",
update: {
url: "orders/update.json",
}
}
});
dataType
: Stringurl
: Object | Stringtype
: String