Why does Ext.getCmp(...).setChecked cause errors - extjs

I'm trying to set the checked state of an ExtJS 6.2 radiofield dynamically when a window is loaded for editing user information.
My window code is as follows
Ext.define('scim.view.users.EditUserWdw', {
extend: 'Ext.window.Window',
alias: 'widget.EditUserWdw',
id: 'editUserWdw',
required: [
'scim.view.users.UserController',
'Ext.form.Panel'
],
width: 400,
listeners: {
beforeclose: function (wdw) {
var frm = this.down('form');
if (frm.isDirty()) {
Ext.Msg.show({
title: 'Confirm Cancel',
msg: '<p>You started editing a user. Closing this window now will cause you to lose any information you changed.</p><p>Are you sure?</p>',
icon: Ext.Msg.QUESTION,
buttons: Ext.Msg.YESNO,
fn: function (ans) {
if (ans == 'yes') {
frm.reset();
wdw.close();
}
}
});
return false;
} else {
return true;
}
}
},
items: [{
xtype: 'form',
reference: 'form',
id: 'editUserFrm',
border: false,
style: 'background-color: #fff',
url: '/scim_libs/Users.php?metho=updateUser&userId=' + sessionStorage.userId,
padding: 5,
bbar: ['->', {
xtype: 'button',
text: 'Update User',
iconCls: 'x-fa fa-save',
handler: function () {
var frm = this.up('form');
if (frm.isValid()) {
frm.submit({
success: function (frm, response) {
var jData = Ext.util.JSON.decode(response.resposnse.responseText);
if (jData.status == "duplicate") {
Ext.Msg.show({
title: 'Duplicate Email',
msg: '<p>The email address <strong>' + Ext.getCmp('editUserEmail').getValue() + '</strong> is already used by another user.</p><p>Please use a different email address and try adding the user again.</p>',
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK,
closable: false,
fn: function () {
Ext.getCmp('editUserEmail').focus();
this.close();
}
})
}
else if (jData.status == "success") {
Ext.getStore('User').load();
Ext.Msg.show({
title: 'User Added',
msg: '<p>The user <strong>' + Ext.getCmp('editUserFirstName').getValue() + ' ' + Ext.getCmp('addUserLastName').getValue() + '</strong> has been updated successfully.</p>',
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK,
fn: function () {
Ext.getCmp('addUserFrm').reset();
Ext.getCmp('addUserWdw').close();
}
})
} else {
Ext.Msg.show({
title: 'Unexpected Error!',
msg: '<p>An unexpected error occurred when trying to update the user <strong>' + Ext.getCmp('addUserFirstName').getValue + ' ' + Ext.getCmp('adduUserLastName').getValue() + '</strong>. Please try updating the user again.</p><p>Should this problem persist, please contact technical support and provide the following information:</p><p>' + jData.status + '</p>',
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK,
fn: function () {
Ext.getCmp('addUserFrm').reset();
Ext.getCmp('addUserWdw').close();
}
})
}
}
})
}
}
}, {
xtype: 'button',
text: 'Cancel',
iconCls: 'x-fa fa-ban',
handler: function () {
this.up('form').up('window').close();
}
}],
items: [{
xtype: 'textfield',
anchor: '100%',
name: 'editUserFirstName',
id: 'editUserFirstName',
fieldLabel: 'First Name',
allowBlank: false,
minLength: 2,
madLength: 65,
selectOnAutoFocus: true,
listeners: {
afterrender: function () {
this.focus(true);
}
}
}, {
xtype: 'textfield',
anchor: '100%',
name: 'editUserLastName',
id: 'editUserLastName',
fieldLabel: 'Last Name',
allowBlank: false,
minLength: 2,
maxLength: 65
}, {
xtype: 'textfield',
anchor: '100%',
name: 'editUserEmail',
id: 'editUserEmail',
fieldLabel: 'Email',
allowBlank: false,
maxLength: 255,
selectOnFocus: true,
vtype: 'email'
}, {
xtype: 'textfield',
anchor: '100%',
name: 'editUserPhone',
id: 'editUserPhone',
fieldLabel: 'Phone',
maskRe: /[0-9]/,
regexText: 'Numbers Only',
allowBlank: true,
vtype: 'phone',
maxLength: 14,
listeners: {
change: function () {
if (this.getValue().length == 3) {
this.setValue('(' + this.getValue() + ') ');
}
if (this.getValue().length == 9) {
this.setValue(this.getValue() + '-');
}
}
}
}, {
xtype: 'fieldcontainer',
fieldLabel: 'Reset Password',
itemId: 'editUserResetGrp',
defaults: {
flex: 1
},
layout: 'hbox',
width: 200,
items: [{
xtype: 'radiofield',
boxLabel: 'Yes',
name: 'editUserReset',
inputValue: 1,
id: 'editUserReset1'
}, {
xtype: 'radiofield',
boxLabel: 'No',
name: 'editUserReset',
inputValue: 0,
id: 'editUserReset2'
}]
}, {
xtype: 'fieldcontainer',
fieldLabel: 'Lock Account',
defaults: {
flex: 1
},
layout: 'hbox',
width: 200,
items: [{
xtype: 'radiofield',
boxLabel: 'Yes',
name: 'editUserLocked',
inputValue: 0,
id: 'editUserLocked1'
}, {
xtype: 'radiofield',
boxLabel: 'No',
name: 'editUserLocked',
inputValue: 1,
id: 'editUserLocked2'
}]
}]
}]
})
My controller code is
Ext.define('scim.view.users.UserController', {
extend: 'Ext.app.ViewController',
alias: 'controller.user',
addUser: function () {
var addUserWdw = Ext.create('scim.view.users.AddUserWdw', {
title: 'Add New User'
}).show();
},
editUser: function (grid, rowIndex, colIndex) {
var objRow = Ext.getStore('User').getAt(rowIndex);
var editUserWdw = Ext.create('scim.view.users.EditUserWdw', {
title: 'Edit User - ' + objRow.data.userFirstName + ' ' + objRow.data.userLastName
}).show();
Ext.getCmp('editUserFirstName').setValue(objRow.data.userFirstName);
Ext.getCmp('editUserLastName').setValue(objRow.data.userLastName);
Ext.getCmp('editUserEmail').setValue(true);
Ext.getCmp('editUserPhone').setValue('(' + objRow.data.userPhone.substr(0, 3) + ') ' + objRow.data.userPhone.substr(3, 3) + '-' + objRow.data.userPhone.substr(6, 4));
console.log(objRow.data.reset);
if (objRow.data.reset == 0) {
console.log(Ext.getCmp('editUserReset2'));
console.log(Ext.getCmp('editUserReset2').checked);
Ext.getCmp('editUserReset2').setChecked(true);
console.log(Ext.getCmp('editUserReset2').checked);
} else {
console.log(Ext.getCmp('editUserReset1'));
}
},
getUsers: function () {
Ext.getStore('Users').load();
}
})
When running
console.log(Ext.getCmp('editUserReset2').checked)
The results received are as expected "false".
console.log(Ext.getCmp('editUserReset2').setChecked(true)
triggers then the error returned is
Uncaught TypeError: Ext.getCmp(...).setChecked is not a function
I've tried getting the fieldcontainer and then an array of radiofield's and using setChecked(index, true) with the same results.
I've checked the documentation and it is a method to this xtype. So I've become stumped in where this error is generating from. Any help would be greatly appreciated.

Thanks #EvanTrimboli for the following answer...
I was using the documentation on Sencha's website for the Modern Toolkit which uses the
Ext.getCmp(...).setChecked(true)
While my code is actually using the Classic Toolkit which uses the
Ext.getCmp(...).setValue(value)
As the means of setting a radio button checked state.

Related

Not able to access object from data in ViewModel

Am trying to fetch the persondetails details into enableButton method.
Am aware that we can achieve this by simply adding key and value to data object.
But my question here is, is there any way to store data into persondetails and fetch it?
If I specify as below and bind accordingly, then its wok fine.
data: {
firstname: '',
lastname: ''
}
bind: {
value: '{lastname}'
},
Here is the code:
Ext.application({
name : 'Fiddle',
launch : function() {
Ext.define('MyApp.view.TestViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.userinfo',
data: {
persondetails:{
firstname: '',
lastname: ''
}
},
formulas: {
enableButton: function(get){
debugger;
if(get('firstname')!=='' && get('lastname')!=='' ){
return true;
}else{
return false;
}
},
fullName: function(get){
if(get('firstname')!=='' && get('lastname')!=='' ){
return get('firstname') + ' ' + get('lastname');
}
}
}
});
Ext.create('Ext.form.Panel', {
title: 'Contact Info',
width: 500,
bodyPadding: 10,
renderTo: Ext.getBody(),
viewModel:{
type:'userinfo'
},
items: [{
xtype: 'textfield',
name: 'firstname',
emptyText: 'Enter First Name',
bind: {
value: '{persondetails.firstname}'
},
}, {
xtype: 'textfield',
name: 'lastname',
emptyText: 'Enter Last Name',
bind: {
value: '{persondetails.lastname}'
},
}, {
xtype: 'button',
reference: 'clickme',
disabled: true,
bind: {
disabled: '{!enableButton}'
},
text: 'Click',
listeners: {
click: function(){
alert('{fullName}');
}
}
}, {
xtype: 'displayfield',
fieldLabel: 'Full Name',
bind: {
value: '{fullName}'
}
}]
});
}
});
I have created a fiddle Example
According to documentation
When a direct bind is made and the bound property is an object, by
default the binding callback is only called when that reference
changes. This is the most efficient way to understand a bind of this
type, but sometimes you may need to be notified if any of the
properties of that object change.
To do this, we create a "deep bind":
In other words, if a object changes its properties, the viewmodel will not notify these changes (although their properties are changed correctly).
If you need to listen this changes, you need to use deep binding
Ext.application({
name : 'Fiddle',
launch : function() {
Ext.define('MyApp.view.TestViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.userinfo',
data: {
persondetails: {
firstname: '',
lastname: ''
}
},
formulas: {
enableButton: {
bind: {
bindTo: '{persondetails}',
deep: true // listen to any change in personaldetails
},
get: function (data) {
return data.firstname && data.lastname
}
},
fullName: {
bind: {
bindTo: '{persondetails}',
deep: true // listen to any change in personaldetails
},
get: function (data) {
return data.firstname + ' ' + data.lastname
}
},
}
});
Ext.create('Ext.form.Panel', {
title: 'Contact Info',
width: 500,
bodyPadding: 10,
renderTo: Ext.getBody(),
viewModel:{
type:'userinfo'
},
items: [{
xtype: 'textfield',
name: 'firstname',
emptyText: 'Enter First Name',
bind: {
value: '{persondetails.firstname}'
},
}, {
xtype: 'textfield',
name: 'lastname',
emptyText: 'Enter Last Name',
bind: {
value: '{persondetails.lastname}'
},
}, {
xtype: 'button',
reference: 'clickme',
disabled: true,
bind: {
disabled: '{!enableButton}'
},
text: 'Click',
listeners: {
click: function(){
alert('{fullName}');
}
}
}, {
xtype: 'displayfield',
fieldLabel: 'Full Name',
bind: {
value: '{fullName}'
}
}]
});
}
});

