PDA

View Full Version : Opening a new Window with an ID in parameter



kyrillos52
25 Aug 2010, 11:38 PM
Hi,

I'll like to open a new window created with ext-designer where I want to initialize a parameter (Hidden Field) with an ID provided from a grid.

Example : I have a grid with a list of articles and I want update an article.

How can I do that ?

Thank you.

jarrednicholls
30 Aug 2010, 7:08 AM
Hi kyrillos52,

Let's say you have an Ext.grid.GridPanel subclass named "MyGrid" and it's completed defined, etc., and you want to show the window when a user double clicks a row. Attach a listener to the "rowdblclick" event for the grid:



MyWindow = Ext.extend(MyWindowUi, {
initComponent: function(){
MyWindow.superclass.initComponent.call(this);

this.myHiddenField.setValue(this.recordId);
}
});

MyGrid = Ext.extend(MyGridUi, {
initComponent: function(){
MyGrid.superclass.initComponent.call(this);

this.on('rowdblclick', this.openWindow, this);
},

openWindow: function(grid, idx, e){
var record = this.store.getAt(idx);
var win = new MyWindow({
recordId: record.id
});
win.show();
}
});


Assumptions:

1) Your "MyWindow" subclass has an Ext.Hidden descendant "item" with a "ref" configured to put the reference "myHiddenField" up onto the MyWindow instance. "ref" is configured in the Designer via "autoRef". See http://dev.sencha.com/deploy/dev/docs/?class=Ext.Component&member=ref for more information.

2) MyWindow and MyGrid are subclasses of "Ui" classes generated by the Designer, which are completely configured and ready to go.

Important things to note are the "myHIddenField" ref on the MyWindow, as well as the "rowdblclick" event handler for the MyGrid class that will get the record's ID, and pass it to a new instance of MyWindow as a "recordId" parameter. This is in turn used to set the value of the "myHiddenField" hidden field.

Let me know if that makes sense. I hope that helps!
Jarred

kyrillos52
31 Aug 2010, 11:55 PM
Thank you for your response,

I will know if it can be possible to use binding to modify myWindow with the element of my JSON object and how to use it.

For example, myGrid load the articles with using JSON retrieve from the server. And I use the data on the grid to open myWindow with the element of the selected item. My server will have less mySQL requests.

It look likes with this but using window : http://dev.sencha.com/deploy/dev/examples/form/form-grid.html