Quantcast

dojox.grid.DataGrid disable cell editing on specific rows

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

dojox.grid.DataGrid disable cell editing on specific rows

karlry
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: dojox.grid.DataGrid disable cell editing on specific rows

zhuxw
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, '&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]);
}
},

On Tue, Jul 10, 2012 at 10:30 PM, karlry <[hidden email]> wrote:
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

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/dojox-grid-DataGrid-disable-cell-editing-on-specific-rows-tp3987523.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
________________________________________________________
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


________________________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: dojox.grid.DataGrid disable cell editing on specific rows

karlry
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: dojox.grid.DataGrid disable cell editing on specific rows

zhuxw
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!

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

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/dojox-grid-DataGrid-disable-cell-editing-on-specific-rows-tp3987523p3987545.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
________________________________________________________
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


________________________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: dojox.grid.DataGrid disable cell editing on specific rows

karlry
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
Loading...