How to pass parameter value from view to Ext.window?

I am get confused to pass value from view to window,
I have a view contain the user info and one button on which click a new window opens to upload an Image file. the image upload code I done in window. But I want to pass User Id with the image which I want to post on server. the user Id I on View. I want to carry that userId on file upload window. How can I do this?
Bellow is my code.
file upload view
Ext.define('vDemo.view.FileUpload', {
extend: 'Ext.Panel',
region: 'center',
border:'false',
initComponent: function () {
var me = this;
this.form = new Ext.form.Panel({
xtype: 'panel',
border: false,
//layout: 'vbox',
padding: '2 2 2 2',
bodyPadding: 10,
frame: false,
renderTo: Ext.getBody(),
items: [{
xtype: 'filefield',
name: 'photo',
fieldLabel: 'Photo',
labelWidth: 50,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: 'Select Photo...'
}],
buttons: [{
text: 'Upload',
handler: function () {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
url: 'photo-upload.php',
waitMsg: 'Uploading your photo...',
success: function (fp, o) {
Ext.Msg.alert('Success', 'Your photo "' + o.result.file + '" has been uploaded.');
}
});
}
}
}]
});
this.items = [this.form];
this.callParent();
}
});
UserForm view (on which button click I am open the file upload window)
Ext.define('vDemo.view.userHome', {
extend: 'Ext.Panel',
border: false,
Padding: '5 5 5 5',
title: 'Home',
initComponent: function () {
var me = this;
this.changingImage = Ext.create('Ext.Img', {
src:'', //'appRes/ProfilePic/ProfilePic1.png',
width: 150,
height: 170
});
this.image = new Ext.Container({
cls: 'img-block',
padding:'0 0 2 0',
items: [this.changingImage]
});
this.ImagePanel = new Ext.form.Panel({
padding: '5 5 5 5',
layout: 'vbox',
border: false,
items: [
this.image,
{
xtype: 'button',
text: 'Chage Image',
width: 150,
height: 30,
handler: function () {
me.fileUpload();
}
}
]
});
this.InfoPanel = new Ext.form.Panel({
padding: '5 5 5 5',
layout: 'vbox',
border: false,
items: [{
xtype: 'hidden',
name: 'hfUserAutoId'
},
{
xtype: 'displayfield',
fieldLabel: 'Name:',
name: 'lblName',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'Email:',
name: 'lblEmail',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'Date of Birth:',
name: 'lblDateOfBirth',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'UserId',
name: 'lblUserId',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'Gender',
name: 'lblGender',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'Blood Group',
name: 'lblBloodGroup',
value: ''
},
{
xtype: 'displayfield',
fieldLabel: 'Hieght',
name: 'lblHieght',
value: ''
}]
});
this.form = new Ext.form.Panel({
padding: '10 100 10 100',
layout: 'hbox',
header: {
titlePosition: 0,
items: [{
xtype: 'button',
text: 'Back',
handler: function () {
me.fireEvent('getBack');
}
}]
},
items: [me.ImagePanel, this.InfoPanel]
});
this.items = [this.form];
this.callParent();
},
fillForm: function(sRec) {
var me = this;
console.log(sRec);
// var sRec1 = Ext.StoreMgr.lookup('UserInfo').getById(ssRec.get('userAutoId'));
console.log(sRec[0].userAutoId);
me.form.getForm().findField('hfUserAutoId').setValue(sRec.userAutoId);
me.form.getForm().findField('lblName').setValue(sRec[0].firstName + " " + sRec[0].lastName);
me.form.getForm().findField('lblUserId').setValue(sRec[0].userid);
me.form.getForm().findField('lblEmail').setValue(sRec[0].email);
if (sRec[0].gender == true) {
me.form.getForm().findField('lblGender').setValue("Male");
}
else if (sRec[0].gender == false) {
me.form.getForm().findField('gender').setValue("Female");
};
me.form.getForm().findField('lblDateOfBirth').setValue(sRec[0].DOB);
me.form.getForm().findField('lblBloodGroup').setValue(sRec[0].bloodGroup);
me.form.getForm().findField('lblHieght').setValue(sRec[0].hieght);
// me.form.getForm().findField('image').setSrc(sRec.get('profilePicPath'));
me.changingImage.setSrc(sRec[0].profilePicPath);
},
fileUpload: function () {
this.uploadWinPanel = new vDemo.view.FileUpload({});
var hfUserAutoId = me.form.getForm().findField('hfUserAutoId').getValue();
this.EditWin = new Ext.Window({
//header:false,
Height: 400,
width: 320,
title: 'Upload Photo',
border: 0,
resizable: false,
draggable: false,
modal: false,
items: [this.uploadWinPanel]
}).show();
}
});
Well, you pass the user id on initialization of the uploadWinPanel like so:
var hfUserAutoId = me.form.getForm().findField('hfUserAutoId').getValue();
this.uploadWinPanel = new vDemo.view.FileUpload({
userId: hfUserAutoId
});
And then in the FileUpload component, beside the filefield, you add a hiddenfield which grabs the userId value:
items: [{
xtype: 'filefield',
name: 'photo',
fieldLabel: 'Photo',
labelWidth: 50,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: 'Select Photo...'
},{
xtype: 'hiddenfield',
name: 'user_id',
value: this.userId
}]

