<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.1/processing-api.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.4.1/dojox/grid/resources/Grid.css">
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4.1/dojo/dojo.xd.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div id="gridDiv" style="width:400px;height:400px;"></div>
</body>
</html>
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileReadStore");
dojo.addOnLoad(function() {
var data =
{ "head":
{
"vars": [ "s" , "fname" , "lname" ] } ,
"results": {
"bindings": [
{
"s":{"type": "uri1" , "value": "41" },
"fname": { "type": "literal" , "value": "Gayathri" } ,
"lname": { "type": "literal" , "value": "Vasudevan" }
} ,
{
"s":{"type": "uri6" , "value": "39" },
"fname": { "type": "literal" , "value": "Magesh" } ,
"lname": { "type": "literal" , "value": "Vasudevan" }
},
{
"s":{"type": "uri27" , "value": "text" },
"fname": { "type": "literal" , "value": "Yahoo" } ,
"lname": { "type": "literal" , "value": "VHoodlum" }
},
{
"s":{"type": "uri6" , "value": "39" },
"fname": { "type": "literal" , "value": "Magesh" } ,
"lname": { "type": "literal" , "value": "Vasudevan" }
},
{
"s":{"type": "uri6" , "value": "39" },
"fname": { "type": "literal" , "value": "Magesh" } ,
"lname": { "type": "literal" , "value": "Vasudevan" }
},
{
"s":{"type": "uri6" , "value": "39" },
"fname": { "type": "literal" , "value": "Magesh" } ,
"lname": { "type": "literal" , "value": "Vasudevan" }
}
]
}
};
var urlColmn = 'AnotherGrid';
var items = dojo.map(data.results.bindings, function(binding) {
return {
fname : binding.fname.value,
lname : binding.lname.value,
s: binding.s.value
};
});
var store = new dojo.data.ItemFileReadStore({
data : {
items : items
}
});
var layout = [[
{ field : "fname", name : "First Name", width : "33%"},
{ field : "lname", name : "Last Name", width : "33%" },
{ field : "s", name : "url", width : "33%", formatter:"Integer"}
]];
var grid = new dojox.grid.DataGrid({
store : store,
structure : layout,
rowsPerPage: 10
});
function _createGrid(store) {
grid.placeAt("gridDiv");
grid.update();
grid.startup();
return grid;
}
_createGrid(store);
});
dojo.addOnLoad(function() {
var data_items = {"committees":[{"cname":"test data","office":"","term":"2015"}],"boardcertifications":[{"area":"Bustion","year":"2012"},{"area":"Conaw","year":"2005"},{"area":"Cl","year":"2013"}],"sections":[{"sname":"Real Property, Probate Law"},{"sname":"Trial Lawyers"}]};
var d_iems_committees =
dojo.map(data_items.committees,function(resultSet)
{
return {
cname: resultSet.cname,
office: resultSet.office,
term: resultSet.term
};
});
var d_data =
{
items: d_iems_committees
};
var d_store = new dojo.data.ItemFileReadStore({
identifier: 'cname',
data: d_data
});
var d_layout = [[
{'name': 'Committee name', 'field': 'cname', 'width': '200px'},
{'name': 'Office', 'field': 'type', 'width': '50px'},
{'name': 'Term', 'field': 'term', 'width': '50px'}
]];
var d_grid = new dojox.grid.DataGrid({
store : d_store,
structure : d_layout,
rowsSelector: '20px'
});
function _createGrid2(d_store) {
d_grid.placeAt("gridDiv2");
d_grid.update();
d_grid.startup();
return d_grid;
}
_createGrid2(d_store);
var d_iems_board =
dojo.map(data_items.boardcertifications,function(bcResultSet)
{
return {
area: bcResultSet.area,
year: bcResultSet.year
};
});
});
Output
This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account
Dismiss xKeyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |