Hello,
I am new to Kendo UI. I am trying to create a hierarchy grid with two json data sources with the following code (two json files at the bottom of the post). The filter doesn't seem to take any effect. All movies are listed for both categories. It is the same when I change the filter to 'filter: { "field": "category", "operator": "eq", "value": "Drama"}'. What am I missing? Thanks.
<div id="example">
<div id="grid"></div>
<script>
$(document).ready(function() {
var element = $("#grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: "https://www.example.com/category.json"
},
schema: {
data: "categories"
},
pageSize: 6,
serverPaging: true,
serverSorting: true
},
height: 600,
sortable: true,
pageable: true,
detailInit: detailInit,
dataBound: function() {
this.expandRow(this.tbody.find("tr.k-master-row").first());
},
columns: [
{
field: "categoryName",
title: "Category",
width: "110px"
},
{
field: "description",
title: "Description",
width: "110px"
}
]
});
});
function detailInit(e) {
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: {
type: "json",
transport: {
read: "https://www.example.com/movie.json"
},
schema: {
data: "movies"
},
serverPaging: true,
serverSorting: true,
serverFiltering: true,
pageSize: 100,
filter: { field: "category", operator: "eq", value: e.data.categoryName }
},
scrollable: false,
sortable: true,
pageable: true,
columns: [
{ field: "title", width: "110px" },
{ field: "year", width: "110px" }
]
});
}
</script>
</div>
#############################################################
category.json:
{
"categories": [
{
"categoryName": "SciFi",
"description": "SciFi movies since 1970"
},
{
"categoryName": "Drama",
"description": "Drama movies since 1990"
}
]
}
###############################################################
movie.json:
{
"movies": [
{ "title": "Star Wars: A New Hope", "year": 1977, "category": "SciFi" },
{ "title": "Star Wars: The Empire Strikes Back", "year": 1980, "category": "SciFi" },
{ "title": "Star Wars: Return of the Jedi", "year": 1983, "category": "SciFi" },
{ "title": "The Shawshenk Redemption", "year": 1994, "category": "Drama" },
{ "title": "Fight Club", "year": 1999, "category": "Drama" },
{ "title": "The Usual Suspects", "year": 1995, "category": "Drama" }
]
}