As a "target" handler toolbar button, the method of the controller? - extjs-mvc

Hello!
I want this handler "handler: onEventControler (???)" removed from view (it do not belong there)
For grid view set dockedItems this cod:
this.dockedItems = [{
xtype: 'toolbar',
items: [{
xtype: 'newstation'
},{
id: 'add-persone-btn',
xtype: 'button',
itemId: 'add',
text: 'Add',
iconCls: 'icon-add',
handler: onEventControler(???)
}, '-', {
itemId: 'delete',
text: 'Delete',
iconCls: 'icon-delete',
disabled: true,
handler: function(){
var selection = grid.getView().getSelectionModel().getSelection()[0];
if (selection) {
store.remove(selection);
}
}
}]
}]
I also tried to implement a this.control, but I could not ask for a button selectorQuery.
How do I properly respecting the architecture mvc extJs4?
thank you.

You should be able to do something like this inside the controller of this view.
init: function () {
this.control({
'toolbar #add': {
click: this.onAddStation
}
});
}
Handler:
onAddStation: function(button, e, eOpts){
//Handle
}
Alternatively, you could use an "action" config on your button.
action: 'addstation'
Then you could have:
init: function () {
this.control({
'button[action=addstation]': {
click: me.onAddStation
}
});
}
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.button.Button

This is method "initComponent" for view gridd view:
initComponent: function () {
this.plugins = [Ext.create('Ext.grid.plugin.RowEditing')];
this.dockedItems = [{
xtype: 'toolbar',
items: [{
xtype: 'button',
itemId: 'add',
text: 'Add',
iconCls: 'icon-add',
action: 'add-new-persone'
}, '-', {
itemId: 'delete',
text: 'Delete',
iconCls: 'icon-delete',
action: 'delete-persone',
disabled: true
}, '-', {
itemId: 'synch',
text: 'Synchronization',
iconCls: 'icon-synch',
action: 'synch-persone'
}]
}];
// paging bar on the bottom
this.bbar = Ext.create('Ext.PagingToolbar', {
store: this.store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display",
items:[]
});
this._initColumns();
this._initFilter();
this.callParent(arguments);
},

Related

get svg code in highchart directive with angular js

in normal highchart i get svg code with code like this
var chart = $('#container').highcharts()
svg = chart.getSVG();
So, how can i get svg code with this highchart directive in angular js???
i try like normal code but i didn't get svg code.
i use this directive for my highchart
https://github.com/rootux/angular-highcharts-directive
and this my code in controller.js
$scope.chartLogisticGIGR = {
options: {
tooltip: {
shared: true
}
},
xAxis: { // Primary xAxis
categories: $scope.nameMonths,
title: {
text: 'Month'
},
labels: {
enabled: true
},
min:0
},
yAxis: [{ // Primary yAxis
title: {
text: 'GI / GR in IDR'
},
labels: {
formatter: function () {
return Highcharts.numberFormat(this.value / 1000000,'0') + ' mil';
}
}
}, { // Secondary yAxis
title: {
text: 'Balance'
},
labels: {
formatter: function () {
return Highcharts.numberFormat(this.value / 1000000,'0') + ' mil';
}
},
}],
series: [{
name: 'AGP - Goods Receipt',
type: 'column',
stacking: 'normal',
stack: '1',
data: $scope.dataLogisticGIGR_AGP_GR,
color: $rootScope.getColor('AGP Ext'),
tooltip: {
pointFormat: '<span style="color:{series.color}">{series.name}: {point.y:,.0f}</span><br/>'
}
},{
name: 'AGP - Goods Issue',
type: 'column',
stacking: 'normal',
stack: '1',
data: $scope.dataLogisticGIGR_AGP_GI,
color: $rootScope.getColor('AGP Int'),
tooltip: {
pointFormat: '<span style="color:{series.color}">{series.name}: {point.y:,.0f}</span><br/>'
}
},{
name: 'AGP - Balance',
type: 'spline',
data: $scope.dataLogisticGIGR_AGP_Balance,
color: $rootScope.getColor('AI 2'),
tooltip: {
pointFormat: '<span style="color:{series.color}">{series.name}: {point.y:,.0f}</span><br/>'
}
},{
name: 'AI - Goods Receipt',
type: 'column',
stacking: 'normal',
stack: '3',
data: $scope.dataLogisticGIGR_AI_GR,
color: $rootScope.getColor('AI'),
tooltip: {
pointFormat: '<span style="color:{series.color}">{series.name}: {point.y:,.0f}</span><br/>'
}
},{
name: 'AI - Goods Issue',
type: 'column',
stacking: 'normal',
stack: '3',
data: $scope.dataLogisticGIGR_AI_GI,
color: $rootScope.getColor('AP 2'),
tooltip: {
pointFormat: '<span style="color:{series.color}">{series.name}: {point.y:,.0f}</span><br/>'
}
},{
name: 'AI - Balance',
type: 'spline',
data: $scope.dataLogisticGIGR_AI_Balance,
color: $rootScope.getColor('AP'),
tooltip: {
pointFormat: '<span style="color:{series.color}">{series.name}: {point.y:,.0f}</span><br/>'
}
}],
title: {
text: ''
},
loading: false
};
in this is my code in directive highchart
'use strict';
angular.module('chartsExample.directives',[])
.directive('chart', function () {
return {
restrict: 'E',
template: '<div></div>',
scope: {
chartData: "=value"
},
transclude:true,
replace: true,
link: function (scope, element, attrs) {
var chartsDefaults = {
chart: {
renderTo: element[0],
type: attrs.type || null,
height: attrs.height || null,
width: attrs.width || null
}
};
//Update when charts data changes
scope.$watch(function() { return scope.chartData; }, function(value) {
if(!value) return;
// We need deep copy in order to NOT override original chart object.
// This allows us to override chart data member and still the keep
// our original renderTo will be the same
var newSettings = {};
angular.extend(newSettings, chartsDefaults, scope.chartData);
var chart = new Highcharts.Chart(newSettings);
});
}
};
});
Thank's....

