PDA

View Full Version : value is undefined in ext-all-debug.js Line 40707



Rashikh
17 Aug 2011, 11:21 PM
I am getting 'value is undefined' Error in ext-all-debug.js file @line 40707. I have attached my entire JS code which i am using in my JSP homepage which has tab panel , i am rendering my form panel to that tab panel.



Ext.override(Ext.form.Field, {

setFieldLabel: function(text) {
if (this.rendered) {
this.el.up('.x-form-item', 10, true).child('.x-form-item-label').update(text);
}
this.fieldLabel = text;
}
});


Ext.apply(Ext.form.VTypes, {
daterange: function(val, field) {
var date = field.parseDate(val);


if (!date) {
return false;
}
if (field.startDateField) {
var start = Ext.getCmp(field.startDateField);
if (!start.maxValue || (date.getTime() != start.maxValue.getTime())) {
start.setMaxValue(date);
start.validate();
}
} else if (field.endDateField) {
var end = Ext.getCmp(field.endDateField);
if (!end.minValue || (date.getTime() != end.minValue.getTime())) {
end.setMinValue(date);
end.validate();
}
}
/*
* Always return true since we're only using this vtype to set the min/max allowed values (these are tested for after the vtype test)
*/
return true;
}
});


Ext.QuickTips.init();


var agency_store = new Ext.data.ArrayStore({
fields: ['id', 'agency_name'],
data: [['1', 'Wipro'], ['2', 'External Consultant'], ['3', 'Contractor'], ['4', 'Others']]
});


var project_store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'empdetails',
method: 'GET'
}),
reader: new Ext.data.JsonReader({
root: 'projectnames'
}, ['proj_id', 'proj_name'])


});
project_store.load();


var role_store = new Ext.data.ArrayStore({
fields: ['id', 'role'],
data: [['1', 'Project Engineer'], ['2', 'Senior Engineer'], ['3', 'Project Manager']]
});


var location_type_store = new Ext.data.ArrayStore({
fields: ['id', 'location'],
data: [['1', 'Onsite'], ['2', 'Offshore']]
});


var location_store = new Ext.data.ArrayStore({
fields: ['id', 'location'],
data: [['1', 'New York'], ['2', 'Germany'], ['3', 'Bangalore'], ['4', 'Chennai']]
});


var user_type_store = new Ext.data.ArrayStore({
fields: ['id', 'user_type'],
data: [['1', 'Normal User'], ['2', 'Lead User'], ['3', 'Admin User']]
});


var wo_status_store = new Ext.data.ArrayStore({
fields: ['id', 'wo_status'],
data: [['1', 'Created'], ['2', 'Signed'], ['3', 'Not Available']]
});


var employee_data = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'actionServlet?action=getEmpData',
method: 'GET'
}),
reader: new Ext.data.JsonReader({
root: 'emp_data'
}, ['emp_id', 'emp_name', 'emp_email_id', 'emp_agency', 'emp_project_name', 'emp_client_director', 'emp_project_start_date', 'emp_project_end_date', 'emp_role', 'emp_billing_rate',
'emp_location_type', 'emp_work_location', 'emp_home_location', 'emp_user_type', 'emp_mode', 'emp_status', 'emp_wo_number', 'emp_wo_status']),
// autoLoad: true,
listeners: {
load: function() {
var rec = this.data.get(0);


Ext.getCmp('emp_id').setValue(rec.get('emp_id'));
Ext.getCmp('emp_name').setValue(rec.get('emp_name'));
Ext.getCmp('emp_email_id').setValue(rec.get('emp_email_id'));
Ext.getCmp('emp_agency').setValue(rec.get('emp_agency'));
Ext.getCmp('emp_project_name').setValue(rec.get('emp_project_name'));
Ext.getCmp('emp_client_director').setValue(rec.get('emp_client_director'));
Ext.getCmp('emp_project_start_date').setValue(rec.get('emp_project_start_date'));
Ext.getCmp('emp_project_end_date').setValue(rec.get('emp_project_end_date'));
Ext.getCmp('emp_role').setValue(rec.get('emp_role'));
Ext.getCmp('emp_billing_rate').setValue(rec.get('emp_billing_rate'));
Ext.getCmp('emp_location_type').setValue(rec.get('emp_location_type'));
Ext.getCmp('emp_work_location').setValue(rec.get('emp_work_location'));
Ext.getCmp('emp_home_location').setValue(rec.get('emp_home_location'));
Ext.getCmp('emp_user_type').setValue(rec.get('emp_user_type'));
Ext.getCmp('emp_mode').setValue(rec.get('emp_mode'));
Ext.getCmp('emp_status').setValue(rec.get('emp_status'));
Ext.getCmp('emp_wo_number').setValue(rec.get('emp_wo_number'));
Ext.getCmp('emp_wo_status').setValue(rec.get('emp_wo_status'));


}
}
});


