YUI DataTable with JSON and client side filtering Data Error
Posted
by user316574
on Stack Overflow
See other posts from Stack Overflow
or by user316574
Published on 2010-04-14T14:10:40Z
Indexed on
2010/04/14
14:13 UTC
Read the original article
Hit count: 623
Hi, I don't understand what I'm doing wrong here ! I keep getting a Data Error. But I validated the JSON and it's ok...
Here is the javascript from the YUI Datatble example (slightly modified).
<div class="markup">
<label for="filter">Filter by state:</label> <input type="text" id="filter" value="">
<div id="tbl"></div>
-->
YAHOO.util.Event.addListener(window, "load", function() {
//var Ex = YAHOO.namespace('example');
var dataSource = new YAHOO.util.DataSource("jsondb/json_meta_proxy.html",{
responseType : YAHOO.util.DataSource.TYPE_JSON,
responseSchema : {
resultsList: "records",
fields: [
{key:"idprojet"},
{key:"nomprojet"}
],
metaFields: {
totalRecords: "totalRecords"
}
},
doBeforeCallback : function (req,raw,res,cb) {
// This is the filter function
var data = res.results || [],
filtered = [],
i,l;
if (req) {
req = req.toLowerCase();
for (i = 0, l = data.length; i
and here is the JSON data in the file "jsondb/json_meta_proxy.html"
{
"recordsReturned": 1,
"totalRecords": 1,
"startIndex": 0,
"sort": "idprojet",
"dir": "asc",
"records": [
{
"idprojet": "11256",
"nomprojet": ""
}
]
}
Many thanks for your help !!!
© Stack Overflow or respective owner