Print Page - General brainstorming for Note-taking software:: Heck, if it was just me, I cant even say which program is stage 4 - get a bunch of people who use these tools to Right now Ive just included a single "Note" field which http://www.donationcoder.com/Forums/bb/index.php?action=printpage;topic=2362.0HOME | I'm trying to conditionally disable/readonly an editable field in a edit grid row based upon a different field.
I built a custom render that changes the CSS to shaded, but can't change the field to readonly so they can't edit it. As you can see I've tried various statements I found digging through the forums.
Here's my renderer on a regular date field:
header: 'Comment',
dataIndex: 'SITCM',
width: 360,
hidden: false
, editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 60
}),
renderer: function(value,cell,record,columnIndex) {
var user = record.get("SITCU");
// var user2 = record.data.SITCU;
if( user != Ext.get('usrpf').dom.value ){
cell.css = "readonlycell";
// cell.addClass( 'readonly' );
// record.data.SITCM.setEditable( false );
// tcmColumnModel.setEditor(columnIndex,null);
// tcmColumnModel.setEditable( columnIndex, false );
// var colmodel = this.getColumnModel();
// var id = tcmColumnModel.getColumnId(columnIndex);
// this.setEditable(columnIndex , false);
}
return value;
}
Thanks in advance!
Looking it over again, I think it's confusing as it stands at the moment.
I think most of those options fall under 2 categories:
listen to beforeedit, return false depending on your business logic
override isCelleditable, return false depending on your business logic.
There's a setEditable method on the column model.
__________________
"It doesn't work" and "It's not working" are not adequate problem descriptions.
I tried setEditable and it doesn't work; meaning the field is still editable.
Here's my statement...
tcmColumnModel.setEditable( columnIndex, false );
...which is inside this renderer:
{
header: 'Comment',
dataIndex: 'SITCM',
width: 360,
sortable: false,
hidden: false
, editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 60 Prev:: rong>Disabled? Social Security - DisabilityGroup.comSocial Security Disability. We win 8 out of 10 cases. Free evaluation. http://results.aspx?q=[SOLVED!]+Cant+get+EditGrids+field+disabled/readonly+in+custom+renderer&first=10&FORM=PQREHOME | heidisql.googlecode.com:: Field: TField); procedure DBGridColEnter(Sender: Temporarily disable AutoReconnect in Registry // in case of cant connect -> close MDI-Child http://heidisql.googlecode.com/svn-history/r1596/trunk/source/childwin.pasHOME |
}),
renderer: function(value,cell,record,columnIndex) {
var user = record.get("SITCU"); heidisql.googlecode.com:: Field: TField); procedure DBGridColEnter(Sender: Temporarily disable AutoReconnect in Registry // in case of context menu; storing right click item so it wont get http://heidisql.googlecode.com/svn-history/r1431/trunk/source/childwin.pasHOME |
if( user != Ext.get('usrpf').dom.value ){
cell.css = "readonlycell"; tcmColumnModel.setEditable( columnIndex, false );
}
return value;
}
}
According to the docs (http://extjs.com/deploy/dev/docs/) this should work, but the field is still editable. I spent time trying to figure this out; an example in the docs would greatly help.
Thanks.
Thanks! That worked! (However, a checkbox is still editable)
Here's my code:
// Don't allow editing if not user's comment
tcmColumnModel.isCellEditable = function(col, row) {
var record = tcmDataStore.getAt(row);
if ( record.get('SITCU') != Ext.get('usrpf').dom.value ) { // replace with your condition
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call (this, col, row);
};
The business rule we have is a user can only change their comments; so I protect the row if it's not their comment.
Thanks!
checkboxes are a little painful to deal with -- they don't have an associated editor, so you'll need to hook into the grid's cellclick event and cancel the event if the checkbox column was clicked. Lighttpd:: solutions to small and big problems other httpds cant enable/disable WebDAV. webdav.is-readonly: enable/disable read only. field> <operator> <value> { <field http://redmine.lighttpd.net/wiki/lighttpd/export/specialHOME | WebAppList : eConsultant:: has some restrictions and features disabled. 16 Import Powerpoint files in both read-only and Click button and get ready to smite your foes with a custom-made curse straight http://www.econsultant.com/webapplist/HOME |
Thanks; I'll do that.
any reason why you're overriding the isCellEditable() method directly instead of employing grid listeners?
No; that's just the way I coded it from looking at Grid FAQ #28. Would that work better? Is that the standard?
Thanks for your help; this is more understandable to me and removes the blind spot I had! =D>
checkboxes are a little painful to deal with -- they don't have an associated editor, so you'll need to hook into the grid's cellclick event and cancel the event if the checkbox column was clicked.
any reason why you're overriding the isCellEditable() method directly instead of employing grid listeners?
...that's just the way I coded it from looking at Grid FAQ #28.
Hmmm. Option 1 and 4 both use listeners (Option 1 starts with "Use beforeedit and return false ...". The last couple options discuss checkbox stuff I think.
If anything is wrong or confusing in there let me know and I'll edit it. I don't personally verify everything that's in there.
Thanks; I'll do that.
No; that's just the way I coded it from looking at Grid FAQ #28. Would that work better? Is that the standard?
Thanks for your help; this is more understandable to me and removes the blind spot I had! =D>
never read the grid faq. ;)
if it's there though it's probably explained somwhere else in the faq why it's done that way.
personally though i'd stick with listeners for consistency -- i don't want to have to figure out months later why i overrode a function in one place and used listeners in another.
There's a setEditable method on the column model.
I've gone through the grid faq and now I'm completely confused...
Where would I put the code to disable the edit on a grid field?
header: 'Authorisation #',
dataIndex: 'crAuthNum',
width: 90,
// ,
renderer: function(value, cell, record, columnIndex){
cell.css = "editorcell";
return value;
},
editor: new Ext.form.NumberField({
allowBlank: false,
maxLength: 30
})
All I'm trying to do is disable the cell if there is already a value present...
Hmmm. Option 1 and 4 both use listeners (Option 1 starts with "Use beforeedit and return false ...". The last couple options discuss checkbox stuff I think.
If anything is wrong or confusing in there let me know and I'll edit it. I don't personally verify everything that's in there.
I can't figure out where to place the code though...
I tried this:
{
header: 'Authorisation #',
dataIndex: 'crAuthNum',
width: 90,
renderer: function(value, cell, record, columnIndex){
cell.css = "editorcell";
return value;
},
editor: new Ext.form.NumberField({
allowBlank: false,
maxLength: 30
}),
isCellEditable: function(col, row){
var record = store.getAt(row);
if (value == "") {
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call (this, col, row);
}
}
Obviously that's not right cos it ain't working :(
After your column model code you put this statement (or use a listener as Mystix recommends):...
Cool thanks,
will try and figure out the listener.
a column renderer is a function which is called once for every single field in a column.
using Firebug, try calling setEditable(1, false) on the editor grid's columnmodel in the online editor grid example (http://extjs.com/deploy/dev/examples/grid/edit-grid.html) to prove that it works.
what you're looking for is row-specific, so hook into the editorgrid's beforeedit (http://extjs.com/docs/?class=Ext.grid.EditorGridPanel&member=beforeedit) event instead, perform your decision-making process there, and then decide if the edit should commence (by returning true), or bail (by returning false).
No; it wasn't confusing. I used Option/Example 3 because it looked clean; I was able to add my condition if inside the function.
Option/Example 3
myColumnModel.isCellEditable = function(colIndex, rowIndex){ return !someBooleanStoredSomewhere; };
Any suggestions, anyone? I'm sure it's just a variation of the attempts I've made.
I've looked at several examples on other posts.
Thanks.
I'll leave as is unless someone has suggestions...
I agree. They can look through the various examples to find the one that best suits their situation.
After your column model code you put this statement (or use a listener as Mystix recommends):
// Column model:
tcmColumnModel = new Ext.grid.ColumnModel(
... // grid fields go here
);
...
// Don't allow editing if not user's comment
tcmColumnModel.isCellEditable = function(col, row) {
var record = tcmDataStore.getAt(row);
if ( record.get('SITCU') != Ext.get('usrpf').dom.value ) { // replace with your condition
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call (this, col, row);
};
I'll leave as is unless someone has suggestions...
I can't figure out where to place the code though...
I tried this:
{
header: 'Authorisation #',
dataIndex: 'crAuthNum',
width: 90,
renderer: function(value, cell, record, columnIndex){
cell.css = "editorcell";
return value;
},
editor: new Ext.form.NumberField({
allowBlank: false,
maxLength: 30
}),
isCellEditable: function(col, row){
var record = store.getAt(row);
if (value == "") {
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call (this, col, row);
}
}
Obviously that's not right cos it ain't working :(
You've got it inside your column model as a property; you want to move it outside of your column model definition - see my previous post:
// Column model:
tcmColumnModel = new Ext.grid.ColumnModel(
... // grid fields go here
); // eo colum model definition
...
// Don't allow editing if not user's comment
tcmColumnModel.isCellEditable = function(col, row) {
var record = tcmDataStore.getAt(row);
if ( record.get('SITCU') != Ext.get('usrpf').dom.value ) { // replace with your condition
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call (this, col, row);
};
You've got it inside your column model as a property; you want to move it outside of your column model definition - see my previous post:Ok, great. Thanks
None of the 6 options in Grid FAQ 28 helped you?
How much does getting a small tattoo on your hip/stomach hurt?
Do anyone else have an itchy anus? ?
|