I have the following override in myPackage\overrides\window\Window:
Ext.define('myPackage.window.Window', {
override: 'Ext.window.Window',
listeners: {
beforeshow: function (window) {
console.log('before show');
}
}
});
I then use this with this code:
Ext.define('myApp.view.login.Login', {
extend: 'Ext.window.Window',
xtype: 'login',
requires: [
'myApp.view.login.LoginController',
'Ext.form.Panel'
],
controller: 'login',
title: 'Login',
closable: false,
autoShow: true,
resizable: false,
listeners: {
show: function() {
console.log('in show');
}
},
items: {
... snipped for brevity; a couple of textfields and a button
...
}
});
The problem is that while the 'show' event in 'myApp.view.login.Login' works fine, the 'beforeshow' event in the override ('myPackage.window.Window') never fires.
If I then remove the listeners from 'myApp.view.login.Login', then the 'beforeshow' event in 'myPackage.window.Window' will then fire (I can see all this with the console.log output).
What I don't understand is, why? I am probably missing something fairly simple.
Any help with this is greatly appreciated. Thanks!
you should add the listener after you window is initialized.
I haven't tested it yet. but I am sure it should solve your issue.
eg:
Ext.define('myApp.view.login.Login', {
extend: 'Ext.window.Window',
xtype: 'login',
requires: [
'Ext.form.Panel'
],
title: 'Login',
width: 300,
height: 300,
closable: true,
autoShow: true,
resizable: false,
initComponent: function () {
var me = this;
Ext.apply(me, {
listeners: {
show: function () {
console.log('in show');
}
},
items: [
{
xtype: 'textfield',
width: 300
}
]
});
me.callParent(arguments);
}
});
Related
Have this code
Ext.define('C.YmkDetPanel', {
extend: 'Ext.Panel',
xtype: 'YmkDetPanel',
conttroller: 'ccc',
viewModel: {
type: 'ymkDetModel'
},
bind: {
html: '<div> {zzz} </div> <div id = "button"> </div>'
},
listeners: {
painted: function ( ) {
new Ext.Button({
renderTo: 'button',
scope: this,
text: 'Click Me',
listeners:
{
tap: function() {
alert(this.up());
}
}
});
}
},
initComponent: function() {
this.callParent(arguments);
}
});
I see created button.
But on click this.up() is null. THIS is the button.
How to access to C.YmkDetPanel from button? in Painted event THIS is "Ext.dom.Element"
Use a container and nest the 2 items separately, fiddle:
Ext.define('C.YmkDetPanel', {
extend: 'Ext.Panel',
xtype: 'YmkDetPanel',
viewModel: {
data: {
zzz: 'foo'
}
},
items: [{
xtype: 'component',
bind: '{zzz}'
}, {
xtype: 'button',
text: 'Click me'
}]
});
Ext.application({
name : 'Fiddle',
launch : function() {
Ext.Viewport.add({
xtype: 'YmkDetPanel'
});
}
});
Hi i'm new to Sencha and i'm try to set json request data to filedset. But it does not work. Please help me i cannot find the error.
this is my json request data:
{"response":{"electric_current":103.7506250769956,"electric_power":120.62350489414762}}
And this is the code.
Ext.define('AIOS_vis.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'main',
requires: [
'Ext.TitleBar'
],
config: {
listeners: {
activate: function() {
alert('gr');
Ext.data.JsonP.request({
url: 'http://localhost:8080/mock/GetCtPwer.php',
method: 'POST'
callbackkey: 'callback',
params: {
tap_id: 1
},
scope: this, /// fix handler scope
callback: function (response, value, request) {
var wattComponent = Ext.getCmp('watt');
wattComponent.setValue(value.response.electric_power);
var ampereComponent = Ext.getCmp('ampere');
ampereComponent.setValue(value.response.electric_current);
},
failure: function (response, request) {
Ext.Msg.alert(response);
}
});
}
},
tabBarPosition: 'bottom',
items: [
{
title: 'Home',
iconCls: 'home',
styleHtmlContent: true,
scrollable: true,
items: [
{
docked: 'top',
xtype: 'titlebar',
title: 'Visual',
},
{
xtype: 'fieldset',
instructions: 'Last Update: 2014/02/06:12:45:23',
items: [
{
xtype: 'button',
text : 'current',
height: '40px',
},
{
xtype: 'textfield',
id: 'watt',
label: 'Wattage (W):',
text: '1890.9W'
}, {
xtype: 'textfield',
id: 'ampere',
label: 'Amperage (A):',
text: '18.91A'
}]
},
{
xtype :'titlebar',
style: 'background:#484848',
title : 'power</br>123.4Wh',
height: '100px'
}
]}
]
},
});
Change your webservice url to (for example) http://yoururl.com:8080/mock/GetCtPwer.php?jsonp=parseResponse
and make sure your webserice is responding this:
parseResponse({"response":{"electric_current":103.7506250769956,"electric_power":120.62350489414762}})
you can change "parseResponse" to whatever you want.
I modified the code like this and I added some items, because I'd like to get a div with scroll, but it does not work in Sencha!
Any suggest?
Thanks in advance!
Code:
/*global Ext:false */
Ext.application({
launch: function () {
Ext.create('Ext.Container', {
fullscreen: true,
styleHtmlContent: true,
data: [{
fname: 'Stratton',
lname: 'Sclavos',
role: 'Executive Chairman'
},
etc. ],
tpl: '<div style="overflow: auto; overflow-y: auto;"><tpl for="."><div><strong>{lname}</strong>, {fname} <em class="muted">({role})</em></div></tpl></div>'
}); // create()
} // launch
}); // application()
Add:
scrollable : {
direction : 'vertical'
},
Like this:
/*global Ext:false */
Ext.application({
launch: function () {
Ext.create('Ext.Container', {
fullscreen: true,
styleHtmlContent: true,
scrollable : {
direction : 'vertical'
},
data: [{
fname: 'Stratton',
lname: 'Sclavos',
role: 'Executive Chairman'
},
etc. ],
tpl: '<div style="overflow: auto; overflow-y: auto;"><tpl for="."><div><strong>{lname}</strong>, {fname} <em class="muted">({role})</em></div></tpl></div>'
}); // create()
} // launch
}); // application()
I am trying to draw a circle using Sencha's Ext.draw.Component in my customized view class but it is not showing any circle in it. I have pasted the code for reference.
I also tried to define the variable of type component in my Main class but upon doing so the compiler gave an error saying that the type component is unknown.
// Main Class
Ext.define('GS0.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'main',
requires: [
'Ext.TitleBar',
'Ext.Video',
'Ext.Carousel',
'Ext.Container',
'Ext.draw.Component',
'Ext.Img'
],
config: {
tabBarPosition: 'bottom',
items: [
{
iconCls: 'home',
xtype: 'carousel',
ui : 'dark',
direction: 'horizontal',
items: [
{
xtype: 'draw',
type: 'circle',
radius: 50,
x: 100,
y: 100,
fill: '#2d2d2d'
},
{
xtype: 'img',
src: 'images/nm.jpg'
}
]
}
]
}
});
// Circle Class
Ext.define('GS0.view.CC', {
extend: 'Ext.draw.Component',
xtype: 'cc',
config: {
type: 'circle',
cx: 100,
cy: 100,
r: 25,
fillStyle: 'blue'
}
});
Try modifying you items in the GSO.view.Main
items: [{
iconCls: 'home',
xtype: 'carousel',
ui : 'dark',
direction: 'horizontal',
items: [{
xtype: 'draw',
items:[{
type: 'circle',
fill: '#79BB3F',
radius: 100,
x: 100,
y: 100
}]
},{
xtype: 'img',
src: 'images/nm.jpg'
}]
}]
The circle code should be added as an item to the xtype=draw block.
I think the way I am loading the Main is a problem. here is the code. Can you spot any error. PS please see line Ext.viewport.add(Ext.create(GS0.view.main))
Ext.Loader.setPath({
'Ext': 'touch/src',
'GS0': 'app'
});
//</debug>
Ext.application({
name: 'GS0',
requires: [
'Ext.MessageBox'
],
views: [
'Main'
],
icon: {
'57': 'resources/icons/Icon.png',
'72': 'resources/icons/Icon~ipad.png',
'114': 'resources/icons/Icon#2x.png',
'144': 'resources/icons/Icon~ipad#2x.png'
},
isIconPrecomposed: true,
startupImage: {
'320x460': 'resources/startup/320x460.jpg',
'640x920': 'resources/startup/640x920.png',
'768x1004': 'resources/startup/768x1004.png',
'748x1024': 'resources/startup/748x1024.png',
'1536x2008': 'resources/startup/1536x2008.png',
'1496x2048': 'resources/startup/1496x2048.png'
},
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
// Initialize the main view
Ext.Viewport.add(Ext.create('GS0.view.Main'));
},
onUpdated: function() {
Ext.Msg.confirm(
"Application Update",
"This application has just successfully been updated to the latest version. Reload now?",
function(buttonId) {
if (buttonId === 'yes') {
window.location.reload();
}
}
);
}
});
I've got a grid getting data through a json store. I want to display the total number of rows in the grid. The problem is that the store.count() function is running before the store loads so it is returning 0. How can I get my count function to run only once the store has loaded? I'm working in MVC, here is my app.js which has my counting logic in it.
Thank you for any help
Ext.application({
name: 'AM',
appFolder: 'app',
controllers: [
'Users'
],
launch: function(){
Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
Ext.create('Ext.container.Viewport', {
resizable: 'true',
forceFit: 'true',
layout: 'fit',
items:[{
xtype: 'userpanel',
}]
});
var port = Ext.ComponentQuery.query('viewport')[0],
panel = port.down('userpanel'),
grid = panel.down('userlist'),
label = panel.down('label');
var count = grid.store.getCount();
var labelText = "Number of people in list: " + count;
label.setText(labelText);
}
});
store code:
Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',
autoLoad: true,
autoSync: true,
purgePageCount: 0,
proxy: {
type: 'rest',
url: 'json.php',
reader: {
type: 'json',
root: 'queue',
successProperty: 'success'
}
},
sortOnLoad: true,
//autoLoad: true,
sorters: [
{
property: 'PreReq',
direction: 'DESC'
},
{
property: 'Major1',
direction: 'ASC'
},
{
property: 'UnitsCompleted',
direction: 'DESC'
}
],
listeners:{
onload: function(){
var port = button.up('viewport'),
grid = port.down('userlist'),
panel = port.down('userpanel'),
label = panel.down('label'),
count = grid.store.getCount(),
labelText = "Number of people in list: " + count;
label.setText(labelText);
},
scope: this
}
});
grid code:
Ext.define('AM.view.user.List' , {
extend: 'Ext.grid.Panel',
alias: 'widget.userlist',
store: 'Users',
height: 'auto',
width: 'auto',
//resizable: 'true',
features:[{
ftype: 'grouping'
}],
autoFill: 'true',
layout: 'fit',
autoScroll: 'true',
initComponent: function() {
function renderTip(value, metaData, record, rowIdx, colIdx, store) {
metaData.tdAttr = 'data-qtip="' + value + '"';
return value;
};
var dateRender = Ext.util.Format.dateRenderer('m/d/Y');
this.columns=[
//code for all my columns
]
];
this.callParent(arguments);
}
});
Try putting a listener on the store then listen for the onload event get the count and update the field that way. Though there are many ways to do this that is just one.
But in the example above you never load the store you just create it, which is why you see zero.
figured it out, needed to add a listener for the "load" event, not "onLoad". Code below...
Ext.define('APP.store.Store', {
extend: 'Ext.data.Store',
model: 'APP.model.Model',
autoLoad: true,
autoSync: true,
purgePageCount: 0,
proxy: {
type: 'rest',
url: 'json.php',
reader: {
type: 'json',
root: 'users',
successProperty: 'success'
}
},
sortOnLoad:true,
sorters: [{
property: 'last',
direction: 'ASC'
}],
listeners: {
load:{
fn:function(){
var label = Ext.ComponentQuery.query('#countlabel')[0];
label.setText(this.count()+ ' Total Participants);
}
}
}
});