PDA

View Full Version : grid: flagging cell changes in the renderer



notjoshing
7 Mar 2008, 8:17 AM
I have a paging editor grid where I add my own highlighting to records flagged as changed either from the server, or through user interaction with the grid. I've hacked a way to do this using an object populated with the grid, to which changes are added with beforeedit. The renderer uses this object to appropriately highlight cells.

It would be much more convenient, though, if the object fed into the renderer had some sort of flag to indicate that the data had changed. Have I missed something?

Josh

mjlecomte
7 Mar 2008, 8:40 AM
Have you looked at getChanges (http://extjs.com/deploy/dev/docs/?class=Ext.data.Record&member=getChanges) & isModified (http://extjs.com/deploy/dev/docs/?class=Ext.data.Record&member=isModified)?

Also, by default ext applies a red triangle to modified fields indicating they are 'dirty'. Depending on what you're looking for maybe you just alter the css for that?

notjoshing
7 Mar 2008, 11:33 AM
&getChanges and &isModified both take a field name as an argument. The field name, though, is not one of the parameters passed to the renderer:

* value : Object
The data value for the cell.

* metadata : Object
An object in which you may set the following attributes:
o css : String
A CSS class name to add to the cell's TD element.
o attr : String
An HTML attribute definition string to apply to the data container element within the table cell (e.g. 'style="color:red;"').

* record : Ext.data.record
The Ext.data.Record from which the data was extracted.

* rowIndex : Number
Row index

* colIndex : Number
Column index

* store : Ext.data.Store
The Ext.data.Store object from which the Record was extracted.
How are you proposing getting the name of the field? Through the column model?

Josh

mjlecomte
7 Mar 2008, 11:52 AM
I'm not necessarily "proposing" anything. I don't understand your application (business logic) nor have you posted any code that I might understand better what you're trying to do. Are you trying to keep track of unsaved / dirty records across numerous paged records?

The underlying area that I was trying to point you to was "dirty". Depending on what you're doing tracking which records are dirty might help you.

I recall reading about this in forums before so you can also search the forums for more info.

notjoshing
10 Mar 2008, 8:29 AM
Are you trying to keep track of unsaved / dirty records across numerous paged records?
In part, yes. The application acts as a go-between for tracking changes which authorized users will later make into a restricted access system through a separate application. Because of this, changes between pages need to appear, but we also need to save records back to the database and have them show up as changed from the original data for all users.

I don't understand your application (business logic) nor have you posted any code that I might understand better what you're trying to do.
Hopefully you understand the business logic a bit better from what I posted above. I have this functionality up and running, and figuring out how to do it was not the thread's intent. Because of that, I have not posted code. I simply wanted to know what approach others would take to the task, other than interacting a renderer with a custom object tracking changes from the server and the grid.

I recall reading about this in forums before so you can also search the forums for more info.
Thanks for the recommendation. I posted in part because I originally found nothing that seemed to answer my question.

Josh