PDA

View Full Version : ComboBox(json) is empty after getform.reset()



treblereel
21 Apr 2010, 2:26 PM
A have a combobox in a form with data from Jsonstore, cant find why after i have do reset of a form combo is empty ?
What i am doing wrong ? Plz help.


var usersStorebyRole = new Ext.data.JsonStore({
// autoLoad: true,
id: 'usersStorebyRoleId',
url: '<?php echo base_url();?>users/getUsersByRole',
root: 'users',
mode: 'remote',
totalProperty: 'count',
params: { role: 'is_pm' },
baseParams: { role: 'is_pm' },
fields: [{ name: 'user_id' }, { name: 'username' }]

});
usersStorebyRole.setDefaultSort('username', 'asc');
usersStorebyRole.load({params:{'role':'is_pm'}});
//usersStorebyRole.setDefaultSort('username', 'asc');
//usersStorebyRole.load();




var addJobForm = new Ext.FormPanel ({
labelWidth: 75, // label settings here cascade unless overridden
url:'<?php echo base_url();?>job/addJob',
frame:true,
method: 'POST',
bodyStyle:'padding:5px 5px 0',
defaults: {width: 230},
defaultType: 'textfield',
items: [{ fieldLabel: 'Jobname', name: 'name', width: 200,allowBlank: false},
{ fieldLabel: "Index", name: 'jobIndex', width: 80},
{ name: 'parent',hidden: true },
{ xtype: 'datefield',format: "Y-m-d" , fieldLabel: "Created At", dataIndex: 'created_at', name: 'created_at' },
{ xtype: 'datefield',format: "Y-m-d" , fieldLabel: "Expired At", dataIndex: 'expired_at', name: 'expired_at' },
{ xtype:'combo',
id: 'customer_name',
fieldLabel: "PM",
maxLength: 200,
allowBlank: false,
anchor: '95%',
hidden: false,
hideLabel: false,
triggerAction: 'all',
allQuery: '',
minChars: 0,
store: usersStorebyRole2,
displayField: 'username',
valueField: 'user_id',
mode: 'remote',
listeners: {
select: function(el,type){
customer_codeField.setValue(type.json.cif);
}
}
},

//{ xtype:'combo',lazyRender: true,store: usersStorebyRole, editable: false, mode: 'remote', valueField:'user_id',
// displayField:'username', hiddenName:'user_id', fieldLabel: "PM",triggerAction: 'all', width: 200, name: 'user_id',allowBlank: false},
{ xtype: 'checkbox', fieldLabel: "Status", dataIndex: 'active', width: 200, name: 'active',checked : 'on' },
{ xtype: 'checkbox', fieldLabel: "Default Job", dataIndex: 'defaultJob', width: 200, name: 'defaultJob' },

],
buttons: [{
text: 'Save',
handler: function () {
var nodeAction = myTree.getSelectionModel().getSelectedNode();
addJobForm.getForm().findField('parent').setValue(nodeAction.id);
addJobForm.getForm().submit({
waitMsg: 'Saving...', // Wait Message
success: function (form, action) {
result = Ext.decode(action.response.responseText);
var text = result.data.text;
var id = result.data.id;



// alert(response.responseJson['data']);
parentNode = myTree.getNodeById(nodeAction.id);
parentNode.expand();
parentNode.appendChild(new Ext.tree.TreeNode({"text": text,"id": id,"leaf":"true"}));
// parentNode.appendChild(new Ext.tree.TreeNode({"text": "OK","id":"100","leaf":"true"}));

parentNode.renderChildren();


// When saving data success
Ext.MessageBox.alert ('Message','Data has been saved');
addJobForm.getForm().reset();
// usersStorebyRole.setDefaultSort('username', 'asc');
//combo.store.reload();
// usersStorebyRole.reload();
win_add_job.hide();
usersStorebyRole.reload({params:{'role':'is_pm'}});
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Message','Saving data failed');
}
});
}
},{
text: 'Cancel',
handler: function () {
addJobForm.getForm().reset();
win_add_job.hide();
}
}]
});



var win_add_job = new Ext.Window({
width:370,
height:270,
title: 'Add Job',
resizable: false,
closeAction:'hide',
items: [addJobForm],
bodyStyle:{'background-color': '#FFFFFF'}
});

treblereel
22 Apr 2010, 10:03 AM
maybe i need to do something like "function createJobWin(){}" with store inside ?