Reputation: 205
I am new at ExtJS, i try send value with a button to a new window , I did some example, they are not working, in this example I think , I almost done, but this didn't work too, What is my wrong or wrongs?
var win = function (msg) {
Ext.create('Ext.Window', {
title: msg,
...// here my window
}); this.show;
};
var btnAction = Ext.create('Ext.Button', {
text: 'Add Something',
listeners: {
click: function() {
var rec = grid4.getSelectionModel().getSelection()[0];
if (rec) {
win(rec.get('price'));
} else {
alert('Please select a company from the grid');
};}}
});
Upvotes: 1
Views: 288
Reputation: 6420
this.show
is a function. Functions are executed like this: this.show();
Watch out because now you can click 10 times on the same button and each time opening a new window... don't know if that's what you want..
here's a fiddle
var win = function (msg) {
var win = Ext.create('Ext.Window', {
title: msg
// here my window
});
win.show();
return win;
};
var btnAction = Ext.create('Ext.Button', {
text: 'Add Something',
listeners: {
click: function () {
var rec = grid4.getSelectionModel().getSelection()[0];
if (rec) {
win(rec.get('price'));
} else {
alert('Please select a company from the grid');
}
}
}
});
Upvotes: 1
Reputation: 2940
I'm not sure of what you're trying to do with that price
after sending it to the window. But you can use up()
and down()
methods to access a field in that window.
For example
var btnAction = Ext.create('Ext.Button', {
text: 'Add Something',
listeners: {
click: function() {
var rec = grid4.getSelectionModel().getSelection()[0];
if (rec) {
win.down('textfield[name=priceField]').setValue(rec.get('price'));
} else {
alert('Please select a company from the grid');
};}}
});
Also, any reason you're creating your window this way?
var win = function (msg) {
Ext.create('Ext.Window', {
title: msg,
...// here my window
}); this.show;
};
I'd normally do that this way...
var win = Ext.create('Ext.Window',{
title:msg,
....//
}).show();
And the method I mentioned before for accesing the windows fields will probably require it being created like this.
Upvotes: 1