私は道場を使い始めたばかりで、それをいじり始めました。基本的に私がしたいのは、2つの列AとBを持つテーブルがあることです。列Bのセルは、列Aの値に応じてロックまたは編集可能になります。
レイアウトで定義されている列レベルではなく、セルレベルで編集可能なプロパティを設定する方法はありますか?
フォーマッタを使用してみましたが、正しく動作しません。
グリッド関数をオーバーライドできますonCellDblClick
が、これはバージョン固有のコードです。ページでdojo.versionが変更された場合、グリッドEvent.jsは他の動作をする可能性があります。次のスニペットは、バージョン1.7.2の.../dojox/grid/_Event.jsから取得したものです。
セルをダブルクリックして編集を開始するように設定されている場合(デフォルトの動作)、return
次の場所に適切に配置して、単に無視することを選択できます。
var customOnEditActivate = function(e){
// summary:
// Event fired when a cell is double-clicked.
// e: Event
// Decorated event object contains reference to grid, cell, and rowIndex
var event;
if(this._click.length > 1 && has('ie')){
event = this._click[1];
}else if(this._click.length > 1 && this._click[0].rowIndex != this._click[1].rowIndex){
event = this._click[0];
}else{
event = e;
}
////
// entrypoints of interest: event.cell & event.cellNode(.innerHTML)
// As example we could ignore editing mode if cell contains 'NON_EDITABLE'
if(cell.innerHTML.match("NON_EDITABLE"))
return;
//
////
this.focus.setFocusCell(event.cell, event.rowIndex);
this.onRowClick(event);
this.edit.setEditCell(event.cell, event.rowIndex);
this.onRowDblClick(e);
},
したがって、グリッドを初期化するときに、configパラメーターonCellDblClick
を上記の関数に設定します。
require(["dojox/grid/DataGrid"], function(DataGrid) {
var grid = new DataGrid({
onCellDblClick: customOnEditActivate
});
});
また
<div
data-dojo-type="dojox.grid.DataGrid"
data-dojo-props="onCellDblClick: customOnEditActivate"
></div>
あなたはオーバーライドすることができます
canEdit: function(inCell, inRowIndex)
DataGridのメソッド。それから、あなたはアイテムを得ることができます:
this.getItem(inRowIndex)
次に、編集可能かどうかを判断し、true/falseを返します。
私は次のことを実行しました(Ed Jellardの提案と同様):
<script type="dojo/require">
jsonRestStore : "dojox/data/JsonRestStore",
contentPane : "dijit/layout/ContentPane",
dataGrid : "dojox/grid/DataGrid"
</script>
<div dojoType="dijit.layout.ContentPane">
<script type="dojo/method">
configStore = new dojox.data.JsonRestStore
( { target : "/data/config",
idAttribute : "propertyName" } );
configStructure =
[ {field:'propertyName', name:'Property - Name',
width:20},
{field:'value', name:'Value',
editable:true},
{field:'guiConfigurable', name:'Property Type'},
{field:'description', name:'Description'}
];
</script>
</div>
<table data-dojo-type="dojox.grid.DataGrid"
store="configStore"
structure=configStructure>
<script type="dojo/method" event="canSort" args="sortInfo">
return false;
</script>
<script type="dojo/method" event="onApplyCellEdit" >
configStore.save();
</script>
<script type="dojo/method" event="canEdit" args="inCell, inRowIndex">
var gc = this.getItem(inRowIndex).guiConfigurable;
return gc == 'W' || gc == 'D';
</script>
<tbody/>
</table>