var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'actionServlet?action=search',
method: 'GET'


}),
reader: new Ext.data.JsonReader({
root: 'emp_data',
totalProperty: 'totalCount'
}),
fields: ['emp_id', 'emp_name', 'emp_email_id', 'emp_agency']
});


var resultTpl = new Ext.XTemplate('<tpl for="."><tpl for="emp_data"><div class="search-item">', '<h3>{emp_id} - {emp_name}</h3>', '<p>{emp_email_id}</p>', '<p>{emp_agency}</p>', '</div></tpl></tpl>');


var searchFieldSet = {
xtype: 'fieldset',
title: 'Search',
id: 'searchFieldSet',
hideBorders: true,
autoHeight: true,
hidden: true,
defaults: {
width: 210
},
items: [{
xtype: 'combo',
store: ds,
id: 'search',
fieldLabel: 'Search',
displayField: 'emp_id',
typeAhead: false,
loadingText: 'Searching...',
width: 210,
pageSize: 2,
hideTrigger: true,
tpl: resultTpl,
itemSelector: 'div.search-item',
onSelect: function(record) {
employee_data.setBaseParam('emp_id', record.id);
employee_data.load();
Ext.getCmp('emp_id').focus();
}
}]


};


var empInfoFieldSet = {
xtype: 'fieldset',
title: 'Employee Information',
id: 'empInfoFieldSet',
autoHeight: true,
defaults: {
msgTarget: 'side',
allowBlank: false,
selectOnFocus: true,
width: 210
},
items: [{
xtype: 'numberfield',
fieldLabel: 'Employee id',
id: 'emp_id',
blankText: 'Emp id is required'
}, {
xtype: 'textfield',
fieldLabel: 'Employee name',
id: 'emp_name',
blankText: 'Name is required'
}, {
xtype: 'textfield',
fieldLabel: 'Employee Email Id',
id: 'emp_email_id',
blankText: 'Email id is required',
vtype: 'email',
vtypeText: 'Please enter a valid email!'
}, {
xtype: 'combo',
fieldLabel: 'Agency',
id: 'emp_agency',
value: 'Wipro',
store: agency_store,
valueField: 'id',
displayField: 'agency_name',
mode: 'local',
triggerAction: 'all',
editable: false,
typeAhead: true,
emptyText: 'Select an Agency',
blankText: 'Agency is required'
}]
};


var projdetFieldSet = {
xtype: 'fieldset',
id: 'projdetFieldSet',
// checkboxToggle:true,
title: 'Project Details',
autoHeight: true,
defaults: {
msgTarget: 'side',
allowBlank: false,
selectOnFocus: true,
width: 210
},
// collapsed:true,
items: [{
xtype: 'combo',
fieldLabel: 'Project Assigned',
id: 'emp_project_name',
store: project_store,
valueField: 'proj_id',
displayField: 'proj_name',
mode: 'local',
triggerAction: 'all',
editable: false,
typeAhead: true,
emptyText: 'Select a Project',
blankText: 'Project Name is required'
}, {
xtype: 'textfield',
fieldLabel: 'Client Director',
id: 'emp_client_director',
editable: false,
blankText: 'Client Director Name is required'
}, {
xtype: 'datefield',
fieldLabel: 'Project Start Date',
name: 'emp_project_start_date',
id: 'emp_project_start_date',
vtype: 'daterange',
endDateField: 'emp_project_end_date',
blankText: 'Project start date is required'
}, {
xtype: 'datefield',
fieldLabel: 'Project End Date',
name: 'emp_project_end_date',
id: 'emp_project_end_date',
// vtype: 'daterange',
// endDateField: 'emp_project_start_date'
blankText: 'Project end date is required'
}, {
xtype: 'combo',
fieldLabel: 'Role',
id: 'emp_role',
store: role_store,
valueField: 'id',
displayField: 'role',
mode: 'local',
triggerAction: 'all',
editable: false,
typeAhead: true,
emptyText: 'Select a Role',
blankText: 'Role is required'
}, {
xtype: 'numberfield',
fieldLabel: 'Billing Rate',
id: 'emp_billing_rate',
editable: false,
blankText: 'Billing Rate is required'
}]
};