How to create a Form for each row in a grid panel:extjs

How do i create a different form for each row in the Grid...
i have a grid like ..
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
Your question doesn't explain your problem very well. Please update your topic and question. As I understood from your question, yes, you can. There are couple of ways. One of them is putting a form into a grid cell using grid column renderer. Another way is using editor in grid column. The second way is easy, but it's not proper way. If you want the second way also, I can add it. So, I'll add an efficient one. Please check the code below and fiddle:
https://fiddle.sencha.com/#fiddle/11i5
Ext.define('UploadForm', {
extend: 'Ext.form.Panel',
width: 200,
frame: true,
items: [{
xtype: 'filefield',
name: 'photo',
msgTarget: 'side',
allowBlank: false,
buttonText: 'Select'
}],
buttons: [{
text: 'Upload',
handler: function() {
var form = this.up('form').getForm();
if(form.isValid()){
form.submit({
url: 'photo-upload.php',
waitMsg: 'Uploading your photo...',
success: function(fp, o) {
Ext.Msg.alert('Success', 'Your photo "' + o.result.file + '" has been uploaded.');
}
});
}
}
}],
initComponent: function () {
if (this.delayedRenderTo) {
this.delayRender();
}
this.callParent();
},
delayRender: function () {
Ext.TaskManager.start({
scope: this,
interval: 200,
run: function () {
var container = Ext.fly(this.delayedRenderTo);
if (container) {
this.render(container);
return false;
} else {
return true;
}
}
});
}
});
var store = Ext.create('Ext.data.Store', {
fields: ['Name', 'Phone', 'Email', 'filePath'],
data: [{
Name: 'Rick',
Phone: '23122123',
Email: 'something#mail.com',
filePath: '/home'
}, {
Name: 'Jane',
Phone: '32132183',
Email: 'some#thing.com',
filePath: '/home'
}]
});
var renderTree = function(value, meta, record) {
var me = this;
var container_id = Ext.id(),
container = '<div id="' + container_id + '"></div>';
Ext.create('UploadForm', {
delayedRenderTo: container_id
});
return container;
}
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: store,
columns: [
{ text: 'Name', dataIndex: 'Name' },
{ text: 'Email', dataIndex: 'Email' },
{ text: 'Phone', dataIndex: 'Phone' },
{ text: 'Upload',
dataIndex: 'filePath',
width: 300,
renderer: renderTree
}
],
renderTo: Ext.getBody()
});
P.s. Its based from Render dynamic components in ExtJS 4 GridPanel Column with Ext.create

