JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojox/grid/resources/claroGrid.css">
<div id="gridDiv"></div>
CSS
@import "{{baseUrl}}dojox/grid/resources/claroGrid.css";
/*Grid needs an explicit height by default*/
#grid {
height: 20em;
}
JavaScript
require(['dojo/_base/lang', 'dojox/grid/DataGrid', 'dojo/data/ItemFileWriteStore', 'dojo/dom', 'dojo/domReady!'],
function(lang, DataGrid, ItemFileWriteStore, dom){
/*set up data store*/
var data = {
identifier: "id",
items: []
};
var data_list = [
{ col1: "normal", col2: true, 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: true, col3: 'Signs can be selectively', col4: 19.34}
];
var rows = 60;
for(var i = 0, l = data_list.length; i < rows; i++){
data.items.push(lang.mixin({ id: i+1 }, data_list[i%l]));
}
var store = new ItemFileWriteStore({data: data});
/*set up layout*/
var layout = [[
{'name': 'Column 1', 'field': 'id', 'width': '150px'},
{'name': 'Column 2', 'field': 'col2', 'width': '100px'},
{'name': 'Column 3', 'field': 'col3', 'width': '200px'},
{'name': 'Column 4', 'field': 'col4', 'width': '150px'}
]];
function myStyleRow(row){
/* The row object has 4 parameters, and you can set two others to provide your own styling
These parameters are :
-- index : the row index
-- selected: whether or not the row is selected
-- over : whether or not the mouse is over this row
-- odd : whether or not this row index is odd. */
var item = grid.getItem(row.index);
if(item){
var type = store.getValue(item, "col2", null);
if(!!type){
row.customStyles += "color:#FF00FF;";
}
}
if(row.over)
{
row.customStyles += "background-color:#FF00FF;";
}
grid.focus.styleRow(row);
grid.edit.styleRow(row);
}
/*create a new grid*/
grid = new DataGrid({
id: 'grid',
store: store,
structure: layout,
onStyleRow:...