Dynamically Building a Container with this.setItems()

I'm trying to build my container in the initialize() function by creating all my components then calling this.setItems([...]). For some reason, my components are being placed on top of each other, rather than after each other in the vbox.
I am able to grab the top component and move it down, as is shown in the attached image.
Simplified view with two components:
Ext.define("Sencha.view.DynamicView", {
extend: 'Ext.Container',
xtype: 'dynamic-view',
requires: [],
config: {
layout: {
type: 'vbox'
},
flex: 1,
cls: 'view-container',
store: null
},
createRadioSet: function() {
this.radioFieldSet = Ext.create('Ext.form.FormPanel', {
flex: 1,
items: [{
xtype: 'fieldset',
title: 'About You',
defaults: {
xtype: 'radiofield',
labelWidth: '40%'
},
instructions: 'Favorite color?',
items: [{
name: 'color',
value: 'red',
label: 'Red'
},
{
name: 'color',
value: 'green',
label: 'Green'
}
]
}]
});
return this.radioFieldSet;
},
createCheckboxSet: function() {
this.checkboxFieldSet = Ext.create('Ext.form.FormPanel', {
flex: 1,
items: [{
xtype: 'fieldset',
title: 'Check all that apply',
defaults: {
xtype: 'checkboxfield',
labelWidth: '40%'
},
instructions: 'Tell us all about yourself',
items: [{
name: 'firstName',
value: 'First',
label: 'First Name'
},
{
name: 'lastName',
value: 'Last',
label: 'Last Name'
}
]
}]
});
return this.checkboxFieldSet;
},
initialize: function() {
this.callParent(arguments); // #TDeBailleul - fixed
var r1 = this.createRadioSet();
var cbSet1 = this.createCheckboxSet();
// this.add(cbSet1);
// this.add(r1);
this.setItems([r1, cbSet1]);
}
});
My problem was that I was adding my components incorrectly in a tab controller. I'm including an example that creates buttons on one tab and the checkboxes on another tab.
Ext.Loader.setConfig({
enabled : true
});
Ext.application({
name : ('SF' || 'SenchaFiddle'),
createRadioSet: function () {
this.radioFieldSet = Ext.create('Ext.form.FormPanel', {
height: '300px',
width: '300px',
items: [
{
xtype: 'fieldset',
title: 'Title',
defaults: {
xtype: 'radiofield',
labelWidth: '40%'
},
instructions: 'Favorite color?',
items: [
{
name: 'color',
value: 'red',
label: 'Red'
},
{
name: 'color',
value: 'green',
label: 'Green'
}
]
}
]
});
return this.radioFieldSet;
},
createButton: function(i) {
return Ext.create('Ext.Button', {
text: 'hello' + i,
height: '50px',
width: '100px'
});
},
launch: function () {
var tabPanel = Ext.create('Ext.tab.Panel', {
layout: 'card',
padding: 2,
tabBarPosition: 'bottom',
items: [
{
id: 'tab1',
title: 'Home',
layout: 'hbox',
xtype: 'container',
iconCls: 'home'
},
{
id: 'tab2',
title: 'More',
layout: 'hbox',
xtype: 'container',
iconCls: 'star'
}
]
});
Ext.Viewport.add(tabPanel);
var a,b;
for (var i = 0; i < 3; i++) {
a = this.createButton(i);
b = this.createRadioSet();
// tabPanel.getAt(0).add(b); // Reference the proper component: Tab 1
Ext.getCmp('tab1').add(a);
Ext.getCmp('tab2').add(b);
}
}
});

