View Full Version : FF Layout Tab Grid Rendering Messed Up
Joyfulbob
11 Jun 2008, 1:17 PM
Nto sure how else to explain it. I've got a edit grid inside a tab on a layout. It has worked fine for a couple of weeks, then after making other unrelated code changes the layout gets jazzed up (See the attachment). Other tab grids are OK.
Happens in FF (a refresh solves it in IE7).
Thanks in advance!
jay@moduscreate.com
11 Jun 2008, 1:33 PM
Please post related code in php or code tags :)
Joyfulbob
11 Jun 2008, 1:39 PM
Here's my layout page, followed by the tcnEditGrid.js ux xtype edit grid that is the problem Tab. I haven't changed tcnEditGrid.js.
SiteCentral.html:
/$top
Content-type: text/html
/$page
<html>
<head>
<title>Site Central</title>
<link rel="stylesheet" type="text/css" href="/cgidev/js/ExtJS/ext2/resources/css/ext-all.css" />
<script type="text/javascript" src="/cgidev/js/ExtJS/ext2/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="/cgidev/js/ExtJS/ext2/ext-all-debug.js"></script>
<link rel="stylesheet" type="text/css" href="/cgidev/js/ExtJS/ext2/examples/examples.css" />
<script type="text/javascript" src="/cgidev/js/ExtJS/ext2/examples/examples.js"></script>
<script type="text/javascript" src="/cgidev/js/ExtJS/ext2/examples/grid/RowExpander.js"></script>
<script type="text/javascript">
/*global Ext, evbNameSpace */
// Ext.namespace('evbNameSpace.scmModule');
// var console = console || { log: Ext.log };
</script>
<script type="text/javascript" src="/cgidev/js/evb_combos.js"></script>
<!-- Everbrite pre-configured user-entension editables -->
<script type="text/javascript" src="/cgidev/js/ux_PromptField.js"></script>
<script type="text/javascript" src="/cgidev/js/ux_hPmtGrid.js"></script>
<script type="text/javascript" src="/cgidev/js/vmInqGrid.js"></script>
<script type="text/javascript" src="/cgidev/js/aroInqGrid.js"></script>
<script type="text/javascript" src="/cgidev/js/hInqGrid.js"></script>
<script type="text/javascript" src="/cgidev/js/thdEditPanel.js"></script>
<script type="text/javascript" src="/cgidev/js/tcnEditGrid.js"></script>
<script type="text/javascript" src="/cgidev/js/tcmEditGrid.js"></script>
<script type="text/javascript" src="/cgidev/js/ttmEditGrid.js"></script>
<script type="text/javascript" src="/cgidev/js/sxtEditGrid.js"></script>
<style type="text/css">
html, body {
font:normal 12px verdana;
margin:0;
padding:0;
border:0 none;
overflow:hidden;
height:100%;
}
p {
margin:5px;
}
.Statistics {
background-image:url(/cgidev/js/ExtJS/ext2/examples/shared/icons/fam/folder_wrench.png);
}
.nav {
background-image:url(/cgidev/js/ExtJS/ext2/examples/shared/icons/fam/folder_go.png);
}
#body .x-panel {
margin-bottom:20px;
}
.icon-grid {
background-image:url(/cgidev/js/ExtJS/ext2/examples/shared/icons/fam/grid.png) !important;
}
#button-grid .x-panel-body {
border:1px solid #99bbe8;
border-top:0 none;
}
.add {
background-image:url(/cgidev/js/ExtJS/ext2/examples/shared/icons/fam/add.gif) !important;
}
.remove {
background-image:url(/cgidev/js/ExtJS/ext2/examples/shared/icons/fam/delete.gif) !important;
}
.save {
background-image:url(/cgidev/js/ExtJS/ext2/examples/shared/icons/save.gif) !important;
}
.option {
background-image:url(/cgidev/js/ExtJS/ext2/examples/shared/icons/fam/cog_edit.png) !important;
}
.wrench {
background-image:url(/cgidev/js/ExtJS/ext2/examples/shared/icons/fam/folder_wrench.png) !important;
}
.close {
background-image:url(/cgidev/js/ExtJS/ext2/resources/images/slate/qtip/close.gif) !important;
}
.app {
background-image:url(/cgidev/js/ExtJS/ext2/examples/shared/icons/fam/application_go.png) !important;
}
.loading {
background-image:url(/cgidev/js/ExtJS/ext2/resources/images/default/tree/loading.gif) !important;
}
.done {
background-image:url(/cgidev/js/ExtJS/ext2/resources/images/default/grid/done.gif) !important;
}
.find {
background-image:url(/cgidev/js/ExtJS/img/find.png) !important;
}
.refresh {
background-image:url(/cgidev/js/ExtJS/examples/shared/icons/fam/table_refresh.png) !important;
}
.readonlycell {
background-color:#CCCCCC !important;
}
.x-form-field-wrap .evb-addtrigger-class {
background-image: url(/cgidev/images/add-trigger.gif);
cursor:pointer;
}
<!-- prompt field styles -->
p.cfg, p.header{
font-family: verdana,lucida,arial,helvetica,sans-serif;
}
pre {
font-size : 11px;
}
p.cfg {
font-size : 12px;
margin-left:10px;
margin-top:5px;
}
p.header {
font-size : 13px;
font-weight : bold;
}
p.cfg span{
font-weight : bold;
}
.images-view .x-window-body{
background: #ffffff;
color: #000000;
}
.images-view .thumb{
border:1px solid #dddddd;
padding: 0px;
height: 97px;
width: 95px;
}
.images-view .thumb-wrap table{
font: 11px Arial, Helvetica, sans-serif;
text-align: center;
}
.images-view .thumb-wrap{
float: left;
margin: 4px;
margin-right: 0;
padding: 5px;
cursor: pointer;
}
.images-view .x-view-over{
border:1px solid #cccccc;
background: #eeeeee;
padding: 4px;
}
.images-view .x-view-selected{
background: #ccddee;
border:1px solid #6699cc;
padding: 4px;
}
.images-view .x-view-selected .thumb{
border:1px solid #6699cc;
}
.images-view .loading-indicator {
font-size:11px;
background-image:url(/cgidev/js/ExtJS/ext2/resources/images/default/grid/loading.gif);
background-repeat: no-repeat;
background-position: left;
padding-left:20px;
margin:10px;
}
</style>
<script type="text/javascript">
// reference local blank image
Ext.BLANK_IMAGE_URL = '/cgidev/js/ExtJS/ext2/resources/images/default/s.gif';
Ext.ux.MenuPanel = function(config) {
Ext.ux.MenuPanel.superclass.constructor.call(this, config);
if((typeof this.menu =='undefined') || this.menu == null)
throw 'you need to specify an instance of Menu in your cfg object';
this.menu.shadow = false;//We don't need shadow, do we?Besides, without this IE6 complain so...
}
Ext.extend(Ext.ux.MenuPanel, Ext.Panel, {
afterRender: function(){
Ext.ux.MenuPanel.superclass.afterRender.call(this);
var el = this.menu.getEl();
el.getShim();
el.hideShim();
this.body.appendChild(el);
el.clearPositioning('auto');
el.setWidth('100%');
el.applyStyles({
border: '0px'
});
el.show();
},
getMenu: function(){
return this.menu;
},
//private
beforeDestroy: function(){
Ext.ux.MenuPanel.superclass.beforeDestroy.call(this);
this.menu.destroy();
}
});
Ext.reg('menupanel', Ext.ux.MenuPanel);
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
// Save states, preferences in a cookie
var cp = new Ext.state.CookieProvider({
expires: new Date(new Date().getTime()+(1000*60*60*24*30)) //30 days
});
Ext.state.Manager.setProvider(cp);
var menu1 = new Ext.menu.Menu({
id: 'mainMenu',
items: [
{
text: 'A/R Inquiry',
iconCls:'nav',
handler: function(){
var w = Ext.getCmp('center-panel');
w.add({contentEl:'center_aropen',title:'A/R Inquiry',xtype: 'aroInqGrid',closable:true,split: true,autoScroll:true,enableTabScroll:true}).show();
}
},{
text: 'Customer Master',
iconCls:'nav',
handler: function(){
// var w = Ext.getCmp('center-panel');
// w.add({contentEl:'center_cusmst',title:'Customer Master',autoLoad: {url: 'cusmst', params: 'submit=RETRIEVE&process=INQUIRE&processtype=DETAIL&dbfile=CUSMST'},closable:true,split: true,autoScroll:true,enableTabScroll:true}).show();
// centerPanel.setActiveTab('center_cusmst');
// For now open Customer Master in current CGI design
var comno = Ext.get('COMNOfield').dom.value;
var cusno = Ext.get('CUSNOfield').dom.value;
var url = 'flexac?submit=RETRIEVE&dbfile=cusmst&process=EDIT&processType=DETAIL&dbfile=CUSMST&comnoi=' + comno + '&cusnoi=' + cusno;
window.open(url);
}
},{
text: 'Customer Master Inquiry',
iconCls:'nav',
handler: function(){
// For now open Customer Master in current CGI design
var comno = Ext.get('COMNOfield').dom.value;
var cusno = Ext.get('CUSNOfield').dom.value;
var url = 'ej_cusmst?limit=50&dir=ASC&comparison=eq&filter-string-company=' + comno + '&filter-string-customer=' + cusno;
window.open(url);
}
},{
text: 'Released Items',
iconCls:'nav',
handler: function(){
var w = Ext.getCmp('center-panel');
w.add({contentEl:'center_rlshdr',title:'Released Items',xtype: 'hInqGrid',closable:true,split: true,autoScroll:true,enableTabScroll:true}).show();
}
},{
text: 'DOCS',
iconCls:'nav',
handler: function(){
// For now open FSPO in current design
var site = Ext.get('SITIDkey').dom.value;
var url = 'http://corp-dm/cyberdocs/quickstart.asp?show=SEARCHACT:__FORMNAME=custSearch:STORE_NUM=' + site;
window.open(url);
}
},{
text: 'EQS',
iconCls:'nav',
handler: function(){
var w = Ext.getCmp('center-panel');
w.add({contentEl:'center_eqs',title:'E.Q.S.',closable:true,split: true,autoScroll:true,enableTabScroll:true}).show();
centerPanel.setActiveTab('center_eqs');
}
},{
text: 'FSPO',
iconCls:'nav',
handler: function(){
// For now open FSPO in current CGI design
var sitid = Ext.get('SITIDkey').dom.value;
var url = 'fspofldsv?submit=GO&shsitid=' + sitid;
window.open(url);
}
},{
text: 'Installers',
iconCls:'nav',
handler: function(){
// For now open Installers in current CGI design
var vendor = Ext.get('SITIDkey').dom.value;
var url = 'installer?vndnri=' + vendor;
window.open(url);
}
},{
text: 'PIF',
iconCls:'nav',
handler: function(){
// Open the PIF Extranet web site
var plnbr = Ext.get('PLNBRfield').dom.value;
var url = 'http://extranet.everbrite.com/project/list-projects.jsp?projectStatus=&revisionStatus=&report=PI&projectNumber=' + plnbr;
window.open(url);
}
},{
text: 'Quality',
iconCls:'nav',
handler: function(){
// Open the Quality Extranet web site
var sitid = Ext.get('SITIDkey').dom.value;
var url = 'http://extranet.everbrite.com/quality/index.jsp?sitid=' + sitid;
window.open(url);
}
}
]
});
var siteMenu = {
xtype: 'menupanel',
title: 'Site-related Applications',
collapsible:true,
menu: menu1
};
var inqMenus = new Ext.menu.Menu({
id: 'inqMenu',
items: [
{
text: 'Open/SNB Releases',
iconCls:'nav',
handler: function(){
var w = Ext.getCmp('center-panel');
// 'X' parm value lets ej_opnsnb know we're coming from SiteCentral
w.add({contentEl:'center_opnsnb',title:'Open Releases/SNB',autoLoad: {url: 'ej_opnsnb', params: 'rlsts=X' },closable:true,split: true,autoScroll:true,enableTabScroll:true}).show();
centerPanel.setActiveTab('center_opnsnb');
}
},{
text: 'Open Releases',
iconCls:'nav',
handler: function(){
var url = 'ej_opnsnb?rlsts=O&load1sttime=Y&filterstringactcd=' + Ext.get('ACTCDfield').dom.value;
window.open(url);
}
},{
text: 'SNB',
iconCls:'nav',
handler: function(){
var url = 'ej_opnsnb?rlsts=S&load1sttime=Y&filterstringactcd=' + Ext.get('ACTCDfield').dom.value;
window.open(url);
}
},{
text: 'SNB in Tab',
iconCls:'nav',
handler: function(){
var url = 'ej_opnsnb?rlsts=S';
window.open(url);
}
}]
});
var inqMenu = {
xtype: 'menupanel',
title: 'Inquiries',
collapsible:true,
menu: inqMenus
};
var centerPanel = new Ext.TabPanel({
region:'center',
id:'center-panel',
deferredRender:true,
activeTab:0,
enableTabScroll:true,
autoScroll:true,
defaults: {autoScroll:true},
items:[
SITHDRCreateForm,
{
contentEl:'sitcnt',
title: 'Contacts',
id: 'siteContacts',
split: true,
autoScroll:true,
xtype:'tcnEditGrid',
enableTabScroll:true
},{
contentEl:'sitcmt',
title: 'Comments',
id: 'siteComments',
split: true,
autoScroll:true,
xtype:'tcmEditGrid',
enableTabScroll:true
},{
contentEl:'sitext',
title: 'Critical Issues',
tabtip:'Enter your critical issue dates here',
split: true,
autoScroll:true,
xtype:'sxtEditGrid',
// autoLoad: {url: 'FLEXUI', params: 'SITID=' + Ext.get('SITID').dom.value + '&submit=retrieve&process=edit&processtype=detail&dbfile=SITEXT&ajaxcall=Y' },
enableTabScroll:true
},{
contentEl:'sititm',
title: 'Product',
id: 'siteProduct',
split: true,
autoScroll:true,
xtype: 'ttmEditGrid',
enableTabScroll:true
}
]
})
var viewport = new Ext.Viewport({
layout:'border',
items:[
new Ext.BoxComponent({
region:'north',
el: 'north',
hidden:true,
height:32
}),{
region:'west',
id:'west-panel',
title:'Site Central',
split:true,
width: 200,
minSize: 175,
maxSize: 400,
collapsible: true,
margins:'0 0 0 5',
layout:'accordion',
layoutConfig:{
animate:true
},
items: [
siteMenu
, inqMenu
,{
title:'Reports',
border:false,
autoLoad: {url: '/cgidev/nav_as400reports.htm'}
},{
title:'Extranet',
border:false,
autoLoad: {url: '/cgidev/nav_extranet.htm'}
},{
title:'Miscellaneous',
border:false,
autoLoad: {url: '/cgidev/nav_misc.htm'}
}]
},
centerPanel
]
});
Ext.get('SITIDkey').dom.focus('', 10);
// Ext.getCmp('SITIDkey').focus('', 10);
// Ext.getEl('SITIDkey').setFocus('', 10);
// keyTrigger.onTriggerClick = SearchSitHdr;
keyTrigger.onTriggerClick = RetrieveRecord;
keyTrigger.applyToMarkup('SITIDkey');
// Prompt for valid Installers
VndnrTrigger.onTriggerClick = VenNamSelectUI;
VndnrTrigger.applyToMarkup('SITINfield');
// VndnrTrigger2.onTriggerClick = VenNamSelectUI;
// VndnrTrigger2.applyToMarkup('SITINfield');
// Rtv rcd when inputted key changes
// Ext.get('SITIDkey').on('blur', function(fld){
// RetrieveRecord();
// });
// end of onReady
});
</script>
</head>
<body>
<input type="hidden" name="usrpf" id="usrpf" value="/%usrpf%/">
<input type="hidden" name="divid" id="divid" value="/%divid%/">
<div id="sithdr">
<div id="SITHDRdiv"><input type="hidden" id="SITID" size="20" value="" /></div>
</div>
<div id="sitcmt" class="x-hide-display">
<div id="SITCMTdiv"></div>
</div>
<div id="sitcnt" class="x-hide-display">
<div id="SITCNTdiv"></div>
</div>
<div id="sitext" class="x-hide-display">
</div>
<div id="sititm" class="x-hide-display">
<div id="SITITMdiv"></div>
</div>
<div id="center_opnsnb" class="x-hide-display">
<p><i>The Flex Inquiry here</i></p>
</div id='opnsnb_div'> </div>
</div>
<div id="props-panel" style="width:200px;height:200px;overflow:hidden;">
</div>
<div id="west" class="x-hide-display">
<p>Choose your menu option here</p>
</div>
<div id="north" class="x-hide-display"></div>
<!-- thd combo boxes -->
<select name="SISTSArray" id="SISTSArray" style="display:none;">
<option value='A'>Active</option>
<option value='H'>Hold</option>
<option value='I'>Invoice</option>
<option value='P'>Prospect</option>
<option value='Q'>Quote</option>
<option value='M'>Maintenance</option>
<option value='C'>Close</option>
</select>
<select name="STRSTArray" id="STRSTArray" style="display:none;">
<option value='NEW'>New</option>
<option value='NO'>No</option>
<option value='RBD'>Rebuild</option>
<option value='RIM'>Reimage</option>
<option value='RMD'>Remodel</option>
<option value='RLC'>Relocation</option>
<option value='OIL'>Oil Alliance</option>
<option value='WLM'>WalMart</option>
</select>
<select name="SCNTTArray" id="SCNTTArray" style="display:none;">
<option value='C1'>Site Contact</option>
<option value='CN'>Contact Name</option>
<option value='C2'>Site Contact 2</option>
<option value='C3'>Site Contact 3</option>
<option value='LN'>Landlord</option>
<option value='EA'>Email</option>
<option value='IN'>Installer</option>
<option value='AN'>Architect</option>
</select>
</body>
</html>
tcnEditGrid.js:
var tcnDataStore; // this will be our datastore
var tcnColumnModel; // this will be our columnmodel
// var tcnEditGrid;
var tcnSelModel = new Ext.grid.RowSelectionModel({singleSelect:false});
// Adding a new entry/row:
var tcnCreateForm;
var tcnCreateWindow;
var key;
var dt = new Date();
// e.) Define the flds:
var SITIDfield;
var SCNTSfield;
var SCNTTfield;
var SITCXfield;
// Context menu
var tcnSelectedRow;
var tcnEditGrid = new Ext.extend(Ext.grid.EditorGridPanel, {
//begin template methods
initComponent: function() {
// a.) Data store:
tcnDataStore = new Ext.data.Store({
id: 'tcnDataStore',
proxy: new Ext.data.HttpProxy({
url: 'SITCNT', // File to connect to
method: 'POST'
}),
baseParams:{
submit: '',
process: 'EDIT',
processType: 'LIST',
SITID:' '
},
// b.) Reader:
reader: new Ext.data.JsonReader({ // we tell the datastore where to get his data from
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{ name : 'SITID', type: 'string' , mapping: 'SITID' }
, { name : 'SCNTS', type: 'int' , mapping: 'SCNTS' }
, { name : 'SCNTT', type: '' , mapping: 'SCNTT' }
, { name : 'SITCX', type: 'string' , mapping: 'SITCX' }
]) ,
sortInfo:{ field:'SCNTS', direction:"ASC" }
});
// b.) Column model: (Plex: write a cmField section for each field in the grid, and a variable for each fld attribute)
tcnColumnModel = new Ext.grid.ColumnModel(
[
{
header: 'Site',
readOnly: true,
dataIndex: 'SITID',
width: 120,
hidden: true,
renderer: function(value,cell) {
cell.css = "readonlycell";
return value;
}
} , {
header: 'Seq#',
readOnly: true,
dataIndex: 'SCNTS',
width: 102,
hidden: true,
renderer: function(value,cell) {
cell.css = "readonlycell";
return value;
}
}, {
header: 'Type',
readOnly: false,
dataIndex: 'SCNTT',
width: 140,
hidden: false
, editor: new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'SCNTTArray',
lazyRender:true,
listClass: 'x-combo-list-small'
})
} , {
header: 'Contact Info',
readOnly: false,
dataIndex: 'SITCX',
width: 300,
hidden: false
, editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 50,
maskRe: /([a-zA-Z0-9\s]+)$/ // alphanumeric + spaces allowed
})
}
]
);
tcnColumnModel.defaultSortable=true;
// this could be inline, but we want to define the Plant record
// type so we can add records dynamically
var Contact = Ext.data.Record.create([
// the "name" below matches the tag name to read, except "availDate"
// which is mapped to the tag "availability"
{ name : 'SITID', type: 'string' }
, { name : 'SCNTS', type: 'int' }
, { name : 'SCNTT' }
, { name : 'SITCX', type: 'string' }
// {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'}
]);
Ext.apply(this,{
id: 'tcnEditGrid',
store: tcnDataStore, // the datastore is defined here
cm: tcnColumnModel, // the columnmodel is defined here
clicksToEdit:1,
stripeRows: true,
autoWidth:true,
loadMask: true,
border:false,
frame:false,
viewConfig:{emptyText:'No rows to display'},
selModel: tcnSelModel,
// c.) toolbar items
tbar: [
{
text: 'Add Contacts', tooltip:'Add new Contacts', handler: this.displayFormWindow.createDelegate(this),
iconCls: 'add'
}
, '-', {
text: 'Delete selected Contacts', tooltip:'Delete selected row(s)', handler: this.confirmDeleteSITCNT.createDelegate(this),
iconCls: 'remove'
}
]
}); // end of apply
tcnEditGrid.superclass.initComponent.apply(this,arguments);
// The last thing we need is an actionlistener that will call the ontcnEditGridContextMenu function when we right click:
this.addListener('rowcontextmenu', this.ontcnEditGridContextMenu);
// Ok, now that the save function is ready, we need to attach it to the event where the user // edits the cell. This is done at the very end of our javascript file :
this.on('afteredit', this.saveTheSITCNT);
} // end of function initComponent
, // template method
onRender: function() {
// before parent code
//MyExtendedClass.superclass.onRender.apply(this, arguments);
tcnEditGrid.superclass.onRender.apply(this, arguments);
// The Comments tab has been clicked; redner the grid and load the Site Id's comments
key = Ext.get('SITIDkey').dom.value;
tcnDataStore.baseParams = {
submit:'RETRIEVE',
SITIDi: key
};
this.store.load();
} // end of function onRender
, // template method
initEvents: function() {
tcnEditGrid.superclass.initEvents.apply(this, arguments);
// f.) We need to write the code that describes the behavior of those fields: (within the onReady function):
SITIDfield = new Ext.form.TextField({
id: 'SITIDfield',
fieldLabel: 'Site',
maxLength: 20,
allowBlank: false,
width:120,
readOnly: false,
disabled: true,
hidden:false,
hideLabel:false,
maskRe: /([a-zA-Z0-9\s]+)$/
});
SCNTSfield = new Ext.form.NumberField({
id: 'SCNTSfield',
fieldLabel: 'Seq#',
maxLength: 17,
allowBlank: false,
width:102,
readOnly: true,
hidden:true,
hideLabel:true
});
SCNTTfield = new Ext.form.ComboBox({
store: new Ext.data.SimpleStore({
fields: ['key', 'label'],
data: [
['C1','Site Contact'],['CN','Contact Name'],['C2','Site Contact 2'],['C3','Site Contact 3'],['LN','Landlord'],['EA','Email'],['IN','Installer'],['AN','Architect']
]
}),
id:'SCNTTfield',
fieldLabel: 'Type',
displayField:'label',
valueField:'key',
mode: 'local',
typeAhead: true,
triggerAction: 'all',
selectOnFocus:true,
forceSelection:true
});
SITCXfield = new Ext.form.TextField({
id: 'SITCXfield',
fieldLabel: 'Contact Info',
maxLength: 50,
allowBlank: false,
width:300,
readOnly: false,
hidden:false,
hideLabel:false,
maskRe: /([a-zA-Z0-9.@\s]+)$/
});
// g.) Creating the form (to add a new rcd):
tcnCreateForm = new Ext.FormPanel({
labelAlign: 'left',
bodyStyle:'padding:5px',
width: 500,
height: 175,
items: [{
layout:'column',
border:false,
items:[{
columnWidth:1.0,
layout: 'form',
border:false,
items: [ SITIDfield, SCNTSfield, SCNTTfield, SITCXfield ]
},{
columnWidth:0.0,
layout: 'form',
border:false
}]
}
],
buttons: [{
text: 'Save and Close',
handler: this.createTheSITCNT
},{
text: 'Cancel',
handler: function(){
// because of the global vars, we can only instantiate one window... so let's just hide it.
tcnCreateWindow.hide();
}
}]
});
tcnCreateWindow = new Ext.Window({
id: 'tcnCreateWindow',
title: 'Add New Contact',
closable:true,
width: 500,
height: 175,
plain:true,
layout: 'fit',
modal:true,
items: tcnCreateForm
});
// Context menu defined (print removed):
SITCNTContextMenu = new Ext.menu.Menu({
id: 'tcnEditGridContextMenu',
items: [
{ text: 'Delete this Contacts', handler: this.deleteSITCNTContextMenu.createDelegate(this) }
]
});
} // end of function initEvents
// template method
,afterRender: function(){
//call parent
tcnEditGrid.superclass.afterRender.apply(this, arguments);
//after rendering, we can set a value if defined in the config
} // end of function afterRender
// template method
,beforeDestroy: function(){
} // end of function beforeDestroy
// template method
,onDestroy: function(){
} // end of function onDestroy
//end template methods
//-----------------------------------------------------------------------------
// Editing:
// d.) Save each cell as it changes (the entire row is sent):
,
saveTheSITCNT: function(oGrid_event){
Ext.Ajax.request({
waitMsg: 'Please wait...',
url: 'SITCNT',
params: {
submit: 'UPDATE',
process: 'EDIT',
processType: 'DETAIL',
SITID: oGrid_event.record.data.SITID,
SCNTS: oGrid_event.record.data.SCNTS,
SCNTT: oGrid_event.record.data.SCNTT,
SITCX: oGrid_event.record.data.SITCX
},
success: function(response){
var result=eval(response.responseText);
switch(result){
case 1:
tcnDataStore.commitChanges(); // changes successful, rmv red triangles
tcnDataStore.reload(); // reload our datastore.
break;
default:
Ext.MessageBox.alert('Error','Save not successful');
break;
}
},
failure: function(response){
var result=response.responseText;
Ext.MessageBox.alert('Error','could not connect to the database. please try again');
}
});
}
// Fncs to work with the form:
,
// h.) reset the Form before opening it
resetSITCNTForm: function (){
SITIDfield.setValue( Ext.get('SITIDkey').dom.value );
var gridRows = tcnEditGrid.colModel;
SCNTSkey = 0;
// console.info('Before init SCNTSkey =',SCNTSkey);
for(i=0; i<this.getStore().getCount(); i++){
var record = this.getStore().getAt(i); // Get the record
SCNTSkey = record.get('SCNTS'); // Get the fields data
}
var encoded_SCNTSkey = Ext.encode(SCNTSkey + 10 );
// console.info('After init SCNTSkey =', encoded_SCNTSkey );
SCNTSfield.setValue(encoded_SCNTSkey);
SCNTTfield.setValue('');
SITCXfield.setValue('');
}
,
// display or bring forth the form
displayFormWindow: function (){
if(!tcnCreateWindow.isVisible()){
this.resetSITCNTForm();
tcnCreateWindow.show();
} else {
tcnCreateWindow.toFront();
}
}
// i.) Implement a save method:
,
createTheSITCNT: function (){
if( SCNTTfield.isValid() && SITCXfield.isValid() ){
Ext.Ajax.request({
waitMsg: 'Please wait...',
url: 'SITCNT',
params: {
submit: 'ADD',
process: 'EDIT',
processType: 'DETAIL',
SITID: SITIDkey.getValue(),
SCNTS: SCNTSfield.getValue(),
SCNTT: SCNTTfield.getValue(),
SITCX: SITCXfield.getValue(),
debuggvar: 'N'
},
success: function(response){
var result=eval(response.responseText);
switch(result){
case 1:
Ext.example.msg('Confirmation', 'Contacts created successfully' );
tcnDataStore.reload();
tcnCreateWindow.hide();
break;
default:
Ext.MessageBox.alert('Warning','Could not create the Contacts');
break;
}
},
failure: function(response){
var result=response.responseText;
Ext.MessageBox.alert('Error','could not connect to the database; try again');
}
});
} else {
Ext.MessageBox.alert('Warning', 'Errors exist on your form');
}
}
, // Confirm delete:
confirmDeleteSITCNT: function (){
if(tcnSelModel.getCount() == 1) // only one Contacts is selected here
{
Ext.MessageBox.confirm('Confirmation','Delete this Contacts?', this.deleteSITCNT);
} else if(tcnSelModel.getCount() > 1){
Ext.MessageBox.confirm('Confirmation','Delete the ' + tcnSelModel.getCount() + ' selected Contacts?', this.deleteSITCNT);
} else {
Ext.msg('Error','Please select at least 1 Contacts to delete');
}
}
,
// The entire delete fnc:
deleteSITCNT: function (btn){
if(btn=='yes'){
// Loop through looking for multiple row(s) selected for delete:
var selections = tcnSelModel.getSelections();
var SITIDAry = [];
var SCNTSAry = [];
for(i = 0; i< tcnSelModel.getCount(); i++){
SITIDAry.push(selections[i].json.SITID);
SCNTSAry.push(selections[i].json.SCNTS);
}
var encoded_SITID_array = Ext.encode(SITIDAry);
var encoded_SCNTS_array = Ext.encode(SCNTSAry);
Ext.Ajax.request({
waitMsg: 'Please Wait',
url: 'SITCNT',
params: {
submit: 'DELETE',
process: 'EDIT',
processType: 'DETAIL',
SITIDAry: encoded_SITID_array,
SCNTSAry: encoded_SCNTS_array
},
success: function(response){
var result=eval(response.responseText);
switch(result){
case 1: // Success : simply reload
Ext.example.msg('Confirmation', 'Contact(s) deleted successfully' );
tcnDataStore.reload();
break;
default:
Ext.MessageBox.alert('Warning','Could not delete the entire selection.');
break;
}
},
failure: function(response){
var result=response.responseText;
Ext.MessageBox.alert('error','could not connect to the database. retry later');
}
});
}
}
, // The first one will be called everytime we right-click on the grid :
ontcnEditGridContextMenu: function (grid, rowIndex, e) {
e.stopEvent();
var coords = e.getXY();
SITCNTContextMenu.rowRecord = grid.store.getAt(rowIndex);
grid.selModel.selectRow(rowIndex);
tcnSelectedRow=rowIndex;
SITCNTContextMenu.showAt([coords[0], coords[1]]);
}
,
deleteSITCNTContextMenu: function (){
this.confirmDeleteSITCNT();
}
,
viewSITCNTContextMenu: function (){
// this.viewDetailsSITCNT();
}
}); // End EditorGridPanel
Ext.ComponentMgr.registerType('tcnEditGrid', tcnEditGrid);
Thanks!
Joyfulbob
12 Jun 2008, 5:18 AM
Now it's happening in another tab's edit grid. I made changes to just the form.submit function code, and suddenly it renders it incorrectly (see attachment). :-/
This is critical - I need to know what causes this - we can't have apps all of a sudden not render correctly.
Here's my tab's edit grid code:
var ttmDataStore; // this will be our datastore
var ttmColumnModel; // this will be our columnmodel
// var ttmEditGrid;
var ttmSelModel = new Ext.grid.RowSelectionModel({singleSelect:false});
// Adding a new entry/row:
var ttmCreateForm;
var ttmCreateWindow;
var key;
var dt = new Date();
var addMultiple = 'N';
var submitProcess;
// e.) Define the flds:
var SITIDfield;
var ITMSQfield;
var ITNBRfield;
var HOUSEfield;
var QTYREfield;
var SITSLfield;
var SITPRfield;
var SPRISfield;
var SPRICfield;
var SUPRTfield;
var SITQIfield;
var TAXYNfield;
var SIAINfield;
var ItNbrTrigger;
// Context menu:
var SITITMListingSelectedRow;
var ttmEditGrid = new Ext.extend(Ext.grid.EditorGridPanel, {
initComponent: function() {
// bbar totals:
var itemsSummary = new Ext.Toolbar.TextItem('Totals: 0');
function renderPosNeg(val) {
if( val>0 ){
return '<span style="color:green;">' + Ext.util.Format.usMoney(val); + '</span>';
} else { if( val<0 ){
return '<span style="color:red;">' + Ext.util.Format.usMoney(val); + '</span>';
}
return val;
}
};
// a.) Data store:
ttmDataStore = new Ext.data.Store({
id: 'ttmDataStore',
proxy: new Ext.data.HttpProxy({
url: 'SITITM', // File to connect to
method: 'POST'
}),
baseParams:{
submit: '',
process: 'EDIT',
processType: 'LIST',
SITID:' '
},
// b.) Reader:
reader: new Ext.data.JsonReader({ // we tell the datastore where to get his data from
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{ name : 'SITID', type: 'string' , mapping: 'SITID' }
, { name : 'ITMSQ', type: 'int' , mapping: 'ITMSQ', align: 'right' }
, { name : 'ITNBR', type: 'string' , mapping: 'ITNBR' }
, { name : 'ITDSC', type: 'string' , mapping: 'ITDSC' }
, { name : 'HOUSE', type: 'string' , mapping: 'HOUSE' }
, { name : 'QTYRE', type: 'int' , mapping: 'QTYRE', renderer: Ext.util.Format.usMoney }
, { name : 'SITSL', type: 'float' , mapping: 'SITSL', renderer: Ext.util.Format.usMoney }
, { name : 'SITPR', type: 'float' , mapping: 'SITPR', renderer: Ext.util.Format.usMoney }
, { name : 'SPRIS', type: 'float' , mapping: 'SPRIS', renderer: Ext.util.Format.usMoney}
, { name : 'SPRIC', type: 'float' , mapping: 'SPRIC', renderer: Ext.util.Format.usMoney }
, { name : 'SUPRT', type: 'string' , mapping: 'SUPRT' }
, { name : 'TAXYN', type: 'string' , mapping: 'TAXYN' }
, { name : 'SIAIN', type: 'string' , mapping: 'SIAIN' }
, { name : 'ALPH01', type: 'string' , mapping: 'ALPH01' }
]) ,
sortInfo:{ field:'ITMSQ', direction:"ASC" }
,
// Site's item totals:
listeners: {
'load':{
fn: function(store, records, options){
// Loop through the total Change
var sellTotal = 0.00;
var installTotal = 0.00;
for( var i = 0; i < store.getCount(); i++ ) {
var record = store.getAt(i);
sellTotal += record.get('QTYRE') * record.get('SITSL');
installTotal += record.get('QTYRE') * record.get('SPRIS');
}
// Add Summary to bottom paging bar
Ext.fly(itemsSummary.getEl()).update('Totals Sell/Install: ' + renderPosNeg(sellTotal) + ' / ' + renderPosNeg(installTotal) );
},
scope: this
}
}
});
// b.) Column model: (Plex: write a cmField section for each field in the grid, and a variable for each fld attribute)
ttmColumnModel = new Ext.grid.ColumnModel(
[
{
header: 'Site#',
readOnly: true,
dataIndex: 'SITID',
width: 120,
hidden: true,
renderer: function(value,cell) {
cell.css = "readonlycell";
return value;
}
}, {
header: 'Seq#',
readOnly: true,
dataIndex: 'ITMSQ',
width: 70,
hidden: true,
renderer: function(value,cell) {
cell.css = "readonlycell";
return value;
}
}, {
header: 'Item',
readOnly: false,
dataIndex: 'ITNBR',
width: 90,
hidden: false
, editor: new Ext.form.TextField({
allowBlank: false,
maxLength: 15,
maskRe: /([a-zA-Z0-9\s]+)$/ // alphanumeric + spaces allowed
})
} , {
header: 'Qty',
readOnly: false,
dataIndex: 'QTYRE',
width: 70,
hidden: false
, editor: new Ext.form.NumberField({
allowBlank: true,
allowDecimals: true,
decimalPrecision: 3,
allowNegative: true,
blankText: '',
maxLength: 2,
align: 'right'
})
} , {
header: 'Description',
readOnly: true,
dataIndex: 'ITDSC',
width: 250,
hidden: false,
renderer: function(value,cell) {
cell.css = "readonlycell";
return value;
}
} , {
header: 'Whs',
readOnly: false,
dataIndex: 'HOUSE',
width: 70,
hidden: false
, editor: new Ext.form.TextField({
allowBlank: true,
maxLength: 3,
maskRe: /([a-zA-Z0-9\s]+)$/ // alphanumeric + spaces allowed
})
} , {
header: 'Prt?',
readOnly: false,
dataIndex: 'SUPRT',
width: 70,
hidden: false
, editor: new Ext.form.TextField({
allowBlank: true,
maxLength: 1,
maskRe: /([a-zA-Z0-9\s]+)$/ // alphanumeric + spaces allowed
})
}, {
header: 'Product Sell',
readOnly: false,
dataIndex: 'SITSL',
width: 70,
hidden: false,
renderer: renderPosNeg,
editor: new Ext.form.NumberField({
allowBlank: true,
allowDecimals: true,
decimalPrecision: 2,
allowNegative: true,
blankText: '',
maxLength: 4,
align: 'right'
})
} , {
header: 'Product Cost',
readOnly: false,
dataIndex: 'SITPR',
width: 70,
hidden: false,
renderer: renderPosNeg
, editor: new Ext.form.NumberField({
allowBlank: true,
allowDecimals:true,
decimalPrecision: 2,
allowNegative: true,
blankText: '',
maxLength: 6,
align: 'right'
})
} , {
header: 'Inst.Sell',
readOnly: false,
dataIndex: 'SPRIS',
width: 48,
hidden: false,
renderer: renderPosNeg
, editor: new Ext.form.NumberField({
allowBlank: true,
allowDecimals: true,
decimalPrecision: 2,
allowNegative: true,
blankText: '',
maxLength: 8,
align: 'right'
})
} , {
header: 'Inst.Cost',
readOnly: false,
dataIndex: 'SPRIC',
width: 60,
hidden: false,
renderer: renderPosNeg
, editor: new Ext.form.NumberField({
allowBlank: true,
allowDecimals: true,
decimalPrecision: 2,
allowNegative: true,
blankText: '',
maxLength: 10,
align: 'right'
})
} , {
header: 'Tax?',
readOnly: false,
dataIndex: 'TAXYN',
width: 70,
hidden: false
, editor: new Ext.form.TextField({
allowBlank: true,
maxLength: 1,
maskRe: /([a-zA-Z0-9\s]+)$/ // alphanumeric + spaces allowed
})
}, {
header: 'Addtl. Info',
readOnly: false,
dataIndex: 'SIAIN',
width: 450,
hidden: false
, editor: new Ext.form.TextField({
allowBlank: true,
maxLength: 75,
maskRe: /([a-zA-Z0-9\s]+)$/ // alphanumeric + spaces allowed
})
}, {
header: 'Released?',
readOnly: true,
dataIndex: 'ALPH01',
width: 40,
hidden: false,
renderer: function(value,cell) {
cell.css = "readonlycell";
if ( value == '1' ) {
value ='one';
} else if ( value == 'M' ) {
value ='multiple';
} else {
value = '';
}
return value;
}
}
]
);
ttmColumnModel.defaultSortable=true;
Ext.apply(this,{
id: 'ttmEditGrid',
store: ttmDataStore, // the datastore is defined here
cm: ttmColumnModel, // the columnmodel is defined here
enableColLock:false,
clicksToEdit:1,
stripeRows: true,
autoWidth:true,
loadMask: true,
border:false,
frame:false,
viewConfig:{emptyText:'No rows to display'},
selModel: ttmSelModel,
// c.) toolbar items
tbar: [
{
text: 'Add Items', tooltip:'Add new Items', handler: this.displayFormWindow.createDelegate(this),
iconCls: 'add',
scope: this
}, '-', {
text: 'Delete selected Items', tooltip:'Delete selected row(s)', handler: this.confirmDeleteSITITM,
iconCls: 'remove',
scope: this
}, '-', {
text: 'Create Release', tooltip:'Create a Release from item(s)', handler: this.confirmCreateRelease,
iconCls: 'app',
scope: this
},{
text: 'Release entire Site', tooltip:'Create a Release for all items', handler: this.confirmReleaseEntireSite,
iconCls: 'app',
scope: this
},{
text: 'Add item(s) to existing Release', tooltip:'Create a Release from an existing Release', handler: this.confirmReleaseFromExisting,
iconCls: 'app',
scope: this
},{
text: 'View Release(s)', tooltip:'View the releases for this site', handler: this.ttmViewReleases.createDelegate(this),
iconCls: 'app',
scope: this
}
],
// Item totals:
bbar: new Ext.PagingToolbar({
pageSize: 200, // Default is 20
disabled: true,
store: ttmDataStore,
displayInfo: true,
displayMsg: '{2} Records',
emptyMsg: "No Records",
items: ['-',' ', itemsSummary]
})
}); // end of apply
ttmEditGrid.superclass.initComponent.apply(this,arguments);
// The last thing we need is an actionlistener that will call the onttmEditGridContextMenu function when we right click:
this.addListener('rowcontextmenu', this.onttmEditGridContextMenu);
// Ok, now that the save function is ready, we need to attach it to the event where the user // edits the cell. This is done at the very end of our javascript file :
this.on('afteredit', this.saveTheSITITM);
} // end of function initComponent
// template method
,onRender: function() {
// before parent code
/**
* Call parent method
* The pattern of calling the parent (superclass) method is always the
* same. We call the parent to ensure we start with the capabilities
* of the parent class before we apply any additions or overrides.
*/
//MyExtendedClass.superclass.onRender.apply(this, arguments);
ttmEditGrid.superclass.onRender.apply(this, arguments);
// The Comments tab has been clicked; redner the grid and load the Site Id's comments
key = Ext.get('SITIDkey').dom.value;
ttmDataStore.baseParams = {
submit:'RETRIEVE',
SITIDi: key
};
this.store.load();
} // end of function onRender
// template method
,initEvents: function(){
ttmEditGrid.superclass.initEvents.apply(this, arguments);
// f.) We need to write the code that describes the behavior of those fields: (within the onReady function):
SITIDfield = new Ext.form.TextField({
id: 'SITIDfield',
fieldLabel: 'Site#',
maxLength: 20,
allowBlank: false,
width:120,
readOnly: true,
disabled: true,
hidden:false,
hideLabel:false,
maskRe: /([a-zA-Z0-9\s]+)$/
});
ITMSQfield = new Ext.form.NumberField({
id: 'ITMSQfield',
fieldLabel: 'Seq#',
maxLength: 5,
allowBlank: false,
width:60,
readOnly: false,
disabled: true,
hidden:true,
hideLabel:true,
maskRe: /([a-zA-Z0-9\s]+)$/
});
ITNBRfield = new Ext.form.TextField({
id: 'ITNBRfield',
fieldLabel: 'Item',
maxLength: 15,
allowBlank: false,
width:120,
readOnly: false,
hidden:false,
hideLabel:false,
maskRe: /([a-zA-Z0-9\s]+)$/
});
HOUSEfield = new Ext.form.ComboBox({
id: 'HOUSEfield',
name:'HOUSEfield',
fieldLabel: 'Warehouse',
hiddenName:'HOUSE',
store: new Ext.data.SimpleStore({
fields: ['key', 'house'],
data : Ext.comboboxdata.warehouses // from evb_combos.js
}),
valueField:'key',
displayField:'house',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select Whs...',
selectOnFocus:true,
forceSelection:true,
width:190
});
QTYREfield = new Ext.form.NumberField({
id: 'QTYREfield',
fieldLabel: 'Qty',
maxLength: 10,
allowBlank: true,
width:60,
readOnly: false,
hidden:false,
hideLabel:false,
decimalPrecision: 3
});
SITSLfield = new Ext.form.NumberField({
id: 'SITSLfield',
fieldLabel: 'Product Sell',
maxLength: 9,
allowBlank: true,
width:54,
readOnly: false,
hidden:false,
hideLabel:false,
decimalPrecision: 2
});
SITPRfield = new Ext.form.NumberField({
id: 'SITPRfield',
fieldLabel: 'Product Cost',
maxLength: 9,
allowBlank: true,
width:54,
readOnly: false,
hidden:false,
hideLabel:false,
decimalPrecision: 2
});
SPRISfield = new Ext.form.NumberField({
id: 'SPRISfield',
fieldLabel: 'Install Sell',
maxLength: 9,
allowBlank: true,
width:54,
readOnly: false,
hidden:false,
hideLabel:false,
decimalPrecision: 2
});
SPRICfield = new Ext.form.NumberField({
id: 'SPRICfield',
fieldLabel: 'Install Cost',
maxLength: 9,
allowBlank: true,
width:54,
readOnly: false,
hidden:false,
hideLabel:false,
decimalPrecision: 2
});
SUPRTfield = new Ext.form.Checkbox({
id: 'SUPRTfield',
fieldLabel: 'Print Internally?',
checked:false
});
SITQIfield = new Ext.form.Checkbox({
id: 'SITQIfield',
fieldLabel: 'Quote?',
checked:true
});
TAXYNfield = new Ext.form.Checkbox({
id: 'TAXYNfield',
fieldLabel: 'Tax?',
checked:true
});
SIAINfield = new Ext.form.TextField({
id: 'SIAINfield',
fieldLabel: 'Addtl. Info',
maxLength: 75,
allowBlank: true,
width:200,
readOnly: false,
hidden:false,
hideLabel:false
});
ItNbrTrigger = new Ext.form.TriggerField({
emptyText: 'Enter Item',
labelStyle: 'font-case:lower;',
triggerClass: 'x-form-search-trigger'
});
// g.) Creating the form (to add a new rcd):
ttmCreateForm = new Ext.FormPanel({
labelAlign: 'left',
bodyStyle:'padding:5px',
width: 700,
items: [{
layout:'column',
border:false,
items:[{
columnWidth:0.6,
layout: 'form',
border:false,
items: [ SITIDfield, ITNBRfield, HOUSEfield, QTYREfield, SUPRTfield, SIAINfield ]
},{
columnWidth:0.4,
layout: 'form',
border:false
, items: [ ITMSQfield, SITSLfield, SITPRfield, SPRISfield, SPRICfield, SITQIfield, TAXYNfield ]
}]
}
],
buttons: [{
text: 'Save',
handler: this.createSITITMs.createDelegate(this)
},{
text: 'Save and Close',
handler: this.createTheSITITM.createDelegate(this)
},{
text: 'EditCheck, Save and Close',
handler: this.createTheSITITMe.createDelegate(this)
},{
text: 'Cancel',
handler: function(){
// because of the global vars, we can only instantiate one window... so let's just hide it.
ttmCreateWindow.hide();
}
}]
});
ttmCreateWindow= new Ext.Window({
id: 'ttmCreateWindow',
title: 'Add New Item',
closable:true,
width: 600,
height: 350,
plain:true,
layout: 'fit',
modal:true,
items: ttmCreateForm
});
// Context menu defined (print removed):
SITITMContextMenu = new Ext.menu.Menu({
id: 'ttmEditGridContextMenu',
items: [
{ text: 'View Item\s Release(s)', handler: this.ttmViewReleases.createDelegate(this) }
]
});
} // end of function initEvents
// template method
,afterRender: function(){
//call parent
ttmEditGrid.superclass.afterRender.apply(this, arguments);
//after rendering, we can set a value if defined in the config
} // end of function afterRender
, // d.) Save each cell as it changes (the entire row is sent):
saveTheSITITM: function (oGrid_event){
Ext.Ajax.request({
waitMsg: 'Please wait...',
url: 'SITITM',
params: {
submit: 'UPDATE',
process: 'EDIT',
processType: 'DETAIL',
SITID: oGrid_event.record.data.SITID,
ITMSQ: oGrid_event.record.data.ITMSQ,
ITNBR: oGrid_event.record.data.ITNBR,
HOUSE: oGrid_event.record.data.HOUSE,
QTYRE: oGrid_event.record.data.QTYRE,
SITSL: oGrid_event.record.data.SITSL,
SITPR: oGrid_event.record.data.SITPR,
SPRIS: oGrid_event.record.data.SPRIS,
SPRIC: oGrid_event.record.data.SPRIC,
SUPRT: oGrid_event.record.data.SUPRT,
TAXYN: oGrid_event.record.data.TAXYN,
SIAIN: oGrid_event.record.data.SIAIN
},
success: function(response){
var result=eval(response.responseText);
switch(result){
case 1:
ttmDataStore.commitChanges(); // changes successful, rmv red triangles
ttmDataStore.reload(); // reload our datastore.
break;
default:
Ext.MessageBox.alert('Error','Save not successful');
break;
}
},
failure: function(response){
var result=response.responseText;
Ext.MessageBox.alert('Error','could not connect to the database. please try again');
}
});
}
// Fncs to work with the form:
, // reset form fields
resetTcnForm: function (){
SITIDfield.setValue( Ext.get('SITIDkey').dom.value );
for(i=0; i< this.getStore().getCount(); i++){
var record = this.getStore().getAt(i); // Get the record
ITMSQkey = record.get('ITMSQ'); // Get the fields data
}
var encoded_ITMSQkey = Ext.encode(ITMSQkey +10);
ITMSQfield.setValue(encoded_ITMSQkey);
ITNBRfield.setValue('');
HOUSEfield.setValue('');
QTYREfield.setValue(0);
SITSLfield.setValue(0);
SITPRfield.setValue(0);
SPRISfield.setValue(0);
SPRICfield.setValue(0);
SUPRTfield.setValue('false');
SITQIfield.setValue('true');
TAXYNfield.setValue('true');
SIAINfield.setValue('');
}
, // display or bring forth the form
displayFormWindow: function (){
if(!ttmCreateWindow.isVisible()){
// h.) reset the Form before opening it
SITIDfield.setValue( Ext.get('SITIDkey').dom.value );
ITNBRfield.setValue('');
ITMSQkey = 0;
for(i=0; i< this.getStore().getCount(); i++){
var record = this.getStore().getAt(i); // Get the record
ITMSQkey = record.get('ITMSQ'); // Get the fields data
}
var encoded_ITMSQkey = Ext.encode(ITMSQkey +10);
ITMSQfield.setValue(encoded_ITMSQkey);
HOUSEfield.setValue('');
QTYREfield.setValue(0);
SITSLfield.setValue(0);
SITPRfield.setValue(0);
SPRISfield.setValue(0);
SPRICfield.setValue(0);
SUPRTfield.setValue('false');
SITQIfield.setValue('true');
TAXYNfield.setValue('true');
SIAINfield.setValue('');
ttmCreateWindow.show();
} else {
ttmCreateWindow.toFront();
}
ItNbrTrigger.onTriggerClick = this.ItmRvaSelectUI;
ItNbrTrigger.applyToMarkup('ITNBRfield');
}
, // Prompt for valid Items
ItmRvaSelectUI: function (){
var vndnr = ITNBRfield.getValue();
var w = Ext.getCmp('center-panel');
w.add({contentEl:'center_',id:'center_itmrva',title:'Item Revision',xtype: 'irvItmRva',closable:true,split: true,autoScroll:true,enableTabScroll:true}).show();
}
, // Create single or multiple litems?
createSITITMs: function (){
addMultiple = 'Y';
// console.info('adding multiple= ' , addMultiple );
for(i=0; i< this.getStore().getCount(); i++){
var record = this.getStore().getAt(i); // Get the record
ITMSQkey = record.get('ITMSQ'); // Get the fields data
}
var encoded_ITMSQkey = Ext.encode(ITMSQkey +10);
ITMSQfield.setValue(encoded_ITMSQkey);
this.createTheSITITM();
}
, // i.) Implement a save method:
createTheSITITM: function (){
if( SITIDfield.isValid() && ITNBRfield.isValid() && HOUSEfield.isValid() && QTYREfield.isValid() && SITSLfield.isValid() && SITPRfield.isValid() && SPRISfield.isValid() && SPRICfield.isValid() && SUPRTfield.isValid() && SITQIfield.isValid() && TAXYNfield.isValid() && SIAINfield.isValid() ){
Ext.Ajax.request({
waitMsg: 'Please wait...',
url: 'SITITM',
params: {
submit: 'ADD',
process: 'EDIT',
processType: 'DETAIL',
SITID: SITIDfield.getValue(),
ITMSQ: ITMSQfield.getValue(),
ITNBR: ITNBRfield.getValue(),
HOUSE: HOUSEfield.getValue(),
QTYRE: QTYREfield.getValue(),
SITSL: SITSLfield.getValue(),
SITPR: SITPRfield.getValue(),
SPRIS: SPRISfield.getValue(),
SPRIC: SPRICfield.getValue(),
SUPRT: SUPRTfield.getValue(),
SITQI: SITQIfield.getValue(),
TAXYN: TAXYNfield.getValue(),
SIAIN: SIAINfield.getValue()
},
success: function(response){
var result=eval(response.responseText);
switch(result){
case 1:
Ext.example.msg('Confirmation', 'Item created successfully' );
ttmDataStore.reload();
if ( addMultiple != 'Y' ) {
ttmCreateWindow.hide();
// console.info('added single =', addMultiple );
} else {
ITNBRfield.setValue('');
ITMSQfield.setValue( Ext.encode(ITMSQfield.getValue() +10) );
HOUSEfield.setValue('');
QTYREfield.setValue(0);
SITSLfield.setValue(0);
SITPRfield.setValue(0);
SPRISfield.setValue(0);
SPRICfield.setValue(0);
SUPRTfield.setValue('false');
SITQIfield.setValue('true');
TAXYNfield.setValue('true');
SIAINfield.setValue('');
ttmCreateWindow.show();
// console.info('added multiple =', addMultiple );
}
break;
case 2:
Ext.MessageBox.alert('Warning','Item does not exist; prompt for valid values');
break;
default:
Ext.MessageBox.alert('Warning','Could not create the Items');
break;
}
},
failure: function(response){
var result=response.responseText;
Ext.MessageBox.alert('Error','could not connect to the database; try again');
}
});
} else {
Ext.MessageBox.alert('Warning', 'Errors exist on your form');
}
addMultiple == 'N';
}
,
createTheSITITMe: function (){
if( SITIDfield.isValid() && ITNBRfield.isValid() && HOUSEfield.isValid() && QTYREfield.isValid() && SITSLfield.isValid() && SITPRfield.isValid() && SPRISfield.isValid() && SPRICfield.isValid() && SUPRTfield.isValid() && SITQIfield.isValid() && TAXYNfield.isValid() && SIAINfield.isValid() ){
Ext.getCmp('ttmCreateForm').submit({
root:'data',
waitMsg: 'Please wait...',
url: 'SITITM',
params: {
submit: 'ADD',
process: 'EDIT',
processType: 'DETAIL',
SITID: SITIDfield.getValue(),
ITMSQ: ITMSQfield.getValue(),
ITNBR: ITNBRfield.getValue(),
HOUSE: HOUSEfield.getValue(),
QTYRE: QTYREfield.getValue(),
SITSL: SITSLfield.getValue(),
SITPR: SITPRfield.getValue(),
SPRIS: SPRISfield.getValue(),
SPRIC: SPRICfield.getValue(),
SUPRT: SUPRTfield.getValue(),
SITQI: SITQIfield.getValue(),
TAXYN: TAXYNfield.getValue(),
SIAIN: SIAINfield.getValue()
},
success: function(response){
var result=eval(response.responseText);
switch(result){
case 1:
Ext.example.msg('Confirmation', 'Item created successfully' );
ttmDataStore.reload();
if ( addMultiple != 'Y' ) {
ttmCreateWindow.hide();
// console.info('added single =', addMultiple );
} else {
ITNBRfield.setValue('');
ITMSQfield.setValue( Ext.encode(ITMSQfield.getValue() +10) );
HOUSEfield.setValue('');
QTYREfield.setValue(0);
SITSLfield.setValue(0);
SITPRfield.setValue(0);
SPRISfield.setValue(0);
SPRICfield.setValue(0);
SUPRTfield.setValue('false');
SITQIfield.setValue('true');
TAXYNfield.setValue('true');
SIAINfield.setValue('');
ttmCreateWindow.show();
// console.info('added multiple =', addMultiple );
}
break;
case 2:
Ext.MessageBox.alert('Warning','Item does not exist; prompt for valid values');
break;
default:
Ext.MessageBox.alert('Warning','Could not create the Items');
break;
}
},
failure: function(response){
var result=response.responseText;
Ext.MessageBox.alert('Error','could not connect to the database; try again');
}
});
} else {
Ext.MessageBox.alert('Warning', 'Errors exist on your form');
}
addMultiple == 'N';
}
, // Confirm delete:
confirmDeleteSITITM: function (){
if(ttmSelModel.getCount() == 1) // only one Items is selected here
{
Ext.MessageBox.confirm('Confirmation','Delete this Item?', this.deleteSITITM );
} else if(ttmSelModel.getCount() > 1){
Ext.MessageBox.confirm('Confirmation','Delete the ' + ttmSelModel.getCount() + ' selected Items?', this.deleteSITITM);
} else {
Ext.example.msg('Error','Please select at least 1 Items to delete');
}
}
, // The entire delete fnc:
deleteSITITM: function (btn){
if(btn=='yes'){
// Loop through looking for multiple row(s) selected for delete:
var selections = ttmSelModel.getSelections();
var SITIDAry = [];
var ITNBRAry = [];
var ITMSQAry = [];
for(i = 0; i< ttmSelModel.getCount(); i++){
SITIDAry.push(selections[i].json.SITID);
ITNBRAry.push(selections[i].json.ITNBR);
ITMSQAry.push(selections[i].json.ITMSQ);
}
var encoded_SITID_array = Ext.encode(SITIDAry);
var encoded_ITNBR_array = Ext.encode(ITNBRAry);
var encoded_ITMSQ_array = Ext.encode(ITMSQAry);
Ext.Ajax.request({
waitMsg: 'Please Wait',
url: 'SITITM',
params: {
submit: 'DELETE',
process: 'EDIT',
processType: 'DETAIL',
SITIDAry: encoded_SITID_array,
ITNBRAry: encoded_ITNBR_array,
ITMSQAry: encoded_ITMSQ_array
},
success: function(response){
var result=eval(response.responseText);
switch(result){
case 1: // Success : simply reload
Ext.example.msg('Confirmation', 'Item(s) deleted successfully' );
ttmDataStore.reload();
break;
default:
Ext.MessageBox.alert('Warning','Could not delete the entire selection.');
break;
}
},
failure: function(response){
var result=response.responseText;
Ext.MessageBox.alert('error','could not connect to the database. retry later');
}
});
}
}
, // Confirm create of Release:
confirmCreateRelease: function (){
submitProcess = 'CRTPARTRLS';
if(ttmSelModel.getCount() == 1) // only one Items is selected here
{
Ext.MessageBox.confirm('Confirmation','Create a Release for this Item?', this.createRelease );
} else if(ttmSelModel.getCount() > 1){
Ext.MessageBox.confirm('Confirmation','Create a Release for the ' + ttmSelModel.getCount() + ' selected Items?', this.createRelease);
} else {
Ext.example.msg('Error','Please select at least 1 Items to Create a Release from');
}
}
, // Confirm Release from existing Release:
confirmReleaseFromExisting: function (){
submitProcess = 'EXISTRLS';
if(ttmSelModel.getCount() == 1) // only one Items is selected here
{
Ext.MessageBox.confirm('Confirmation','Add this Item to an existing Release?', this.createRelease );
} else if(ttmSelModel.getCount() > 1){
Ext.MessageBox.confirm('Confirmation','Add the ' + ttmSelModel.getCount() + ' selected Items to an existing Release?', this.createRelease);
} else {
Ext.example.msg('Error','Please select at least 1 Items to release to an existing Release');
}
}
, // Confirm Release from existing Release:
confirmReleaseEntireSite: function (){
submitProcess = 'CRTRLS';
Ext.MessageBox.confirm('Confirmation','Create a Release for all items?', this.createRelease );
}
, // The entire delete fnc:
createRelease: function (btn){
if(btn=='yes'){
// Loop through looking for multiple row(s) selected for delete:
var selections = ttmSelModel.getSelections();
var ITNBRAry = [];
var EXISTRLS;
for(i = 0; i< ttmSelModel.getCount(); i++){
ITNBRAry.push(selections[i].json.ITNBR);
// EXISTRLS.push(selections[i].json.EXISTRLS);
}
var encoded_ITNBR_array = Ext.encode(ITNBRAry);
// var encoded_existingRelease = Ext.encode(EXISTRLS);
Ext.Ajax.request({
waitMsg: 'Please Wait',
url: 'SITITM',
params: {
submit: submitProcess,
process: 'EDIT',
processType: 'LIST',
SITIDi: SITIDkey.getValue(),
ITNBRAry: encoded_ITNBR_array,
// EXISTRLS: encoded_existingRelease
EXISTRLS: 0
},
success: function(response){
var result=eval(response.responseText);
switch(result){
case 1: // Success : simply reload
Ext.example.msg('Confirmation', 'Item(s) released successfully' );
break;
default:
Ext.MessageBox.alert('Warning','Could not release item(s)');
break;
}
},
failure: function(response){
var result=response.responseText;
Ext.MessageBox.alert('error','could not connect to the database. retry later');
}
});
}
}
, // The first one will be called everytime we right-click on the grid :
onttmEditGridContextMenu: function (grid, rowIndex, e) {
e.stopEvent();
var coords = e.getXY();
SITITMContextMenu.rowRecord = grid.store.getAt(rowIndex);
grid.selModel.selectRow(rowIndex);
SITITMListingSelectedRow=rowIndex;
SITITMContextMenu.showAt([coords[0], coords[1]]);
// Ext.example.msg('Confirmation', 'cm: ' + rowIndex );
}
,
ttmViewReleases: function (){
// this.viewDetailsSITITM();
}
// eo extend EditorGridPanel
});
Ext.ComponentMgr.registerType('ttmEditGrid', ttmEditGrid);
Thanks in advance!
Joyfulbob
12 Jun 2008, 8:41 AM
I discovered that if I comment out Ext.state.Manager.setProvider(cp); then it doesn't happen, so apparently there's a conflict here.
How do I solve this? We need to allow users to save their preferences.
Thanks in advance!
mjlecomte
12 Jun 2008, 9:34 AM
Whew........that is a lot of code to look at for someone trying to help. Suggest you work with a smaller example from the demos perhaps to show your problem. There are demos that have stateManager in them I believe.
Joyfulbob
12 Jun 2008, 9:45 AM
Sorry; I should've trimmed it down. I searched for rendering problems and didn't find any type of pattern I could look for in my code.
One post noted that cookies/state could interfere. How would I check that? What two things could cause such a conflict?
I'll investigate stateManager. Here's my state code. Agina, if I comment out the setProvider it renders correctly:
Ext.form.Field.prototype.msgTarget = 'side';
// Save states, preferences in a cookie
var cp = new Ext.state.CookieProvider({
expires: new Date(new Date().getTime()+(1000*60*60*24*30)) //30 days
});
Ext.state.Manager.setProvider(cp);
Thanks in advance!
Nareg
13 Jun 2008, 3:17 AM
Consider the information size in bytes you put in a particular cookie while saving the state. If you put too much, you'll definitely get an exception, and the code following the exceptional code line won't work. If I remember correctly, FF allows 4KB a cookie (not sure) AND 50 cookies at once. There's nothing you can do to change it in FF. A similar situation might rise in IE as well. However the 4KB/50 is different for IE.
As a hint try to put the state saving code in a try...catch... block and see if it solves the rendering problem (it might as well introduce a state problem). If so, your problem is probably the information size you're trying to put in a cookie.
Joyfulbob
13 Jun 2008, 5:27 AM
Thanks for your reply!
I didn't know there were limits; does the StateManager inform you? Or is there a way to set that limit? I would have no idea when my app would hit it. (I'll have to read up on this)
I'm also concerned that that's even an issue in my "small" app at this point - I've got only 1 layout with 4 default tabs, and about 10 xTypes (and will be adding more). That seems way small compared to others I've seen on the forums.
Are there standards for states/cookies? Perhaps that could be added to the Build a Big App Tutorial.
I'll use the try/catch block; that should let me know conclusively.
Thanks again!
Bob
Nareg
14 Jun 2008, 1:46 AM
Well, not quite sure if the StateManager has a way to inform you about those limits. Actually, I did have a sore experience with a similar issue :). Fortunately, quite incidentally I ran into that cookie limit information. Then I just reconsidered the structures in a cookie.
You're quite right that this mostly happens in large applications, however pay attention that not only the number of cookies are limited, but the size of an individual cookie is also limited to 4KB. So even if you have the room to save 200KB (4KB x 50 cookies = 200KB total info) you have to keep each cookie under 4KB. That's why this problem may happen in smaller environments as well.
But as the application grows, you will eventually run out of options, and perhaps you could consider saving states server side. I do that way now. It is particularly easy if you do it by JSON strings. Every time you leave a page construct the JSON state object, serialize it, and send to the server to keep it as a simple string. Every time you return to that page, query the server for the state JSON object, and restore the state. This way you can even restore the state even after reopening the page in a new browser window in a different session.
Never seen a doc addressing cookie standards concerning sizes. After all I think it is up to the browser developer :).
Hope I was able to help you.
Regards,
Nareg.
Joyfulbob
16 Jun 2008, 6:15 AM
[QUOTE=Nareg;181876] ...(1) Every time you leave a page construct the JSON state object,... ...(2) restore the state. QUOTE]
Thanks for the info and the great suggestion. We'll implement that. I understand what you said except for the two points quoted above. Could you elaborate or give an example or point me to the API Code Doc?
Thanks.
Nareg
16 Jun 2008, 10:15 PM
Well, JSON stands for JavaScript Object Notation, so that's the string representation of a javascript object. Basically it is a set of name:value pairs separated by comma. E.G.
if you have a Javascript object with property named "name" and the value is "Joyfulbob" :),
its JSON representation would be
{name:"Joyfulbob"}
If there're also other properties, they're separated by comma like:
{name:"Joyfulbob", date:"yesterday", replied:"Nareg"}.
If Your object has an array property it will go inside [] like:
{replies:["firtsreply", "secondreply", "thirdreply"]}
If You have an object property then the property value will be the JSON representation of that object (in other words JSON strings can be nested) like:
{name:"Joyfulbob", question:{title:"All was clear except...", body:"Some text goes here", date:"yesterday"}, reply:{title:"SOme other text goes here", body:"Some reply goes here"}}
Well this was a quick overview if you're not familiar with JSON.
Now consider your page, and write down all of your state properties which You'll need to later restore.
Construct a JSON object (note that I use object and string interchangeably for JSON - they're basically the same. But there's a difference - string is the string representation of the in-memory object.)
E.G.
var stateObject = new Object();
stateObject.property1 = value1;
.....
stateObject.propertyN = valueN;
// Construct the string representation
var JSONString = "{";
for(var property in stateObject){
JSONString += (property + ":\"" + stateObject[property] + "\", ");
// You might consider recursive function for this, if You have complex State object
// comprised of not only simple properties, but objects and arrays as well.
}
// here if JSONString is more than one character long, then we have an extra trailing
// comma+space. So get rid of 'em.
if(JSONString.length > 1){
JSONString = JSONString.substring(0, JSONString.length - 2);
}
// put the closing }
JSONString = JSONString + "}";
// Here you have your state in JSON string. Be aware of special characters like &, quote
// and double quote marks. Before sending this string to the server, be it via AJAX call or
// simple form submission, be sure to use the Javascript function escape(string), which
// replaces the special characters by their "safe representatives".
Here put a code to transmit the JSONString to the server.
Now, you could write a utility function performing the pattern I sampled above, and adopted to your needs, and reuse it. Call that function every time a page unloads.
2.
To restore the state follow this pattern:
when generating the page in JSP, JSF, or PHP whatever engine you use, get the JSON string. If you're using J2EE environment, you have JAR libraries "flexjson.jar" and "json.jar"
(please search the web to get them) that will automatize the JSON string parsing process. For other environments You might look for appropriate libraries.
Here you can just generate the javascript state variables before the page loads on the client side :). (I like this trick - basically you generate the javascript code).
After the page gets loaded on the client side it will have all the variables/values needed to restore the page state. Use them to bring the page to its desired state in a function called in the "onload" event handler of the <body> tag.
That's all.
Try it.
Regards,
Nareg.
Joyfulbob
25 Jun 2008, 5:14 AM
Thanks very much! I'll give that a go.
I was wondering, if I put
stateful: False on the grid, does that pertain to just the grid component itself, or does that include every element inside it; the fields, column sizes, column moves, hiding columns, etc. If so, then this would take care of our problem as only the grid and the bbar are not rendered correctly.
Thanks again!
Bob
Nareg
25 Jun 2008, 6:01 AM
I have not used that property, but according to the docs, it forces the grid internal state to be saved, meaning whatever internal property a grid might have, they will be saved.
Grid component by definition is a UI element to maintain and manage rows and columns, and the properties regarding to them should be saved. However, that won't apply to elements that are embedded in a grid cell.
If you decide to use this property You have to provide the Ext state manager with an implementation that will choose, store, and retrieve properties.
Refer to the help, there are useful code bits (for your case using cookies)
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
This actually does not define which parameters will be saved, rather, You define HOW to save. The parameters are passed by the component automatically.
You may define Your provider class which redefines the
set(propertyName, propertyValue);
get(propertyName);
methods.
E.G.
var MyStateProvider = new Object();
MyStateProvider.get = function(propName){
// here Your custom logic code retrieves the value of "propName" and returns it
// The implementation is up to You
}
MyStateProvider.set = function(propName, propVal){
// Store the property. Again the logic is up to You
}
Ext.state.Manager.setProvider(MyStateProvider);
There is also the class Ext.state.Provider with a very useful event 'statechange' which gets fired every time the state of a component changes. You might as well inherit Your custom state provider from this class.
Now, if You set 'stateful' to false, You'd loose this functionality.
Regards,
Nareg.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.