I was able to center the text within the header, using this:
[colid="startstop"].gridxCell{
text-align: center;
}
I thought this would center all row cells belonging to the startstop column, but it doesn't. My startstop column contains a single button in each row. I have two other columns just like this. How do I center the buttons in the three columns of my choosing?
Here is a peice of my structure:
{ id: 'startstop', field: 'startstop', name: 'Start/Stop', width: '61px',
widgetsInCell: true,
navigable: true,
allowEventBubble: true,
decorator: function(){
//Generate cell widget template string
return [
'<button data-dojo-type="dijit.form.Button" ',
'data-dojo-attach-point="btn" ',
'class="startStopButton" ',
'data-dojo-props= ',
'"onClick: function(){',
'alert(\'Start/Stop\');',
'}"><img src="images/1413390026_control.png" /></button>'
].join('');
},
setCellValue: function(data){
//"this" is the cell widget
this.btn.set('label', data);
}
},
Here is my css class - it only does the size of the button for now as I am having other troubles getting it to work by itself - but that's another question.
.startStopButton .dijitButtonNode {
width: 16px;
height: 16px;
text-align: center;
}
If you want to include widgets in a cell, it is recommended to use the widgetsInCell
flag, along with the onCellWidgetCreated
and setCellValue
methods (as documented here).
Here is how I use a cell with a horizontal slider:
{
id: 'scoreColId',
field: 'score',
name: 'Score',
width: '15%',
// flag there are widgets in cell so that they are destroyed when grid is destroyed
widgetsInCell: true,
// method to create the widget (no cell-specific data yet)
onCellWidgetCreated: function(cellWidget, column) {
// outer div to center align the widget inside placed in the cell
var outerDiv = domConstruct.create('div', {
style: {
'text-align': 'center'
}
}, cellWidget.domNode);
// create the widget and place it in the div (already inside the cell)
cellWidget.slider = new HorizontalSlider({
minumum: 0,
maximum: 10,
});
cellWidget.slider.placeAt(outerDiv);
},
// set each cell with it's specific data
setCellValue: function(gridData, storeData, cellWidget) {
var score = gridData.docScore;
cellWidget.slider.set('value', score);
}
},