PDA

View Full Version : Need help with editable grid.



Erez Segal
21 Jul 2007, 6:15 PM
I tried the video about editable grid, and AJAX, but it ends in the middle...
I managed to create an editable grid.
My task is to trigger an event when a field is changed, (when the little red thing appers).
The event will run my code and decide wether to approve the change (the red thing needs to disappear) or deny the change (an error message will appear, and the red thing stays).

My Questions Are:

I have a function x. how do I set it to be the event handler when a field is changed?
How do I remove the red mark?
How do I make a field refresh from the server?


Thanks,
Erez Segal.

Erez Segal
21 Jul 2007, 6:57 PM
When this function is called, I need the old value, the new value and the Row's ID in it's scope.

sjivan
22 Jul 2007, 8:12 AM
Add an event handler for 'beforeedit' event of EditorGrid and return false if you want to reject the changes. Also check out validateedit.

http://extjs.com/deploy/ext/docs/output/Ext.grid.EditorGrid.html#event-beforeedit

http://extjs.com/deploy/ext/docs/output/Ext.grid.EditorGrid.html#event-validateedit

Sanjiv

Erez Segal
22 Jul 2007, 10:16 AM
Thanks. What about the red sign?

Erez Segal
22 Jul 2007, 11:22 AM
on my 'validateedit' Event Handler, I send the value using AJAX. until I get a response, the function is done.

So now, in my now "Ajax GOT RESPONSE" Event Handler, I need to do one of two things:

Restore the value, And remove the red sing
OR, Confirm the new value, and remove the red sign.


Any suggestions?

Erez Segal
22 Jul 2007, 11:32 AM
Let me rephrase.
Assuming I have the field's name, the record's ID and a value, how can I set the field's value in a specific row/record and remove the red sign?
I also don't have any field in scope, just the grid.

PFM
22 Jul 2007, 3:02 PM
You can do it one of two ways. Either reject or commit changes on the store, or get a reference to the modified record in the store and either commit or reject that change.



Restore the value, And remove the red sing

store.rejectChanges(); // this one is for the store
or
rec.reject(); // this one is for the record


Confirm the new value, and remove the red sign.

store.commitChanges(); // this one is for the store
or
rec.commit(); // this one is for the record

Erez Segal
22 Jul 2007, 4:14 PM
Thank you for your time.

Can I commit/reject just to the field?

How can I get the record Object if all I have is it's ID (or RowID or ColumnID)

Assuming I have to record object, how can I get the field Object and commit/reject only the field?

Erez Segal
23 Jul 2007, 9:59 AM
I tried looking for the record object manual, but didn't find it. I also couldn't figure out which object is the field that is inside a record, and how to commit/reject changes to it.