Sencha dynamically adding to component not work in build - javascript

Sencha Touch 2.2.1
Cmd 3.1.342
I have a sencha web app used to display data using Sencha Charts and carousel. The data is obtained via ajax. Components are created according to the amount of data that is received from the server.
Everything works fine in development. However, when I create a production build, the components are created, but not populated with the carousel and the app crashes. It seems that this happens when I try to add the carousel the carousel to the container using: Ext.getCmp(siteNamex+'Cont').add(thecarousel);
It then dies and console log says:
Uncaught TypeError: Cannot call method 'substring' of undefined
Ext.ClassManager.parseNamespace
Ext.ClassManager.get
Ext.ClassManager.instantiate
Ext.ClassManager.instantiateByAlias
Ext.apply.factory
Ext.define.factoryItem
Ext.define.add
Ext.Ajax.request.success
Ext.apply.callback
Ext.define.onComplete
Ext.define.onStateChange (anonymous function)
Here is the code which creates the container:
newcontainer = Ext.Container({
xtype : 'container',
flex: 1,
margin: '0',
id: siteNamex+'Cont',
itemId: siteNamex+'Cont',
height: '100%',
items: [],
cls:'siteContainer',
html: '<h2 class="siteName" style="'+snStyle+'">'+siteName+'</h2>'
});
This code seems to be working and creates the container as required.
Charts populate an array. The size depends on the data received via ajax:
var allcharts = new Array(); //initializing
Create gauge chart:
chartgx = Ext.chart.Chart({
xtype: 'chart',
renderTo: Ext.getBody(),
cls: 'thegauge',
itemId: 'gauge'+tt2,
store: gaugeStore,
width : 'auto',
background: 'white',
animate: true,
insetPadding: 50,
axes: [{
type: 'gauge',
position: 'gauge',
minimum: 0,
maximum: gaugemax,
steps: 10,
margin: 10
}],
series: [{
type: 'gauge',
field: 'CurrentValue',
donut: 30,
colorSet: ['#f6821f;', '#e0e2e4']
}]
});
Then I put this gauge in a container and add to array:
chartgx2 = Ext.Container({
xtype : 'container',
flex: 1,
layout: 'fit',
cls: 'gaugeContainer',
items: chartgx,
html: gaugeText
})
allcharts.push(chartgx2);
The carousel is then created using:
thecarousel = Ext.Carousel({
xtype: 'carousel',
width: '100%',
height: '100%',
itemId: 'thecarousel_'+siteName,
cls: 'chartscarousel',
id: siteNamex+'_carousel',
defaults: {
styleHtmlContent:true
},
items: allcharts
})
and is added to the container using Ext.getCmp(siteNamex+'Cont').add(thecarousel);
As I said earlier, this all works fine in development, but in the production build it throws up the error mentioned.
My app.js has the following:
requires: [
'Ext.field.Select',
'Ext.Ajax',
'Ext.Button',
'Ext.carousel.Indicator',
'Ext.carousel.Infinite',
'Ext.carousel.Item',
'Ext.carousel.Carousel',
'Ext.fx.easing.EaseOut',
'Ext.util.TranslatableGroup',
'Ext.chart.Chart',
'Ext.chart.axis.Gauge',
'Ext.chart.theme.*',
'Ext.util.Format',
'Ext.MessageBox',
'Ext.form.Panel',
'Ext.Panel',
'Ext.fx.Parser',
'Ext.Container',
'Ext.data.*',
'Ext.dataview.List',
'Ext.dataview.component.Container',
'Ext.chart.theme.Base',
'Ext.chart.theme.TitleStyle',
'Ext.chart.theme.GridStyle',
'Ext.chart.Toolbar',
'Ext.chart.legend.View',
'Ext.chart.Legend',
'Ext.chart.series.Bar',
'Ext.chart.series.Column',
'Ext.chart.series.Gauge',
'Ext.chart.series.Series',
'Ext.chart.axis.Numeric',
'Ext.chart.axis.Category',
'Ext.draw.Surface',
'Ext.draw.Draw',
'Ext.draw.Matrix',
'Ext.draw.engine.Canvas',
'Ext.draw.CompositeSprite',
'Ext.fx.Frame',
'Ext.draw.Sprite',
'Ext.fx.Sprite',
'Ext.Component',
'Ext.ComponentManager',
'Ext.ComponentQuery',
'Ext.TitleBar',
'Ext.draw.sprite.Sector',
'Ext.draw.sprite.Rect',
'Ext.chart.interactions.Abstract',
'Ext.chart.axis.Axis',
'Ext.util.SizeMonitor',
'Ext.chart.grid.HorizontalGrid',
'Ext.chart.grid.VerticalGrid'
],
When I run build command there are no errors.
Sencha Touch 2.2.1
Cmd 3.1.342
Update:
I rebuilt the gauge using this code exactly as it appears on the page. This did not resolve the problem

I would debug it like this:
Open your app in Chrome
Open dev tools
Go in "Sources" tab
Click two times on the pause symbol ("Pause on uncaught exceptions", bottom left arrow in the image bellow)
Do the thing that makes your application crash, or reload if it crashes on loading
The debugger will kick in just before throwing the exception you've noted
In the call stack, select the line Ext.ClassManager.instantiateByAlias (second arrow)
In the "Scope Variables" tab, you'll see the name of the culprit (circled bellow)
The variable name may be different because of the minification process, but you should be able to identify it easily. Optionally, you can disable compression in the file .sencha/app/production.properties to see the real code and make it easier.

Related

Extjs Toolbar crash, extjs 4.2.1, Chrome, Windows

