Skip to content

Instantly share code, notes, and snippets.

@ishitvagoel
Created July 4, 2014 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishitvagoel/ba1134b51d1909b254ed to your computer and use it in GitHub Desktop.
Save ishitvagoel/ba1134b51d1909b254ed to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Datatable Example</title>
<script src="http://yui.yahooapis.com/3.16.0/build/yui/yui-min.js"></script>
</head>
<body>
<script type="text/javascript">
YUI().use("node", "datatable", "datatable-sort", "json-stringify", "escape",
"datatable-datasource", "datasource-io", "datasource-jsonschema", function(Y) {
var myDataSource = new Y.DataSource.IO({source:"jsonrpc.cgi"}),
//The callback used as a parameter to sendRequest fucntion Line 49
myCallback = {
success: function(e){
alert(e.response);
Y.log(e.response);
},
failure: function(e){
alert("Could not retrieve data: " + e.error.message);
}
};
var json_object = {
version : "1.1",
method : "Bug.possible_duplicates",
id : "0", //Harcoded Value for YAHOO.bugzilla.dupTable.counter
params : {
// What values can we specify here for testing ?
//product : product_name, // What value can we specify here for testing ?
//summary : summary_field.value,
limit : 7,
include_fields : [ "id", "summary", "status", "resolution",
"update_token" ]
}
};
var post_data = Y.JSON.stringify(json_object);
myDataSource.plug(Y.Plugin.DataSourceJSONSchema, {
schema: {
resultListLocator : "result.bugs",
resultFields : [ "id", "summary", "status", "resolution",
"update_token" ]
}
});
myDataSource.sendRequest({
request:post_data ,
cfg: {
method: "POST",
headers: { 'Content-Type': 'application/json' }
},
callback: myCallback
});
var dt_columns = [
{ key: "id", label: "col_A",
},
{ key: "summary",
label: "col_B",
formatter: "text" },
{ key: "status",
label: "col_C",
},
{ key: "update_token", label: '',
}
];
Y.log(myDataSource);
var table= new Y.DataTable({
columns: dt_columns,
data: myDataSource
});
table.render("#new");
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment