While using the Webix TreeTable view, I found a bug that occurs when you load data dynamically after filtering the table. Am I the only one experiencing this behaviour? This seems to me like something that is quite common to do while using a TreeTable, both as developer and user. Will this get fixed in the next release?
I am using Webix trial v2.1.1 as of November 24th 2014.
These are the steps to reproduce the issue:
- Load index.html
- Type “prod” into the text filter
- Open “Product 1”
- Clear the text filter
Result:
Uncaught TypeError: Cannot read property ‘length’ of undefined in webix_debug.js:11455
What follows is an example that anyone can use to reproduce the issue.
File structure
/
| js/
| | webix/
| | | webix.js
| | | ...
| | script.js
| index.html
| data.php
| data1.json
| data2.json
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Webix Test</title>
<script src="js/webix/webix.js"></script>
<script src="js/script.js"></script>
<link rel="stylesheet" href="js/webix/webix.css">
</head>
<body>
</body>
</html>
js/script.js
webix.ready(function () {
webix.ui({
view: "treetable",
columns: [
{ id: "name", header: ["Name", { content: "textFilter" }],
fillspace: true, template: "{common.treetable()} #name#" },
{ id: "price", header: "Price", width: 150 }
],
url: "data.php",
datatype: "json"
});
});
data.php
<?php
// Set the content type to JSON
header("Content-Type: text/json");
// Receive the parameter "parent" from the query string or set to null
$parent = isset($_GET["parent"]) ? $_GET["parent"] : null;
// Use one of two sets of data, depending on the value of $parent
if ($parent === null) {
echo file_get_contents("data1.json");
} else {
echo file_get_contents("data2.json");
}
data1.json
{
"parent": 0,
"data": [
{ "id": 1, "name": "Product 1", "price": 10, "webix_kids": 1 },
{ "id": 2, "name": "Product 2", "price": 5 },
{ "id": 3, "name": "Something else", "price": 100 }
]
}
data2.json
{
"parent": 1,
"data": [
{ "id": 4, "name": "Sub-Product 1", "price": 3 },
{ "id": 5, "name": "Sub-Product 2", "price": 4 }
]
}