Sencha: Unable to set the right layout :(

I'm trying to create a container that has four items, and what I need is the container to be the one that scroll instead of each individual item, also I want every item to have it's own height so if the four items are bigger than the screen the user can scroll down through the container to see the other items info...
JSFiddle:
http://jsfiddle.net/martuanez/7GV3b/
My code:
var store = {
type: 'store',
fields: ['label', 'value'],
data: [{
label: 'label',
value: 'value',
}, {
label: 'label',
value: 'value',
}, {
label: 'label',
value: 'value',
},
]
};
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: ('SF' || 'SenchaFiddle'),
launch: function () {
Ext.define('MyApp.view.Contacts.ContactsDetailsView', {
xtype: 'ContactsDetailsView',
extend: 'Ext.Container',
config: {
layout: {
type: 'vbox',
padding: 3
},
defaults: {
scrollable: {
direction: 'horizontal',
directionLock: true
},
height: 500,
layout: 'fit'
},
scrollable: 'vertical',
itemCls: 'details-list-container',
items: [{
xtype: 'dataview', //add xtype
itemId: 'detailItem',
loadingText: 'Loading keys...',
emptyText: '<div>No keys found.</div>',
store: store,
onItemDisclosure: false,
itemTpl: '<br/>item 1:<br/> {label}<br/>{value}<br/><br/>',
itemCls: 'details-list',
selectedItemCls: '',
disableSelection: true,
pressedCls: ''
}, {
xtype: 'list',
itemId: 'detailKeys',
store: store,
loadingText: 'Loading keys...',
emptyText: '<div>No keys found.</div>',
onItemDisclosure: false,
itemTpl: 'item 2: {label}{value}<br/>',
itemCls: 'details-list',
selectedItemCls: '',
disableSelection: true,
pressedCls: ''
}, {
xtype: 'list', //add xtype
itemId: 'detailuserdefs',
store: store,
loadingText: 'Loading userdefs...',
onItemDisclosure: false,
itemTpl: 'item 3: {label}{value}<br/>',
itemCls: 'details-list',
selectedItemCls: '',
disableSelection: true,
pressedCls: ''
}, {
xtype: 'list',
itemId: 'detailOthers',
store: store,
loadingText: 'Loading userdefs...',
onItemDisclosure: true,
itemTpl: 'item 4: {label}{value}<br/>',
itemCls: 'details-list'
}
]
}
});
Ext.Viewport.add(Ext.create('MyApp.view.Contacts.ContactsDetailsView'));
}
});
I´ve finally make it work, i set scrollable to false in the defaults section of the container and a height on the child items.
One thing that happened is that when setting scrollable to false in the childs, not in the defaults, sencha didn't recognize the height, this is a bug that they claim they have fixed already, actual version by the time i'm writting this 2.2, version i'm working on 2.1.1
Note: I also managed to set dinamic heights on each item, i did this by setting it apart and adding the items later by doing myContainer.add(itemWithDinamicHeight);
;)
Cheers!

ext js 4 layout

