css - 如何在我的 dojo GridX 中将我的按钮置于我选择的特定列中?

标签 css button dojo dijit.form dojo.gridx

我能够将标题中的文本居中,使用这个:

[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 标志,以及 onCellWidgetCreatedsetCellValue 方法(如记录 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/

相关文章:

jquery - 如何使用Jquery使图像适合div

html - 将 flex 元素定位在最后一行或特定行

javascript - 难以将 xstyle 加载为 dojo 依赖项

javascript - 提交时文本区域验证

dojo - 如何更改 Dojo 数据网格中的单个单元格值

javascript - 在页面构建器 WP 上自动删除斜杠

css - 2个div在同一行,但是第二个div加了一个短的宽度后会换行,为什么?

javascript - 插入带有innerHTML的Facebook登录按钮在Chrome中不起作用

android - 如何在我的应用程序中添加 android 菜单溢出图标

button - yii 中条目的下一个/上一个按钮的最佳方式