Verry weird bug when developing a application. The toolbar dissapears whenever i add a button to it. The code is as follows:
Ext.create('Ext.toolbar.Toolbar', {
renderTo: document.body,
width : window,
height: window,
items: [
{
xtype : 'textfield',
name : 'field1',
emptyText: 'enter search term'
},
'-',
{
xtype : 'button'
// icon: 'img/cross_cursor.gif'}
}
]})
No errors encountered
Height and width point to window object. Give your toolbar an explicit width or no dimensions whatsoever. See https://fiddle.sencha.com/#fiddle/cfn

kendo ui grid batch editing, set focus

I working on a kendo ui grid. The grid is not-editable as default.
In the toolbar is a 'edit' button. When the user clicks on it, the grid should be editable in batch mode like this.
The only solution to get this work is remove and recreate the grid/datasource with new properties (editable:true etc).
This works as expected. Now I want to set the focus on the first row/cell, so that the user can see that the grid is editable now (in the example below the row becomes an input field).
Any suggestions for this?
Here is a fiddle for this.
$('.k-grid-edit').on('click', function (e) {
e.preventDefault();
// remove old grid
$('#grid').html('');
// recreate grid with edit: true and new datasource
$('#grid').kendoGrid({
dataSource: dataSourceInEdit,
editable: true,
columns: [{
field: 'TableId',
title: 'Id',
width: 50
}, {
field: 'Area',
title: 'Area'
}, {
field: 'Table',
title: 'Table',
width: 60
}, {
command: 'destroy',
title: ' ',
width: 100
}]
}).data("kendoGrid");
}); // end edit
Okay, I got it:
These 2 lines make it happen:
var grid = $("#rt_tableGrid").data("kendoGrid");
grid.editRow($("#rt_tableGrid tr:eq(1)"));
Certainly only on my local script, in the Fiddle I cant´t get it to work.
Although in the Docu is written: Requires "inline" or "popup"
Documentation here

extjs displaying loadmask on panel when store loads

I added a loadmask to a panel and I want the spinner to be displayed each time stores associated with the loadmask are loaded. The panel is a large tooltip and the stores are loaded each time a point is visited in a line chart. Thus, when I hover over a point, I'm expecting a load message to appear for a short period of time before I see the contents in the panel. What I'm getting is an empty panel however. If I remove the code that I have which adds the load mask (the initComponent function), it works (without the load message though). How would I use the loadmask in this manner as opposed to explicitly calling the setLoading() method for each panel?
Here's the code:
tips:
{
...
items:{
xtype: 'panel',
initComponent: function(){
var loadMask = new Ext.LoadMask(this, {
store: Ext.getStore('CompanyContext')
});
},
id: 'bar-tip-panel',
width: 700,
height: 700,
layout: {
type: 'accordion',
align : 'stretch',
padding: '5 5 5 5'
},
items:...
}
}
config object isn't the proper place to override initComponent method. What you should do is to define a subclass of Panel, and override the method there.
Ext.define('MyPanel', {
extend: 'Ext.panel.Panel',
xtype: 'mypanel',
initComponent: function() {
this.callParent(arguments); // MUST call parent's method
var loadMask = new Ext.LoadMask(this, {
store: ...
});
},
});
Then, you can use xtype mypanel in your tips configuration.

Set layout on Sencha touch 2

I try to setLayout when the orientation was changed , but I get this type of error :
*Console.js:17Uncaught Error: [ERROR][Ext.Container#setLayout] Replacing a layout after one has already been initialized is not currently supported.*
and I cannot get, what is going on here. Here is my code :
onOrientationChange:function(viewport, orientation){
viewport.setLayout('vbox');
}
where the viewport is :
Ext.define("Q4.view.blg", {
extend: 'Ext.Container',
xtype: 'blg',
config:{
title:"blg",
iconCls:'star',
cls:'blogList',
disableSelection: true,
layout: 'hbox',
defaults:{
scrollable:false
},........
Thanks !!!!!!

Sencha Touch 2 - TabPanel does not work in MVC designed App

simple question for you today...
This works:
var carousel = Ext.create('Ext.Carousel', {
fullscreen: 'true',
//load in views view clean instantiation using
// the widget.alias's defined in each view... yea
// For some reason, putting flex on these components... oh...
// Have to call directly in by just the xtype since these are just
// references..
items: [
{
xtype: 'Main'
},
{
xtype: 'CommentList'
}
]
This does NOT work:
var tabpanel = Ext.create('Ext.TabPanel', {
fullscreen: 'true',
tabBarPosition: 'bottom',
defaults: {
styleHtmlContent: true
},
//load in views view clean instantiation using
// the widget.alias's defined in each view... yea
// For some reason, putting flex on these components... oh...
// Have to call directly in by just the xtype since these are just
// references..
items: [
{
xtype: 'Main',
title: 'The Main',
iconCls: 'user'
},
{
xtype: 'CommentList',
title: 'Comments',
iconCls: 'user'
}
]
});
As you can see, they are pretty much the same except one is a TapPanel (with the required default configs added) and the other is a carousel.
Everything else is exactly the same.... This is in the app.js of my Sencha Touch 2.0 app designed following the MVC architecture.
The result of the not-working TabPanel is that I only see the first view (Main) and no tab-bar appears in the bottom of the screen.
Any ideas what my problem might be?
I am not sure if this is an issue but in my code the line is:
Ext.create("Ext.tab.Panel", {
Not:
Ext.create('Ext.TabPanel', {
Fullscreen should be fullscreen: true instead of fullscreen: 'true'. You could also add this code to make them switch:
cardSwitchAnimation: {type: "fade", duration: 1000},
layout: "card",
Didn't test it, but it worked for me (got it from a snippet of my own code)

Categories