var emplocFieldSet = {
xtype: 'fieldset',
// checkboxToggle:true,
title: 'Employee Location',
autoHeight: true,
defaults: {
msgTarget: 'side',
allowBlank: false,
selectOnFocus: true,
width: 210
},
defaultType: 'textfield',
// collapsed: true,
items: [{


xtype: 'radiogroup',
fieldLabel: 'Location Type',
id: 'emp_location_type',
items: [{
boxLabel: 'Off-Shore',
name: 'emp_location_type',
inputValue: 'Off-Shore',
checked: true,
listeners: {
check: function(field, checked) {
if (checked) {
Ext.getCmp('emp_home_location').hide();
Ext.getCmp('emp_home_location').setFieldLabel("");
} else {
Ext.getCmp('emp_home_location').show();
Ext.getCmp('emp_home_location').setFieldLabel("Home Location:");
}
}
}
}, {
boxLabel: 'On-Site',
name: 'emp_location_type',
inputValue: 'On-Site'
}]


}, {
xtype: 'combo',
fieldLabel: 'Work Location',
id: 'emp_work_location',
store: location_store,
valueField: 'id',
displayField: 'location',
mode: 'local',
triggerAction: 'all',
editable: false,
typeAhead: true,
emptyText: 'Select a location',
blankText: 'Location is required',
listeners: {
select: function() {
var val = (Ext.getCmp('emp_location_type').getValue()).getGroupValue();


if (val == "Off-Shore") {
Ext.getCmp('emp_home_location').setValue(Ext.getCmp('emp_work_location').getValue());
}
}


}


}, {
xtype: 'combo',
id: 'emp_home_location',
hidden: true,
store: location_store,
valueField: 'id',
displayField: 'location',
mode: 'local',
triggerAction: 'all',
editable: false,
typeAhead: true,
emptyText: 'Select a location',
blankText: 'Location is required'


}]


};


var userinfoFieldSet = {
xtype: 'fieldset',
id: 'userinfoFieldSet',
// checkboxToggle:true,
title: 'User Information',
autoHeight: true,
defaults: {
msgTarget: 'side',
allowBlank: false,
selectOnFocus: true,
width: 210
},
defaultType: 'textfield',
// collapsed: true,
items: [{
xtype: 'radiogroup',
fieldLabel: 'Employee Mode',
id: 'emp_mode',
items: [{
boxLabel: 'New',
name: 'emp_mode',
inputValue: 'New',
checked: true
}, {
boxLabel: 'Replacement',
name: 'emp_mode',
inputValue: 'Replacement'
}]
}, {
xtype: 'radiogroup',
fieldLabel: 'Employee Status',
id: 'emp_status',
items: [{
boxLabel: 'Active',
name: 'emp_status',
inputValue: 'Active',
checked: true
}, {
boxLabel: 'Inactive',
name: 'emp_status',
inputValue: 'Inactive'
}]
}, {
xtype: 'combo',
fieldLabel: 'User Type',
id: 'emp_user_type',
store: user_type_store,
value: 'Normal User',
valueField: 'id',
displayField: 'user_type',
mode: 'local',
triggerAction: 'all',
editable: false,
typeAhead: true,
selectOnFocus: true,
allowBlank: false
}, {
xtype: 'textfield',
fieldLabel: 'Work Order Number',
id: 'emp_wo_number',
blankText: 'WO no. is required'
}, {
xtype: 'combo',
fieldLabel: 'Work Order Status',
id: 'emp_wo_status',
store: wo_status_store,
value: 'Created',
valueField: 'id',
displayField: 'wo_status',
mode: 'local',
triggerAction: 'all',
editable: false,
typeAhead: true,
selectOnFocus: true,
allowBlank: false


}]
};


