PDA

View Full Version : this.store.un is not a function with my_window.close()



ryanrca
14 Jan 2011, 2:32 PM
Hey guys,

I have a "publish" button on my grid that produces a Ext.Window that contains a formPanel and some buttons.

After the user does anything, I want that window destroyed with the .close() method. Problem is when the call this.close(), I get the following error:



this.store.un is not a function
this.store.un('beforeload', this.onBeforeLoad, this);
ext-all-debug.js (line 38968)

Any clues???

A little more background, I am passing a reference to the grid to the window, so it can call some grid methods for data:


if (!email_win){
var email_win = new pub_email.emailwin({ grid: this });
}
email_win.show();



It doesn't matter if I call this.close() from within the emailwin object, or if I call email_win.close(), I get the same error.
I did try setting this.grid = undef before calling close, thinking that may be the issue, but that didn't work.

Help!!

Thanks!

-- Ryan

fay
14 Jan 2011, 3:28 PM
I'm pretty certain that re-declaring var email_win within your check is wrong:


if (!email_win){
var email_win = new pub_email.emailwin({ grid: this }); // Remove the var
}


email_win should be defined *somewhere* (accessible) before the if statement.

Without seeing more of your code, it's hard to say what is causing the "un" error.

ryanrca
14 Jan 2011, 5:20 PM
Yeah, I've played around with that. Actually, all the exit path's from email_win should call .close(), so email_win will always be destroyed on exit and re-created when publish is clicked.

This code behaves with the same error message:

var email_win = new pub_email.emailwin({ grid: this });
email_win.show();

There are thousands of lines of code in this application, and I really clueless what I should post.

This is the final exit method of the email_win:


handlePublishEmail: function(btn, obj){

var comments = "";
var to = "";
var subject = "";

var emailFormPanel = Ext.getCmp('emailPrepForm');

var f = emailFormPanel.getForm();
var form_data = f.getFieldValues();

if (btn.id == 'cancel'){
this.close();
return;
}

if (btn.id == 'sendWithComments'){
to = form_data.to;
subject = form_data.subject;
comments = form_data.comments;
}

pub_email.AJAXPublishSelectedToDB(this.grid, comments, to, subject);

var selected = this.grid.getSelectionModel().getSelections().length;
var msg = "Sent email regarding "+ selected +" runs";
xlib.mw(msg);

this.close();
return;
},

valititi
15 Jan 2011, 4:50 AM
have you tried to play with the autoDestroy:true|false properties on your window and/or grid ?

ryanrca
15 Jan 2011, 4:55 PM
Hmmm, good idea. Just finished playing with the autoDestroy settings -- no change in behavior. There doesn't seem to be an autoDestroy property to gridPanel BTW.

I also just noticed the "removeAll()" method to both these objects -- again no change. Still getting that error. I wish I had a clue what was happening here.

Thanks.

valititi
15 Jan 2011, 9:10 PM
gridPanel have no autoDestroy ?... thanks ! :-)))
so if the grid don't have it... then... go deeper... try to see on your store ! same stuff ! you must find somewhere :-)

or... it seems like your window, try to destroy the store and not find her... so, or put store autoDestroy:false, for letting the window to do this , or, try to f..orward it and, before close occurs on window...
Like this :


yourwindow.on('beforeclose', function() {
yourwindow.yourstore.destroy();
yourwindow.yourstore= null;
});

Condor
16 Jan 2011, 5:30 AM
That error is from destroying a combobox on the window. How exactly was that combobox configured?