PDA

View Full Version : initial config of window using ajax result



nadeemshafi9
2 Jun 2009, 8:54 AM
Hi guys

I would like to configure a window to contain a generated form.

this form will be generated in an ajax request and then given to teh window on teh client side.

this will be the initial congig of this window, it dosent work the way i visioned it. her eis the snip

CLIENT


success: function(form, action) {
//alert(action.result.msg);
win = new Ext.Window({
width: 500,
height: 500,
autoScroll: true,
initialConfig: action.result.msg
});
win.show();
},
SERVER



preg_match_all("#<label(?:\s+[^>]+)?>(.*?)</label>#s", $result, $matches);
$pwd_chars_to_enter = $matches[1][1];

preg_match_all("#<input(?:\s+[^>]+)?>#s", $result, $matches);
$pwd_text_feilds = $matches[0];

preg_match_all("#<INPUT(?:\s+[^>]+)?>#s", $result, $matches);
$other_feilds_to_be_sent = $matches[0];


$result = "
{
items: [{
xtype: 'form',
items: [{
xtype: 'textfield',
allowBlank: false,
name: 'email',
id: 'email',
width: 200,
emptyText: 'Email',
fieldLabel: 'Email'
}]
}]
}

";


if($result){
echo $result;
exit;
}


//print_r($matches);
//exit;


$responseArray['id'] = "purchase result";
$responseArray['success'] = "true";
$responseArray['msg'] = $result;

$dojoData = new Zend_Dojo_Data();
$dojoData->setIdentifier('id')
->setMetadata($responseArray);
echo $dojoData->toJson();
exit;
any help, appreciated, thanks

dbassett74
12 Jun 2009, 8:55 AM
This is essentially what I'm looking for too. I want to specify a generic window on the client with default config options. Upon instantiating that window, I want to somehow grab configuration options from the server via JSON/AJAX based on a specified value. So that when the window is actually displayed, it is appropriate configured based on the retrieved info from the server.

Then, in reverse, I want to be able to send the window configuration information back to the server if the user clicks a Save button. For example, the user changed the size of the window.

Does anyone know how to do this?

nadeemshafi9
12 Jun 2009, 10:52 AM
this may help a little


,enableDragDrop:true
,initComponent:function() {
// hard coded config - cannot be changed from outside
var config = {
columns: [
{header: 'x', width: 20, sortable: true},
{header: 'x', width: 120, sortable: true, hidden: true},
{header: 'x', width: 120, sortable: true, hidden: true},
{header: 'Name', width: 120, sortable: true},
{header: 'x', width: 120, sortable: true, hidden: true},
{header: 'x', width: 120, sortable: true, hidden: true},
{header: 'x', width: 120, sortable: true, hidden: true},
{header: 'Image', width: 120, sortable: true, hidden: true}
]
};
// apply config
Ext.apply(this, Ext.apply(this.initialConfig, config));
// call parent
Example.Grid.superclass.initComponent.apply(this, arguments);
} // eo function initComponent

,onRender:function() {
Example.Grid.superclass.onRender.apply(this, arguments);
this.dz = new Example.GridDropZone(this, {ddGroup:this.ddGroup || 'GridDD'});
} // eo function onRender



you may have to eval the config object you get back from the server using ajax

dbassett74
12 Jun 2009, 1:15 PM
Thanks. But, how would this be applied to a Window? For example, I grabbed a JSON config object from the server via AJAX and now have that in the AJAX responseText. How could that be applied to the window? Same way as you showed with Ext.Apply? Can you give me a quick example of applying this to a Window?

nadeemshafi9
12 Jun 2009, 6:49 PM
Thanks. But, how would this be applied to a Window? For example, I grabbed a JSON config object from the server via AJAX and now have that in the AJAX responseText. How could that be applied to the window? Same way as you showed with Ext.Apply? Can you give me a quick example of applying this to a Window?
jsn is what they take anywyasjust stick it into teh apply if that dosent work thgen eval(blah) it