sencha app build producing duplicate components - extjs

I have finished an application and I am in the process of minification. When I build the application I am getting duplicate components rendered. I noticed this when I was testing the application. Whenever I have a grid, there is another one getting painted under it with the same exact attributes. I used Ext.ComponentMgr.all.map to see all my application's components- when I did this I noticed that the un-built version had 1 app-main components and the minified had 2. At first I thought I could attribute this to warnings or errors in the un-built version. But when I run it in chrome/IE, I am not seeing any console warnings or errors.
Is there any way to tell what is causing this error? Below is my main view that gets invoked in the Viewport.js file. each of those views have their respective aliases defined properly.
Ext.define('MPL.view.MPLView', {
extend: 'Ext.container.Container',
requires: [
'Ext.grid.Panel',
'MPL.view.QuotePanelView',
'MPL.view.SearchPanelView',
'MPL.view.PartsPanelView',
'MPL.view.SvcPartsPanelView',
'MPL.view.ConsumedPartsView'
],
xtype: 'app-main',
layout: 'column',
overflowY: 'auto',
items: [
{
xtype: 'SearchPanel',
columnWidth: 1
},
{
xtype: 'QuoteGrid',
columnWidth: 1,
overflowY: 'auto',
height: 200
},
{
xtype: 'PartGrid',
overflowY: 'auto',
columnWidth: 1,
height: 250,
margin: '20 0 0 0',
hidden: true
},
{
xtype: 'SvcPartsGrid',
overflowY: 'auto',
columnWidth: 1,
height: 250,
margin: '20 0 0 0',
hidden: true
},
{
xtype: 'ConsumedPartsGrid',
overflowY: 'auto',
columnWidth: 1,
height: 250,
margin: '20 0 0 0'
}
],
listeners: {
.....
}});
This is what my app.js looks like:
Ext.Loader.setConfig({
enabled : true
});
Ext.application({
name : 'MPL',
extend : 'MPL.Application',
appFolder : 'app',
requires : [ 'overrides.Theme' ],
controllers : [ 'MPLController' ],
models : [
'MPLModel',
'SearchCriteriaModel',
'PartsModel',
'LaborCodeModel',
'PartFieldsModel',
'SourceModel',
'PartsActionModel',
'ConsumedPartsModel'
],
stores : [
'MPLStores',
'SearchCriteriaStore',
'PartsStore',
'LaborCodeStore',
'PartFieldsStore',
'SourceStore',
'PartsActionStore',
'ConsumedPartsStore'
],
autoCreateViewport : true
});
I have placed console.logs and made beforerender listeners on the grids that get duplicated. Again, in the minified version I see two logs in the console and in the un-minified, I only see one.
Still battling this - here is an example of one of the grids that gets duplicated
Ext.define('MPL.view.QuotePanelView', {
alias: 'widget.QuoteGrid',
extend: 'Ext.grid.Panel',
id: 'QuotePanel',
store: 'MPLStores',
columns: [
{ header: MPL.str.getQuoteIdHeader(), dataIndex: 'quoteId', flex: .9},
{ header: MPL.str.getManufacturerHeader(), dataIndex: 'manufacturer', flex: 1.2},
{ header: MPL.str.getVinHeader(), dataIndex: 'vin', flex: 2},
{ header: MPL.str.getYearHeader(), dataIndex: 'year', flex:.8},
{ header: MPL.str.getMakeHeader(), dataIndex: 'make', flex: 1},
{ header: MPL.str.getModelHeader(), dataIndex: 'model', flex: 1},
{ header: MPL.str.getSalesIdHeader(), dataIndex: 'salesPersonId', flex: 1.23},
{ header: MPL.str.getCustIdHeader(), dataIndex: 'customerId', flex: 1},
{ header: MPL.str.getQuoteStatusHeader(), dataIndex: 'status', flex: 1},
{ header: MPL.str.getCreatedDateHeader(), dataIndex: 'createdOn', dateFormat: "Y-m-d", flex: 2}
],
listeners: {
itemclick: function(dv, record, item, index, e) {
MPL.app.fireEvent("FindParts", dv, record, item, index, e);
},
beforerender: function(component, eOpts){
console.log(' id - ' + component.getId());
}
}
});

