Hello,
I trying to programatically filter my data in my grid. Here's my code:
[code]
var ds = {
type: "odata",
transport: {
read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers"
},
pageSize: 20,
group: {
field: "ContactTitle",
dir: "asc",
template: "Yo, I'm a template"
}
};
var g = $("#grid").kendoGrid({
dataSource: ds,
height: 550,
scrollable: true,
resizable: true,
groupable: true,
sortable: true,
groupable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [{
template: "<div class='customer-photo'" +
"style='background-image: url(../content/web/Customers/#:data.CustomerID#.jpg);'></div>" +
"<div class='customer-name'>#: ContactName #</div>",
field: "ContactName",
title: "Contact Name",
width: 240
}, {
field: "ContactTitle",
title: "Contact Title",
groupHeaderTemplate: "Yo, I'm a group for #= value #"
}, {
field: "CompanyName",
title: "Company Name"
}, {
field: "Country",
width: 150
}]
});
g.data().dataSource.filter({
"field" : "ContactName",
"operator" : "contains",
"value" : "Bernardo Batista"
});
[/code]
But this is giving me an error on the line:
g.data().dataSource.filter({...
The error message is: Uncaught TypeError: Cannot read property 'filter' of undefined.
How can I get my datasource from my grid? And then, how do I apply a filter to it?
Thank you.
I trying to programatically filter my data in my grid. Here's my code:
[code]
var ds = {
type: "odata",
transport: {
read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Customers"
},
pageSize: 20,
group: {
field: "ContactTitle",
dir: "asc",
template: "Yo, I'm a template"
}
};
var g = $("#grid").kendoGrid({
dataSource: ds,
height: 550,
scrollable: true,
resizable: true,
groupable: true,
sortable: true,
groupable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [{
template: "<div class='customer-photo'" +
"style='background-image: url(../content/web/Customers/#:data.CustomerID#.jpg);'></div>" +
"<div class='customer-name'>#: ContactName #</div>",
field: "ContactName",
title: "Contact Name",
width: 240
}, {
field: "ContactTitle",
title: "Contact Title",
groupHeaderTemplate: "Yo, I'm a group for #= value #"
}, {
field: "CompanyName",
title: "Company Name"
}, {
field: "Country",
width: 150
}]
});
g.data().dataSource.filter({
"field" : "ContactName",
"operator" : "contains",
"value" : "Bernardo Batista"
});
[/code]
But this is giving me an error on the line:
g.data().dataSource.filter({...
The error message is: Uncaught TypeError: Cannot read property 'filter' of undefined.
How can I get my datasource from my grid? And then, how do I apply a filter to it?
Thank you.