PDA

View Full Version : [Resolved]Render data from a Store, inside Ext.Window ext3.0.0



pjamrisk
16 Jan 2010, 12:20 PM
Hello guys,
In my quest for learning Ext better, I decided to create a small application that will allow me to add record request from the different users for removal or reactivation of assets. To make a long story short, I created a grid where these requests are going to be added, then saved for review. So far everything is working, except the following:
I added a button to the toolbar, which generates a window, and inside it a form. Inside this form I have a field which will read the asset number (on change) and should populate to the rest of the fields in the form. Firebug is telling me that the kn_i.store.reload is not defined, however, if I try the form by itself without the window definition in the grid (in a page by itself) the render works perfectly. Im sure I am overlooking at something simple here, but another set of eyes will be helpful.
Thank you in advance,
Patrick

Here is my code:


var grid1 = new Ext.grid.GridPanel({
renderTo: 'content',
frame:true,
title: 'Remove or Reactivation Form',
height:455,
width:1200,
store: RNR,
tbar: [{
xtype: 'tbbutton',
text: 'Add Request',
handler: function(){
//Load New Form
var RemoveForm = new Ext.Window({
title:'Remove Request',
width: 400, height:300,
layout: 'fit',
modal: true,
closable: true,
plain: true,
buttonAlign: 'center',
items: new Ext.FormPanel({
xtype:'form',
id:'RemoveFormPanel',
url:'submitRemovalRequest.php',
// baseParams : {user : userid},
frame: true,
labelAlign: 'left',
labelWidth: 70,
width: 350,
items: [{
xtype:'textfield',
id: 'kn_id',
fieldLabel: 'KN',
name: 'kn_name',
hiddenName: 'kn_name',
valueField:'ControlNumber',
displayField:'ControlNumber',
dataIndex: 'ControlNumber',
store: knstore,
mode: 'local',
triggerAction: 'all',
listeners: {
'render': function(c) {
c.getEl().on('change', function() {
var kn_i = Ext.getCmp('kn_id').getValue();
var pm_h = Ext.getCmp('pm_hidden_id');
// var id_h = Ext.getCmp('hidden_id');
pm_h.store.reload({params: {ControlNumber: kn_i}});
kn_i.store.reload({params: {ControlNumber: kn_i}});
// id_h.store.reload({params: {ControlNumber: kn_i}});
}, c);
}
}
},{
xtype:'textfield',
id:'pm_hidden_id',
fieldLabel: 'PM ',
anchor:'85%',
cls: 'required_field',
allowBlank: false,
name: 'pmh_name',
hiddenName: 'pmh_name',
mode:'local',
dataIndex: 'PMNumber',
valueField:'PMNumber',
displayField:'PMNumber',
triggerAction: 'all',
readOnly: true,
editable: false,
store: assetstore
}
Note: I only added part of the code since this is theonly part giving me trouble.

pjamrisk
18 Jan 2010, 10:44 PM
Well, after several hours of thinking and reading, I found the following thread

http://www.extjs.com/forum/showthread.php?t=45442

with that I split my code and was able to generate the form in a much cleaner way. Also, the problem I had for those who read this post was me having the wrong variable on my store, so when my handler launched it was just not populating my element at all.

if anyone wants the full code, just reply on the thread.

Hollywood
18 Jan 2010, 11:54 PM
you need to be a little more clearer as to the problem that you are facing ,

also why have you added an xtype:'form' when you are instantiating a new form.you don't need an xtype type when you write new ext.formpanel .

regards,

Hw

pjamrisk
26 Jan 2010, 2:40 AM
Dear Hollywood,
Thank you for the reply. I did not know that about the form, and did the change on it. I also want to update this post by saying that I fixed my problem. After all the form was correct even with some unnecessary lines like the one you pointed out. The problem ended up being my connection to my data store on the back end, I was pointing to the wrong directory.

Sorry again, and thanks for the reply.

Patrick