I hacked my way through this problem. I handled it in the beforerender function of each of the duplicate components. Since I noticed that the renderer was rendering the same exact item, I took the liberty of deleting it and everything that was attached to the previous version.
beforerender: function(component, eOpts){
if(!alreadyRendered){
alreadyRendered = true;
previousComponent = component;
}
else{
previousComponent.removeAll(true);
}
}

Related

extjs nested data not displaying in databind grid

How do I databind my extjs6 grid to include "commission" using the following format I created from webapi ef?
grid columns should look like this.
title: 'Commissions',
xtype: 'grid',
bind: {
store: '{myAccountDetails.commission}'
},
ui: 'featuredpanel-framed',
cls: 'custom-grid',
margin: '0 0 0 0',
itemId: 'gridCommId',
collapsible: true,
columns: [
{
header: 'USD',
dataIndex: 'usd',
flex: 1
},
{
header: 'AUD',
dataIndex: 'aud',
flex: 1
},
{
header: 'CAD',
dataIndex: 'cad',
flex: 1
}
This is my view of grid
the screenshot I attached is myAccountDetails
any help would be greatly appreciated!
just a sidenote... if I add a label I am able to return the info I am looking for but I want it to be inside a grid.
xtype: 'label',
cls: 'myLabelCRM2',
bind: {
text: '{myAccountDetails.commission.aud}'
}
Best approach is to define a store in viewmodel, and bind it's data field directly to the details commision field using the mustache syntax.
Ext.define('MyView', {
viewModel: {
data: {
myAccountDetails: {
accountName: 'foo',
commision: {
aud: 7,
cad: 8,
usd: 9
}
}
},
stores: {
commisionStore: {
fields: ['aud', 'cad', 'usd'],
data: '{myAccountDetails.commision}'
}
}
},
extend: 'Ext.grid.Panel',
xtype: 'MyView',
bind: {
store: '{commisionStore}'
},
columns: [{
header: 'USD',
dataIndex: 'usd',
flex: 1
}, {
header: 'AUD',
dataIndex: 'aud',
flex: 1
}, {
header: 'CAD',
dataIndex: 'cad',
flex: 1
}]
});
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create({
xtype: 'MyView',
width: 300,
height: 300,
renderTo: Ext.getBody()
});
}
});

Panel leaving white space when Scrollbar appears

I'm building an application using Ext.js, and I built a grid panel, and I'm loading data every 14 seconds. When the scrollbar appears on the panel, it appears an white space that I'm trying to remove but I don't know how, I already tried to overwrite the ID that contains the timeline and change the color, but it didn't work because Ext.js generated the CSS code again and every changes disappeared.
Demo
Is it possible to hide this white space?
My code:
Ext.define('ES.view.Layout.Menu.Menu', {
extend: 'Ext.grid.Panel',
alias: 'widget.timelineBar',
controller: 'menu',
viewModel: 'menu',
autoScroll: true,
title: 'Timeline',
bodyStyle: 'background: #2b5876;',
store: {
type: 'timeline'
},
columns: {
border: false,
defaults: {
hoverCls: ''
},
items: [{
text: locale.time,
flex: 1,
dataIndex: 'time',
align: 'center',
height: 60
},
{
text: locale.address,
dataIndex: 'address',
flex: 1,
align: 'center',
height: 60
listeners: {
click: 'onItemClick'
},
},
{
text: locale.dir,
dataIndex: 'dir',
flex: 1,
align: 'right',
height: 60
}
]
}
});

Aligning a text on an extjs label

