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

5vf7fwbs  于 2022-12-08  发布在  Dojo
关注(0)|答案(1)|浏览(156)

Dojo的Datagrid的一个简单模板如下所示,我正在为更复杂的东西构建它。
例如,我如何根据同一行中field 1的onChange事件更新field 2的值?比如将field 1的值复制到field 2。问题是我没有特定单元格的id,将onChange放在layout或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();

}
xwbd5t1u

xwbd5t1u1#

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

相关问题