JSFiddle - React, Tailwind, and code Playground
by Aditya Shrivastava
HTML
<div id="gridDiv"></div>
CSS
@import "http://dojotoolkit.org/reference-guide/1.8/_static/js/dojo/resources/dojo.css";
@import "http://dojotoolkit.org/reference-guide/1.8/_static/js/dijit/themes/claro/claro.css";
@import "http://dojotoolkit.org/reference-guide/1.8/_static/js/dojox/grid/enhanced/resources/claro/EnhancedGrid.css";
@import "http://dojotoolkit.org/reference-guide/1.8/_static/js/dojox/grid/enhanced/resources/EnhancedGrid_rtl.css";
/*Grid need a explicit width/height by default*/
#grid {
width: 43em;
height: 20em;
}
.yellowishRow {
background-color: #878F;
}
JavaScript
dojo.require("dojox.grid.EnhancedGrid");
dojo.require("dojox.grid.enhanced.plugins.Filter");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.ready(function(){
/*set up data store*/
var data = {
identifier: 'id',
items: []
};
var data_list = [
{ col1: "normal", col2: false, col3: 'But are not followed by two hexadecimal', col4: 29.91},
{ col1: "important", col2: false, col3: 'Because a % sign always indicates', col4: 9.33},
{ col1: "important", col2: false, col3: 'Signs can be selectively', col4: 19.34}
];
var rows = 200;
for(var i=0, l=data_list.length; i<rows; i++){
data.items.push(dojo.mixin({ id: i+1 },data_list[i%l]));
}
var store = new dojo.data.ItemFileWriteStore({data: data});
/*set up layout*/
var layout = [[
{name: 'Column 1', field: 'id', datetype: 'number'},
{name: 'Column 2', field: 'col2', datetype: 'string'},
{name: 'Column 3', field: 'col3', datetype: 'string'},
{name: 'Column 4', field: 'col4', datetype: 'string'}
]];
/*create a new grid:*/
var grid = new dojox.grid.EnhancedGrid({
id: 'grid',
store: store,
structure: layout,
rowSelector: '20px',
plugins: {
filter: {
isServerSide: true,
setupFilterQuery: function(commands, request)
{
if(commands.enable && commands.filter)
{
grid.setFilter([{
type: 'string',
column: 1,
condition: 'startsWith',
value: 'XXX'
}, {
type: 'number',
column: 0,
condition: 'lessthan',
value: 100
}], 'logicany');
}
}
}
}
},...