2017-03-05 53 views
0

我想更改通過dgrid/editor插入到OnDemandGrid中的窗口小部件的寬度。模板文件通過調用this.ruleLinesColumns()來設置列,該列返回函數返回的列。我通過下面的代碼將dgrid/editor插件插入列中。默認情況下,小部件的寬度設置爲比列寬寬很多。我想將其設置爲100%,以便它適合列,而不是通過它。如何更改OnDemandGrid中的窗口小部件的寬度

這裏是我的文件:

模板文件

<div data-dojo-type="dijit/layout/ContentPane" 
     data-dojo-props="region: 'center', gutters: false"> 

     <div data-dojo-type="dgrid/OnDemandGrid" 
      data-dojo-mixins="dgrid/Selection, dgrid/extensions/DijitRegistry, prophet/common/dgrid/_StandardGridMixin, prophet/common/dgrid/_TreeRowHighlightingMixin" 
      data-dojo-attach-point="ruleLinesGrid" 
      data-dojo-props="'class': 'grid', 
           store: this.ruleLinesStore, 
           columns: this.ruleLinesColumns(), 
           sort: 'sequence', 
           selectionMode: 'single', 
           deselectOnRefresh: false"> 
    </div> 
</div> 

當我設置列

ruleLinesColumns: function() { 
    var self = this; 
    return [ 
     ... 
     editor({ 
      field: "training", 
      label: msgs.editor.training, 
      sortable: false, 
      required: true, 
      autoSave: true 
     }, NumberTextBox), 
     ... 
    ]; 
}, 

我已經嘗試了幾種不同的東西,例如包括style: {width: '100%'}width: '100%'但似乎沒有任何工作。

這裏的文檔dgrid /編輯: https://github.com/SitePen/dgrid/blob/master/doc/components/mixins/Editor.md

回答

0

我能找到答案!

由於列窗口小部件正通過dgrid /編輯器傳入,因此實際上可以在editorArgs的內部包含您需要爲NumberTextBox設置的所有內容。

例如,我必須得到寬度widget的100%,並確保該數字框只能輸入正整數,同時也使需要

editor({ 
    field: "training", 
    label: msgs.editor.training, 
    sortable: false, 
    autoSave: true, 
    editorArgs: { 
     required: true, // Since required isn't part of editor's field, I had to put it into editorArgs as well 
     constraints: {min: 0, places: 0}, 
     style: {width: '100%'} 
    } 
}, NumberTextBox), 
相關問題