The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

TLCinAction (32) [Avatar] Offline
#1
I have a complex form with a nested grid. I have enabled the grid with RowEditor plugin. I am having trouble with the placement of the listener. I understand from the docs/examples/posts that the listener is placed on the "editor" itself. Any help is appreciated. This code is based on the ch16 example from the book


http://www.extpaste.com/#3142
jesus.garcia (463) [Avatar] Offline
#2
Re: Placement of Listener for RowEditor
Listeners are generally configured and implemented by the code instantiating the class.
TLCinAction (32) [Avatar] Offline
#3
Re: Placement of Listener for RowEditor
I tried that, I believe. I put it on the form that calls this class with my grid code, and can understand that the listener then would be on the grid, but with RowEditor the listener needs to be on the rowEditor, correct?

I am thinking if I place something like this it will work
------------
var editor = new Ext.ux.grid.RowEditor({
saveText: 'Update'
});
editor.on (fire this event)
----------
and then listen for the event on the instanitating class?
jesus.garcia (463) [Avatar] Offline
#4
Re: Placement of Listener for RowEditor
What RowEditor events are you trying to 'listen' to? Are you sure that they are published events?
TLCinAction (32) [Avatar] Offline
#5
Re: Placement of Listener for RowEditor
afteredit, canceledit.

I did this and the message box fired. I am going to go ahead and create a function to do my AJAX call to my php.

Then I need to figure out how to refer the store to reload since right now the editor is outside the grid class. Should I be defining the editor up 1 level on the from when I call the grid? I just haven't found any good examples of RowEditor that are within a class structure and am still learning how to declare these types of things within a class.

I suppose, with the grid I can call a fucntion that creates the plugin. I'll try a few things here and report back.
TLCinAction (32) [Avatar] Offline
#6
Re: Placement of Listener for RowEditor
Here is what I did to see taht the afteredit was picked up/public

var editor = new Ext.ux.grid.RowEditor({
saveText: 'Update'
});
editor.on({
afteredit: function() {
Ext.MessageBox.alert('Ding Ding Ding');
}
});
jesus.garcia (463) [Avatar] Offline
#7
Re: Placement of Listener for RowEditor
afteredit only gets fired upon successful edit of a record.

Go here: http://www.extjs.com/deploy/dev/examples/restful/restful.html

paste the following in your firebug console
Ext.getCmp('ext-comp-1005').on('afteredit', function() {
console.log('here')
});

make an edit. You'll see that the edit only occurs after the data changes .
TLCinAction (32) [Avatar] Offline
#8
Re: Placement of Listener for RowEditor
Well after Editing and all, my Message box is working. I get a box that says Ding,Ding,Ding after I hit update. The value in the edited box doesn't refresh, but when I double click on the row again, the edited value is there.

So now I will run my AJAX call to update the database and refresh the store. I am afraid that when I refresh the store, the store will be hard to reference since this function is "outside" the class. Thus i was asking where to declare the listener.

I guess the real question is how do I move the var editor=editor so that it is within the class and can be referenced properly with listeners as a plugin to the grid and have a succesion of code to perform the AJX and after ajax success, failure ty
jesus.garcia (463) [Avatar] Offline
#9
Re: Placement of Listener for RowEditor
I would probably attach it to a reference in the class.

I.e: this.editor = new Ext....RowEditor();

Then, implement an 'onDestroy' extension method that deletes that reference. The RowEditor already self destructs upon the GridPanel destruction.