禁用或启用dojox数据网格中选择性单元格的编辑

禁用或启用dojox数据网格中选择性单元格的编辑,dojo,dojox.grid.datagrid,dojox.grid,xpages-extlib,Dojo,Dojox.grid.datagrid,Dojox.grid,Xpages Extlib,如何禁用或启用dojox数据网格中选择性单元格的编辑,即 假设我在一个数据网格中有两列(A,B)。我希望B列的值可以基于A列的值进行编辑。我在stack overflow中看到了一个特定于DOJO版本的解决方案。我想知道是否有API可以实现上述目标。没有API。我最近也有类似的要求,下面是我如何实现它的: 1) 最初,列B是可编辑的,因为我在网格的字段部分这样做了 2) 使用onRowClick捕获行的呈现。像这样的事情应该可以 dojo.connect(grid, "onRowClick",

如何禁用或启用dojox数据网格中选择性单元格的编辑,即


假设我在一个数据网格中有两列(A,B)。我希望B列的值可以基于A列的值进行编辑。我在stack overflow中看到了一个特定于DOJO版本的解决方案。我想知道是否有API可以实现上述目标。

没有API。我最近也有类似的要求,下面是我如何实现它的:

1) 最初,列B是可编辑的,因为我在网格的字段部分这样做了 2) 使用onRowClick捕获行的呈现。像这样的事情应该可以

dojo.connect(grid, "onRowClick", grid, function(evt){
  var idx = evt.rowIndex,
  item = this.getItem(idx);

  //  get a value out of the item
  msname = this.store.getValue(item, "msname");
  if(msname != null &U& (trim(msname) == trim(offsetName))) {
    dojox.grid.cells._Base.prototype.format(idx, item);
  }
});
然后,以下方法不允许对所需列进行内联编辑。我们正在将行索引和列索引传递给以下函数:

dojox.grid.cells._Base.prototype.format = function(inRowIndex, inItem){
    var f, i=grid.edit.info, d=this.get ? this.get(inRowIndex, inItem) : (this.value || this.defaultValue);
    d = (d && d.replace && grid.escapeHTMLInData) ? d.replace(/&/g, '&amp;').replace(/</g, '&lt;') : d;

                //Check inRowIndex and inItem to determine whether to be editable for this row here.

    if(this.editable && (this.alwaysEditing || (i.rowIndex==inRowIndex && i.cell==this))){
    return this.formatEditing(d, inRowIndex);
    }else{
    return this._defaultFormat(d, [d, inRowIndex, this]);
    }
}
dojox.grid.cells.\u Base.prototype.format=函数(inRowIndex,inItem){
变量f,i=grid.edit.info,d=this.get?this.get(inRowIndex,inItem):(this.value | | this.defaultValue);

d=(d&&d.replace&&grid.escapeHTMLInData)?d.replace(/&/g,&&;)。replace(/我首选的方法是重写

canEdit:function(inCell,inRowIndex)

方法。从中,您可以获得以下项:

this.getItem(inRowIndex)

然后计算它是否应该是可编辑的,并返回true/false


但是,这会覆盖列上的可编辑标志,因此如果需要,您需要对其进行处理。

我将尝试一下,并让您知道结果。感谢您的快速帮助。您能否解释dojox.grid.cells.\u Base.prototype.format函数的作用?在该上下文中,这是什么?