I am new to extjs.I am designing a pop up window which basically populates some data from the server.I have used the layout as 'fit' and I am using labels for displaying the data.Here is my code
win = new Ext.window.Window({
title: 'Data point details',
layout: 'fit',
width: 'auto',
height: 500,
modal: false,
closeAction: 'destroy',
layout: {
type: 'table',
// The total column count must be specified here
columns: 2,
rows :10 ,
tdAttrs:
{
style:
{
margin: '160px',
valign: 'top' ,
padding: '8px' ,
'font-size' : '12px'
}
}
},
defaults: {
bodyPadding: 10 ,
},
items: [
{
xtype: 'label',
text: 'Element : ' ,
style:
{
'font-weight':'bold',
'labelAlign' : 'right',
}
},
{
xtype: 'label',
text: elementname
},
{
xtype: 'label',
text: 'Expression: ' ,
style:
{
'font-weight':'bold',
}
},
{
xtype: 'label',
text: s.expressionName
},
{
xtype: 'label',
text: 'Profile: ' ,
style:
{
'font-weight':'bold',
}
},
{
xtype: 'label',
text: s.profileName
},
{
xtype: 'label',
text: 'Time:',
style:
{
'font-weight':'bold',
}
},
{
xtype: 'label',
text: Highcharts.dateFormat('%a, %b %e, %Y, %I:%M %p ', this.x)
},
{
xtype: 'label',
text: 'Value:',
style:
{
'font-weight':'bold',
}
},
{
xtype: 'label',
text: yvalue ,
},
{
xtype: 'box',
style : {
padding: '0px',
height: '90px',
//background : 'white',
},
html: new Ext.XTemplate("<div style=\"height:150px;\">{value}")
.apply({value: me.htmldiv.innerHTML })
},
]
});
win.show();
I want the columns which appear on the left hand side to have their text on the right,but the text is always towards the left for all the cells it seems .Likw for example the label which has the text 'Element' appears to be on the left.I have used labelalign but it does not work.Kindly give suggestions
Just few suggestions until i get to the solution:
You have reduntant comas all over the place. Some older browsers will fail on such thing. Example:
{ 'font-weight':'bold',<<-- here }
win = new Ext.window.Window(... - this is global variable declaration - probably worst thing you can do in JavaScript and way to hell. Use var keyword to declare local variables like so: var win = new Ext.window.Window(...
labelAlign is the way to align label text to the right BUT a) you are applying it through style property (styles which Ext apply to HTML element created by component) and b) labelAlign is property of Labelable components and as strange as it might sound, Label itself is not Labelable. Just don't use Label like this, see below...
Duplicate layout property on Window
When you are asking for help and posting code as part of the question, edit your code so that it doesn't contain exteral dependencies - can be copied and run immediately. It took me nearly half a hour to make your sample working
As i said before, you are using Lable component in the way it is not suppose to be used. Labels are not created directly but by specifying label properties on components implementing Labelable mixin (Fields in most cases). It might sound complicated but is not, take a look at the code:
var wnd = new Ext.window.Window({
title: 'Data point details',
width: 400,
height: 200,
modal: false,
closeAction: 'destroy',
layout: {
type: 'anchor',
align: 'stretch'
},
bodyPadding: 10,
defaults: {
labelAlign: 'right',
labelStyle: {
'font-weight': 'bold'
},
labelWidth: 100
},
items: [{
xtype: 'displayfield',
fieldLabel: 'Element',
value: 'elementname'
}, {
xtype: 'displayfield',
fieldLabel: 'Expression',
value: 's.expressionName' // s.expressionName
}, {
xtype: 'displayfield',
fieldLabel: 'Profile',
value: 's.profileName' // s.profileName
}, {
xtype: 'displayfield',
fieldLabel: 'Time',
value: 'time'
}, {
xtype: 'displayfield',
fieldLabel: 'Value',
value: 'yvalue' // yvalue
}]
});
wnd.show();
You can try it and play with it here. My final suggestion would be to take a look at the official ExtJS documentation and guides which are pretty good - here for example are samples on making forms...
Here is an approach to use css styles inline, not in a separate class. This could be useful if you get css values from your javascript constants:
this.myLabel = Ext.create('Ext.form.Label', {
text: 'My Label Name',
style: {
'text-align': this.defaults.myLabelAlign, // The javascript constant.
'font-size': this.defaults.myLabelStyle // The javascript constant.
}
});

Proper way to extend Ext.panel.Panel?

