如何使用来自另一个单元格的 onChange 事件更新一个单元格

How to update one cell using the onChange Event from another cell?

本文关键字:单元格 更新 一个 事件 onChange 何使用 另一个      更新时间:2023-09-26

道场数据网格的简单模板如下,我正在为更复杂的东西构建它。

例如,如何根据同一行的字段 1 的 onChange 事件更新字段 2 的值?就像将字段 1 的值复制到字段 2 一样。问题是我没有特定单元格的 id,在布局下放置 on Change 或 addRow() 似乎都不对,并且似乎不能使用 onChange:function(){...}?

/*set up data store*/
var data = {
  identifier: "id",
  items: []
};

var store = new dojo.data.ItemFileWriteStore({data: data});
/*set up layout*/
var layout = [
defaultCell: {
    editable: true,
    type: dojox.grid.cells._Widget
}
rows: [
    {name: 'ID', field: 'id', width: '30px', widgetClass: dijit.form.TextBox, editable: false},
{name: 'ColA', field: 'field1', width: '100px', widgetClass: dijit.form.TextBox},
{name: 'ColB', field: 'field2', width: '100px', widgetClass: dijit.form.TextBox}
]
];
/*create a new grid*/
var grid = new dojox.grid.DataGrid({
    id: 'grid',
    store: store,
    structure: layout,
singleClickEdit: true,
    rowSelector: '15px'});
/*append the new grid to the div*/
grid.placeAt("gridDiv");
/*Call startup() to render the grid*/
grid.startup();

function addRow(){
    store.newItem({
    id: grid.rowCount,
    field1: '-',
    field2: '-'});
    grid.render();
}

尝试改用onApplyCellEditin(Value, inRowIndex, inFieldIndex)