Set DataSource
This is to test if I can change the DataSource data, rebind it to the grid and keep the Date formatting and filtering
by VtoCorleone
HTML
<script src="http://cdn.kendostatic.com/2012.3.1315/js/kendo.web.min.js"></script>
<link rel="stylesheet" href=" http://cdn.kendostatic.com/2012.3.1315/styles/kendo.default.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.common.min.css">
<div id="testGrid"></div>
JavaScript
var firstNames = ["Nancy", "Andrew", "Janet", "Margaret", "Steven", "Michael", "Robert", "Laura", "Anne", "Nige"],
lastNames = ["Davolio", "Fuller", "Leverling", "Peacock", "Buchanan", "Suyama", "King", "Callahan", "Dodsworth", "White"],
birthDates = [new Date("1948/12/08"), new Date("1952/02/19"), new Date("1963/08/30"), new Date("1937/09/19"), new Date("1955/03/04"), new Date("1963/07/02"), new Date("1960/05/29"), new Date("1958/01/09"), new Date("1966/01/27"), new Date("1966/03/27"), new Date("1973/01/12"), new Date("1983/12/01"), new Date("1969/03/30"), new Date("1992/04/09"), new Date("1993/08/12")];
function createRandomData(count) {
var data = [],
now = new Date();
for (i = 0; i < count; i++) {
var id = i,
firstName = firstNames[Math.floor(Math.random() * firstNames.length)],
lastName = lastNames[Math.floor(Math.random() * lastNames.length)],
birthDate = birthDates[Math.floor(Math.random() * birthDates.length)];
data.push({
Id: id,
FirstName: firstName,
LastName: lastName,
DOB: birthDate
});
}
return data;
}
var columnDefinitions = [{
field: "FirstName",
title: "First Name"
}, {
field: "LastName",
title: "Last Name",
filterable: {
extra: false,
operators:{
string: {
contains: "Contains",
eq: "Is equal to",
startswith: "Starts with"
}
}
}
}, {
field: "DOB",
title: "DOB",
sortable: false,
filterable: false,
template: "#= kendo.toString(DOB,'MM/dd/yyyy') #"
}];
var randomData = createRandomData(1000);
var gridDataSource = {
data: randomData,
pageSize: 100,
scrollable: {
virtual: true
}
};
function createGrid() {
$("#testGrid").html("").kendoGrid({
dataSource: gridDataSource,
columns: columnDefinitions,
...