|
Hi,
I have a grid with cells that are enabled for editing. There are rows that I would like to lock from editing though. Does anyone have any pointers on how to achieve that? Preferably I would like to have the alwaysEditing property on the editable rows as well. Regards Karl |
|
Hi, there is no convenient API for this but you can override the format function in dojox.grid.cells._Base:
dojox.grid.cells._Base.prototpye.format = function(inRowIndex, inItem){
// summary: // provides the html for a given grid cell.
// inRowIndex: int // grid row index // returns: html for a given grid cell
var f, i=this.grid.edit.info, d=this.get ? this.get(inRowIndex, inItem) : (this.value || this.defaultValue);
d = (d && d.replace && this.grid.escapeHTMLInData) ? d.replace(/&/g, '&').replace(/</g, '<') : 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]);
} }, On Tue, Jul 10, 2012 at 10:30 PM, karlry <[hidden email]> wrote: Hi, ________________________________________________________ Dojotoolkit: http://dojotoolkit.org Reference Guide: http://dojotoolkit.org/reference-guide API Documentation: http://dojotoolkit.org/api Tutorials: http://dojotoolkit.org/documentation [hidden email] http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Best Regards
------------- Oliver |
|
Hi, thank you very much for your help. that looks like exactly what i wanted!
Could you please tell me where to put the code, how to override the function? I'm not 100% when it comes to prototype... Many thanks Karl |
|
Hi, if you change the prototype, it'll affect all grids in your page. But this is the simplest way.
Otherwise you can create a subclass of dojox.grid.cells._Base, and assign this subclass to the "type" attribute of the column declaration.
On Wed, Jul 11, 2012 at 3:17 PM, karlry <[hidden email]> wrote: Hi, thank you very much for your help. that looks like exactly what i wanted! ________________________________________________________ Dojotoolkit: http://dojotoolkit.org Reference Guide: http://dojotoolkit.org/reference-guide API Documentation: http://dojotoolkit.org/api Tutorials: http://dojotoolkit.org/documentation [hidden email] http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Best Regards
------------- Oliver |
|
Hi,
I've implemented the method like this dojox.grid.cells._Base.prototype.format = function(inRowIndex, inItem){ // summary: // provides the html for a given grid cell. // inRowIndex: int // grid row index // returns: html for a given grid cell var f, i=this.grid.edit.info, d=this.get ? this.get(inRowIndex, inItem) : (this.value || this.defaultValue); d = (d && d.replace && this.grid.escapeHTMLInData) ? d.replace(/&/g, '&').replace(/</g, '<') : d; //Check inRowIndex and inItem to determine whether to be editable for this row here. //custom code here // console.debug(inItem); if(inItem != null && inItem.type == 'group') { return this._defaultFormat(d, [d, inRowIndex, this]); } else if(this.editable && (this.alwaysEditing || (i.rowIndex==inRowIndex && i.cell==this))){ return this.formatEditing(d, inRowIndex); } else{ return this._defaultFormat(d, [d, inRowIndex, this]); } }; and it almost works. only problem is that if someone clicks in the cell which has no value it changes to "...". could this have to do with the fact that I've implemented a format function and a onStyleRow? Or is it something wrong with my implementation? Thanks |
| Powered by Nabble | Edit this page |