this is code and link on screenshot
Ext.define('SD.view.SDDetail', {
extend: 'Ext.window.Window',
alias: 'widget.sddetail',
title: "Создание заявки",
height: 620,
width: 850,
layout: 'fit',
border: false,
modal: true,
isDemandReadOnly: false,
changeStatusOnly: false,
initComponent: function () {
var me = this;
var user = TR.user;
var f = new Ext.form.FormPanel({
xtype: 'form',
labelWidth: 60
, frame: true
, items: [{
fieldLabel: 'Text'
, xtype: 'textfield'
, anchor: '-18'
}, {
layout: 'column'
, defaults: {
columnWidth: 0.5
//, layout: 'form'
, border: false
, xtype: 'panel'
, bodyStyle: 'padding:0 18px 0 0'
}
, items: [{
defaults: { anchor: '100%' }
, items: [{
xtype: 'combo'
, fieldLabel: 'Combo 1'
, store: ['Item 1', 'Item 2']
}, {
xtype: 'datefield'
, fieldLabel: 'Date'
}]
}, {
defaults: { anchor: '100%' }
, items: [{
xtype: 'combo'
, fieldLabel: 'Combo 2'
, store: ['Item 1', 'Item 2']
}, {
xtype: 'timefield'
, fieldLabel: 'Time'
}]
}]
}, {
fieldLabel: 'Text Area'
, xtype: 'textarea'
, anchor: '-18 -80'
}]
});
this.items = [f];
this.tbar = {
xtype: 'toolbar',
height: 27,
items: [
{
xtype: "tbspacer"
}, "-", {
xtype: "tbspacer"
},
{
text: "Прикрепленные файлы",
icon: "Content/images/btnAttach.gif",
disabled: true,
handler: function (btn, e) { ShowAttachments(r.id, true, me.isDemandReadOnly); }
}, "-", {
xtype: "tbspacer"
}, {
text: "История статусов",
icon: "Content/images/btnHistory.gif",
disabled: true,
handler: function (btn, e) { ShowStatusesHistory(r.id, true); }
}, "-", {
xtype: "tbspacer"
}, {
text: "Информация по сопроводительной карточке",
icon: "Content/images/btnComplect.gif",
disabled: true,
handler: function (btn, e) { ShowComponents(r.id, true, me.isDemandReadOnly); }
}, "-", {
icon: "Content/images/btnPrint.gif",
text: "Сопроводительная карточка изделия",
disabled: true,
handler: function (btn, e) { DemandCardForm(r.id); }
}
]
};
this.buttons = [
{
text: "Сохранить",
action: 'save'
, disabled: me.isDemandReadOnly || user.SdUserViewOnly
}, {
xtype: "button",
text: "Отмена",
handler: function (btn, e) {
me.close();
}
}
];
// me.on('show', function () {
// me.down('kontragentcombo').focus(false, 250);
// });
me.callParent(arguments);
}
http://s002.radikal.ru/i198/1208/e2/7a153ca9b116.jpg
when i uncomment layout: 'form' i have error
namespace is undefined
[Прерывать на этой ошибке]
if (namespace === from || namespace.substring(0, from.length) === from) {
i whant this http://i032.radikal.ru/1208/51/e9b8ba1c1f30.jpg
but have error, what i must do?
layout is not defined in the items of the panel. It's part of the panel's properties (see the docs: Form Panel). Put it before the items.
As a suggestion - it would be easier to see it if your lines had consistent comma layout.

add element to carousel sencha

In sencha touch, I have a carousel declared like this:
ajaxNav = new Ext.Panel({
scroll: 'vertical',
cls: 'card1 demo-data',
styleHtmlContent: true,
layout: {
type: 'vbox',
align: 'stretch'
},
defaults: {
flex: 1
},
items: [{
xtype: 'carousel',
items: [{
id:'tab-1',
html: '',
cls: 'card card1'
},
{
id:'tab-2',
html: '<p>Clicking on either side of the indicators below</p>',
cls: 'card card2'
},
{
id:'tab-3',
html: 'Card #3',
cls: 'card card3'
}]
}]
});
Does anybody knows how to add elements dinamycally??
I write you a simple example to show you how to dinamically add a new panel to an existing Ext.Carousel element.
Ext.setup({
onReady: function() {
var ajaxNav = new Ext.Carousel({
fullscreen: true,
dockedItems: {
xtype: 'toolbar',
title: 'Demo',
items: [{
xtype: 'button',
ui: 'action',
text: 'Add',
handler: function(){
var element = new Ext.Panel({
html: 'New Element'
});
ajaxNav.add(element);
ajaxNav.doLayout();
}
}]
},
items: [{
id:'tab-1',
html: '',
cls: 'card card1'
},{
id:'tab-2',
html: '<p>Clicking on either side of the indicators below</p>',
cls: 'card card2'
},{
id:'tab-3',
html: 'Card #3',
cls: 'card card3'
}]
});
}
});
As you can see, on the "Add" press button event, you first have to define your panel according to your needs, then add it to your carousel, and, the most important thing, you have to let the carousel recalculate his layout calling the "doLayout()" function.
Hope this helps.

Resources