function allFieldsSetReadOnly(status) {
Ext.getCmp('emp_id').setReadOnly(status);
Ext.getCmp('emp_name').setReadOnly(status);
Ext.getCmp('emp_email_id').setReadOnly(status);
Ext.getCmp('emp_agency').setReadOnly(status);
Ext.getCmp('emp_project_name').setReadOnly(status);
Ext.getCmp('emp_client_director').setReadOnly(status);
Ext.getCmp('emp_project_start_date').setReadOnly(status);
Ext.getCmp('emp_project_end_date').setReadOnly(status);
Ext.getCmp('emp_role').setReadOnly(status);
Ext.getCmp('emp_billing_rate').setReadOnly(status);
Ext.getCmp('emp_location_type').setReadOnly(status);
Ext.getCmp('emp_work_location').setReadOnly(status);
Ext.getCmp('emp_home_location').setReadOnly(status);
Ext.getCmp('emp_user_type').setReadOnly(status);
Ext.getCmp('emp_mode').setReadOnly(status);
Ext.getCmp('emp_status').setReadOnly(status);
Ext.getCmp('emp_wo_number').setReadOnly(status);
Ext.getCmp('emp_wo_status').setReadOnly(status);
}


function onAdd() {
allFieldsSetReadOnly(false);
// Ext.getCmp('search').setValue("");
Ext.getCmp('searchFieldSet').hide();
Ext.getCmp('emp_id').setReadOnly(false);
emp_details_form.getForm().reset();
Ext.getCmp('emp_id').focus();


}


function onUpdate() {
allFieldsSetReadOnly(false);
// Ext.getCmp('search').setValue("");
Ext.getCmp('searchFieldSet').show();
Ext.getCmp('emp_id').setReadOnly(true);
emp_details_form.getForm().reset();
// Ext.getCmp('search').focus();


}


function onDelete() {
onUpdate();
allFieldsSetReadOnly(true);


}


var tbarButton = {
xtype: 'buttongroup',
columns: 3,
bodyBorder: false,
border: false,
defaults: {
width: 70
}, // ,enableToggle: true
items: [{
text: 'Add User',
icon: 'assets/images/add.png',
scale: 'medium',
iconAlign: 'left',
handler: function() {
process = 'Insert';
onAdd();
Ext.getCmp('submit_btn').setText("Submit");
}


}, {
text: 'Edit User',
icon: 'assets/images/edit.png',
scale: 'medium',
iconAlign: 'left',
handler: function() {
process = 'Update';
onUpdate();
Ext.getCmp('submit_btn').setText("Update");


}
}, {
text: 'Delete User',
icon: 'assets/images/delete.png',
scale: 'medium',
iconAlign: 'left',
handler: function() {
process = 'Delete';
onDelete();
Ext.getCmp('submit_btn').setText("Delete");
}
}]


};


var emp_details_form = new Ext.form.FormPanel({


url: 'actionServlet?action=save',
method: 'POST',


frame: true,
title: 'Employee Details',
width: 900,
labelWidth: 150,
autoHeight: true,
monitorValid: true,
tbar: [tbarButton],
layout: 'column',
autoScroll: true,
defaults: {
layout: 'anchor',
defaults: {
anchor: '100%'
}
},


items: [{
columnWidth: 1 / 2,
// baseCls:'x-plain',
bodyStyle: 'padding:5px 0 5px 5px',
items: [searchFieldSet, empInfoFieldSet, projdetFieldSet]
}, {
columnWidth: 1 / 2,
// baseCls:'x-plain',
bodyStyle: 'padding:5px',
items: [emplocFieldSet, userinfoFieldSet]
}],


buttons: [{
text: 'Submit',
id: 'submit_btn',
formBind: true,
handler: function() {
Ext.Msg.confirm('Status!', 'Do you want to save all data?', function(btn, text) {
if (btn == 'yes') {
emp_details_form.getForm().submit({


waitTitle: 'Connecting',
waitMsg: 'Sending data...',


success: function(form, action) {
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Success!', obj.msg);
emp_details_form.getForm().reset();
},
failure: function(form, action) {
if (action.failureType == 'server') {
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Failed!', obj.msg);
} else {
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText);
}
emp_details_form.getForm().reset();
}
});
}
});


}
}, {
text: 'Reset',
handler: function() {
Ext.Msg.confirm('Status!', 'Are you sure do you want to erase all data?', function(btn, text) {
if (btn == 'yes') {
emp_details_form.getForm().reset();
}
});


}
}, {
text: 'Search',
handler: function() {
employee_data.setBaseParam('emp_id', 209482);
employee_data.load();
Ext.getCmp('emp_id').focus();


}
}]
// buttons


});







I am getting value undefined error when i switch from one tab to the other, and the error is contiguous in firebug. I am trying to solve it over a long time but i couldn't find the solution......

Anybody please help me out !!

And also i m getting a is undefined ext-all.js at Line 11 when i use ext-all.js instead of ext-all-debug.js

For any queries please reply to this thread..



Thanks In Advance !!!