ExtJS5 Web Desktop Sample: Unable to fire event from controller

I have been working with web desktop example in ExtJS5. The example has static data and no events. I wanted to implement a click event on 'Remove Something' button on grid window. Here is my modified code:
Ext.define('SampleApp.view.main.GridWindow', {
extend: 'Ext.ux.desktop.Module',
requires: [
'Ext.data.ArrayStore',
'Ext.util.Format',
'Ext.grid.Panel',
'Ext.grid.RowNumberer'
],
init: function () {
this.launcher = {
text: 'Grid Window',
iconCls: 'icon-grid'
};
},
controller: 'gridwindow',
createWindow: function () {
var desktop = this.app.getDesktop();
var win = desktop.getWindow('grid-win');
if (!win) {
win = desktop.createWindow({
id: 'grid-win',
title: 'Grid Window',
width: 740,
height: 480,
iconCls: 'icon-grid',
animCollapse: false,
constrainHeader: true,
layout: 'fit',
items: [
{
border: false,
xtype: 'grid',
store: mock.view.main.GridWindow.getDummyData(),
columns: [{ xtype: 'rownumberer', sortable: false, text: "S.N.", width: 70 }, {
id: 'topic',
text: "Topic",
dataIndex: 'gridTopic',
flex: 1,
align: 'center'
}, {
text: "Author",
dataIndex: 'gridAuthor',
flex: 1,
align: 'center',
sortable: true
}, {
text: "Replies",
dataIndex: 'gridReplies',
align: 'center',
flex: 1,
sortable: true
}, {
id: 'last',
text: "Last Post",
dataIndex: 'gridLastPost',
flex: 1,
align: 'center',
sortable: true
}]
}
],
tbar: [{
text: 'Add Something',
tooltip: 'Add a new row',
iconCls: 'add'
}, '-', {
text: 'Options',
tooltip: 'Modify options',
iconCls: 'option'
}, '-', {
text: 'Remove Something',
tooltip: 'Remove the selected item',
iconCls: 'remove',
listeners: {
click: 'onDeleteClick'
}
}]
});
}
return win;
},
statics: {
getDummyData: function () {
var _store = Ext.create('Ext.data.Store', {
fields: [
{ name: 'gridId', type: 'int' },
{ name: 'gridTopic', type: 'string' },
{ name: 'gridAuthor', type: 'string' },
{ name: 'gridReplies', type: 'string' },
{
name: 'gridLastPost', type: 'date', convert: function (value) {
var _date = new Date(value);
return Ext.Date.format(_date, "Y-m-d H:i:s");
}
}
]
});
var _responseText;
Ext.Ajax.request({
async: false,
url: 'http://localhost/sampleapp/getusers',
method: 'GET',
success: function (resp) {
_responseText = Ext.decode(resp.responseText);
_store.loadData(_responseText);
}
});
return _store;
}
}
});
I am unable to handle 'onDeleteClick' event inside the controller. Here is the controller definition:
Ext.define('SampleApp.view.main.GridWindowController', {
extend: 'Ext.app.ViewController',
alias: 'controller.gridwindow',
onDeleteClick: function (button, evt) {
alert('Clicked');
}
});
Can someone point out the mistake. How can this event be handled?
Ext.ux.desktop.Module does not accept controller config option.
Use your controller on an Ext.Component — in your case either the grid or the window.