I am creating a GUI for a webpage using Ext JS 4.1.1. I have tried to create a component ('GeneSearchComponent' below) which I can use in a more complicated layouts. But for some reason I cannot insert an instance of 'GeneSearchComponent' into hpanel. What am I missing in extending the pre-defined 'Ext.panel.Panel' class (and in creating a "widget" of my own)?
If I remove the call to "Ext.create('gene-search-component', ...", everything works; if I put it back in, everything breaks. I wonder why.
(I have not included the definition of 'gene-combobox'. I am pretty convinced that it's not the root cause of my problem.)
Thanks for your time!
Tuomas
Ext.define('GeneSearchComponent', {
extend: 'Ext.panel.Panel',
alias: ['gene-search-component'],
constructor: function(cnfg) {
this.callParent(arguments);
this.initConfig(cnfg);
},
config: {
collapsible: true,
frame: true,
title: 'Search',
bodyPadding: '15 15 15 15',
width: 350,
layout: {
type: 'vbox',
align: 'left'
},
items: [
Ext.widget('gene-combobox', {
id: 'comboboxid'
}),
Ext.create('Ext.Button', {
text: 'Search',
handler: function() {
dosomething();
}})]
},
onRender: function() {
this.callParent(arguments);
}
});
Ext.application({
name: 'FW',
launch: function() {
var bd = Ext.getBody();
var div = Ext.get("search_form");
var hpanel = Ext.create('Ext.panel.Panel', {
id: 'horizontal-panel',
title: "HBoxLayout Panel",
layout: {
type: 'hbox',
align: 'middle'
},
items: [
Ext.create('Ext.container.Container', {
id: 'another-panel',
title: "VBoxLayout Panel",
width: 250,
layout: {
type: 'vbox',
align: 'left'
},
items: [{
xtype: 'panel',
width: 250,
title: ' Panel One',
flex: 2
},{
xtype: 'panel',
width: 250,
title: ' Panel Two',
flex: 1
},{
xtype: 'panel',
width: 250,
title: ' Panel Three',
flex: 1
}]}),
Ext.create('gene-search-component', {
id: 'searchPanel',
})],
renderTo: div,
});
}
});
The problem is that you have not given the gene-search-component the widget namespace when configuring its alias.
alias: 'widget.gene-search-component'
Also to echo the comments on your OP you are doing a lot of unnecessary typing creating components in the way that you are. You should make use of the xtype field rather than using Ext.Create everywhere. I've modified your code to show you how much simpler it could be.
http://jsfiddle.net/hzXx8/

using Panel instead of viewport in extjs

I would like to add a grid to my existing website. I understand that "viewport" takes up the whole page. As i just want part of the page i should "panel".
I've followed this example to setup my grid in a clean mvc style.
http://docs.sencha.com/ext-js/4-0/#/guide/application_architecture
However this example uses "viewport".
launch: function () {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [
{
xtype: 'tasklist',
title: 'Tasks',
html: 'List of tasks will go here'
}
]
});
}
I've changed this to the following.
launch: function () {
Ext.create('Ext.grid.Panel', {
layout: 'fit',
renderTo: 'panelcontainer', // i've added div to html
width: 1000,
height: 600,
items: [
{
xtype: 'tasklist',
title: 'Tasks',
html: 'List of tasks will go here'
}
]
});
}
here is my tasklist
Ext.define('AM.view.task.List', {
extend: 'Ext.grid.Panel',
alias: 'widget.tasklist',
store: 'Tasks',
title: 'All Tasks',
initComponent: function () {
this.columns = [
{ header: 'Name', dataIndex: 'Name', flex: 1 },
{ header: 'ReferenceNumber', dataIndex: 'ReferenceNumber', flex: 1 },
{ header: 'ProductList', dataIndex: 'ProductList', flex: 1 },
{ header: 'Supplier', dataIndex: 'Supplier', flex: 1 },
{ header: 'ModifiedByUserName', dataIndex: 'ModifiedByUserName', flex: 1 },
{ header: 'Date', dataIndex: 'Date', flex: 1, type: 'date', dateFormat: 'Y-m-d' },
{ header: 'Id', dataIndex: 'Id', flex: 1 }
];
this.callParent(arguments);
}
});
This all works. if i use viewport
Change 'Ext.grid.Panel' to 'Ext.panel.Panel' (in launch and tasklist snippets) and it will work as you expect it to.

Resources