作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我能够将标题中的文本居中,使用这个:
[colid="startstop"].gridxCell{
text-align: center;
}
我认为这会使属于 startstop 列的所有行单元格居中,但事实并非如此。我的 startstop 列在每一行中包含一个按钮。我还有另外两列是这样的。如何让我选择的三列中的按钮居中?
这是我的结构的一部分:
{ 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);
}
},
这是我的 css 类 - 它现在只处理按钮的大小,因为我在让它自己工作时遇到其他麻烦 - 但这是另一个问题。
.startStopButton .dijitButtonNode {
width: 16px;
height: 16px;
text-align: center;
}
最佳答案
如果要在单元格中包含小部件,建议使用 widgetsInCell
标志,以及 onCellWidgetCreated
和 setCellValue
方法(如记录 here )。
下面是我如何使用带有水平 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);
}
},
关于css - 如何在我的 dojo GridX 中将我的按钮置于我选择的特定列中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26765830/
我是一名优秀的程序员,十分优秀!