ExtJS, FormPanel, and TabPanel component: post doesn't send all the fields

Here's my problem: as long as the tabs are not shown, the data contained within the tabs are not sent. If I click on a tab, the data is added to the "stack" and is sent through the post event. (See the code)
What I don't get is that I'm using "deferredRender: false". This seems it's the only thing to use to "force" field calculation. I don't see what I'm missing, but I'm missing something.
Can anyone help me?
Thanks a lot.
Here's the full source code (that works) of the DossierPanel class:
DossierPanel = Ext.extend(Ext.form.FormPanel, {
closable: true,
autoScroll:true,
initComponent : function(){
var n = this.id_dossier;
if (this.nom) {
n += ' '+this.nom
}
if (this.prenom) {
n += ' '+this.prenom;
}
this.title = n;
this.id = 'id_dossier_'+this.id_dossier;
this.bodyStyle = 'padding:15px';
this.labelWidth = 150;
this.items = [{
layout:'column',
border:false,
autoHeight: true,
items:[{
columnWidth:.5,
layout: 'form',
border:false,
items: [{
xtype:'textfield',
fieldLabel: 'Civilite ',
name: 'CIVILITE',
readOnly: true
}, {
xtype:'textfield',
fieldLabel: 'Nom ',
name: 'NOM',
anchor:'95%'
}, {
xtype:'textfield',
fieldLabel: 'Prenom ',
name: 'PRENOM',
anchor:'95%'
}]
},{
columnWidth:.5,
layout: 'form',
border:false,
items: [{
xtype:'textfield',
fieldLabel: 'RaisonSociale ',
name: 'RAISONSOCIALE',
anchor:'95%'
},{
xtype:'textfield',
fieldLabel: 'Email ',
name: 'EMAIL',
vtype:'email',
anchor:'95%'
}]
}]
},{
xtype:'tabpanel',
plain:true,
activeTab: 0,
/* (!) For a tab to force calculation, I use
* deferredRender: false
* It's very important for Form with multiple Tabs
*/
deferredRender: false,
defaults:{bodyStyle:'padding:10px'},
items:[{
title:'Détails personnels',
layout:'form',
autoHeight: true,
defaults: {width: '99%'},
defaultType: 'textfield',
items: [{
fieldLabel: 'Poids ',
name: 'POIDS',
readOnly: true
}, {
xtype:'datefield',
fieldLabel: 'Date premier contact ',
name: 'DATE1ERCONTACTJMA',
readOnly: true,
format:'d/m/Y'
}, {
xtype:'datefield',
fieldLabel: 'Date étude dossier ',
name: 'DATEDATE_ETUDE_DOSSIERJMA',
format:'d/m/Y'
}]
},{
title:'Adresse',
layout:'form',
autoHeight: true,
defaults: {width: '95%'},
defaultType: 'textfield',
items: [{
fieldLabel: 'Adresse 1 ',
name: 'ADRESSE1'
}, {
fieldLabel: 'Pays ',
name: 'PAYS',
readOnly: true
}]
},{
title:'Téléphone(s)',
layout:'form',
autoHeight: true,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'NoTelephone2 ',
name: 'NOTELEPHONE2',
}, {
fieldLabel: 'DescTelephone3 ',
name: 'DESCTELEPHONE3',
readOnly: true
}, {
fieldLabel: 'NoTelephone3 ',
name: 'NOTELEPHONE3',
}]
},{
title:'Divers',
layout:'form',
autoHeight: true,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'Mot de passe Internet ',
name: 'MOTDEPASSE'
}, {
fieldLabel: 'Parts ',
name: 'PARTS'
}, {
fieldLabel: 'Commission ',
name: 'COMMISSION'
}]
},{
id: 'tab_emprunts_'+this.id_dossier,
title:'Emprunts',
layout:'form',
autoHeight: true,
defaults: {width: '99%'},
defaultType: 'textfield',
items: []
}]
}];
this.buttonAlign = 'left';
this.buttons = [{
text: 'Recharger',
handler: function() {
this.getForm().load( {
url: '/ws/cellulemedicale/jsonEditDossier.php',
params: {
id_dossier: this.id_dossier
},
waitTitle: 'Wait',
waitMsg: 'Refresh',
failure:function(form, action) {
globGestionErreurAjax(action.response,'Refresh error');
}
});
},
scope: this
},{
text: 'Sauver',
handler: function() {
this.getForm().submit({
url: '/ws/cellulemedicale/jsonEditDossier.php',
params: {
write: 1,
id: this.id_dossier
},
waitTitle: 'Wait...',
waitMsg: 'Saving',
success: function (form, action) {
var b = Ext.util.JSON.decode(action.response.responseText);
if (b.success==true) {
if (b.msg) {
Ext.MessageBox.alert('Done!', b.msg);
}
else {
Ext.MessageBox.alert('Done!', 'Saved ok');
}
}
},
failure:function(form, action) {
globGestionErreurAjax(action.response,'Save error');
}
});
},
scope: this
}];
this.on('actioncomplete', function (form,action) {
if (action.type=='load') {
console.log(action.result.data.emprunts);
if(typeof action.result != 'undefined') {
if(typeof action.result.data != 'undefined') {
if(typeof action.result.data.emprunts != 'undefined') {
/* For now, use the id, this may be ugly:
*/
var tab = Ext.getCmp('tab_emprunts_'+this.id_dossier);
tab.removeAll(true);
var nt = new EmpruntsPanel(action.result.data.emprunts);
tab.add(nt);
}
}
}
}
}
});
DossierPanel.superclass.initComponent.call(this);
console.log(this.events)
}
});
how about adding the forceLayout: true config property to each of the tabs or the tabpanel itself?
I'm hoping this would cause the fields to be calculated.
I think you need to include
defaults: { hideMode: 'offsets' }
in your tab panel.
I think u need set is Dirty = true
{ xtype: 'textfield', name: 'name' ,readOnly:true ,submitValue: true ,isDirty: function() { return true;} }

Resources