Så i have noticed a very annoying bug in Sencha Touch. When i try to add the paging plugin to my dataview the "load more" text is placed above the items, not below like i want it to. It works with the standard listview.
I found another thread asking me to add "inifinte:true" to my dataview, but that did not help. Nor did "bottom:0" or "docked:'bottom'" options. Here is my code:
{
xtype: 'dataview',
plugins: {
type: 'listpaging',
loadMoreText: 'Indlæs flere..',
autoPaging: true
},
flex: 1,
cls: 'inspectionImages',
itemId: 'imageContainer',
padding: 10,
style: 'background: #F7F7F7; color: black',
emptyText: 'Der er ingen billeder på synet.',
itemTpl: ['...'],
loadingText: 'Henter billeder..',
store: 'Images'
}
Also here is an example sencha fiddle code - framework is 2.4.x:
Ext.application({
launch: function () {
var touchTeam = Ext.create('Ext.DataView', {
fullscreen: true,
plugins: {
type: 'listpaging',
loadMoreText: 'Indlæs flere..',
autoPaging: true
},
store: {
fields: ['name', 'age'],
data: [{
name: 'Jamie',
age: 100
}, {
name: 'Rob',
age: 21
}, {
name: 'Tommy',
age: 24
}, {
name: 'Jacky',
age: 24
}, {
name: 'Ed',
age: 26
}]
},
itemTpl: '<div>{name} is {age} years old</div>'
});
touchTeam.getStore().add({
name: 'Abe Elias',
age: 33
});
touchTeam.getStore().getAt(0).set('age', 42);
} // launch
}); // application()
I have checked with the Ext.dataview.dataview in the sencha touch documentation, and this shows similar behaviour when adding the paging plugin so i know that this is probably not my own fault. I really would like the loadinText to be placed in the bottom of the dataview. Any suggestions would highly be appreciated!
The List Paging Plugin is Developed for Lists.
If you are using it for the DataView then The Load more Text Will appear at the Top.
I have faced the same Problem.I have Gone Through the List paging Plugin Js.
Then Got Solution By just Changing the Css Property..
Inspect the "loading-spinner" CLass and change the Style to: style="font-size: 180%; margin: 10px auto;position:absolute; bottom: 0px; left: 50%
and Inspect the Class -"list-paging-msg" And change the style to style="position:absolute; bottom: 0px; left: 50%;"
This is a bug in Sencha Touch. Mitchell Simoens has told here that it is meant for List only but I believe this should also support the dataview as it is light compared to list.
In sencha forum solutions , you can see they have changed the xtype from dataview to list. I also had same problem and I did the same. But you can do some addition if you want the look and feel of dataview instead of list.
disableSelection: true,
pressedCls: '',
I hope this helps you. Let me know if you need anything else.
I have found the solution after gone through the code of List paging Plugin, Ext.dataview.DataView and Ext.dataview.List.
Initialize list paging plugin after dataview initialized, then the "load more component" position will be right.
Ext.define('MyDataView', {
extend: 'Ext.dataview.DataView',
config: {
/* do not set here
plugins: [{
xclass: 'Ext.plugin.ListPaging',
autoPaging: true
}, {
xclass: 'Ext.plugin.PullRefresh'
}]
*/
},
initialize: function() {
var me = this;
me.callParent();
// Initialize plugin here, so the listpaging component will append after dataview container
me.setPlugins([{
xclass: 'Ext.plugin.ListPaging',
autoPaging: true
}, {
xclass: 'Ext.plugin.PullRefresh'
}]);
}
}
As it turns out the pagingplugin were not meant for Dataview. It can be used though. In the end i ended up just manually moving the "load more" text in the DOM at the end of each load of the plugin. To ensure no listeners were lost i used the appendchild JS function and applying some custom css. Now everything works as expected.
Related
I want to send value from one view to another one, I have a code that's work in ExtJS 6 but not in ExtJS 4.
This is from the first one:
var test = Ext.create('test.text', {
delayedRenderTo: container_id,
id: 'messageBox-' + meta.rowIndex,
viewModel: {
data: {
value: value
}
}
});
and we bind it like this:
Ext.define('test.text', {
extend: 'Ext.Panel',
layout: {
type: 'vbox',
align: 'stretch',
overflow: 'scroller',
},
items: [{
xtype: 'textareafield',
grow: true,
growMin: 30,
growMax: 120,
disabled: true,
fullscreen: true,
bind: {
value: '{value}',
},
fieldStyle: 'font-weight:bold;'
}]
});
What is the alternative for ExtJS 4 ?
ViewModels were introduced in Ext JS 5 which is why it doesn't work in Ext JS 4.
To do it in Ext JS 4, you'd have to find the component (the textareafield in this case) and then execute the setter (setValue for this example). It's all manual in Ext JS 4.
Getting the component depends on many things but the best way is to use ComponentQuery and depends where the code executing this would be. First, you'd have to get your test.text instance and then use comp.child('textareafield'). I cannot give you a silver bullet example as it depends on many factors but using component's down, child, query, up methods a good start and they all have different purposes.
I was wondering how I should start making a custom composite component. One that has a border layout, but for which its items show in the center region of the border layout. The following image shows what I'm trying to achieve:
In pseudo-code this would be:
Ext.define('App.custom.ContentView', {
extend: 'Ext.container.Container',
xtype: 'contentview',
layout: 'border',
northCmp: ..., // Custom north region component.
westCmp: ..., // Custom west region component.
centerCmp: ..., // Placeholder for the items it will have.
items: [] // Filled in by each implementation, shown in the center region.
});
Ext.create('App.custom.ContentView', {
layout: 'vbox', // Applies to center region of 'contentview'.
items: [
// Items that go into the center region of the 'contentview'.
]
});
I have looked through the ExtJS source code, and viewed a couple of examples at the Sencha Market; but I have not found an obvious example that does not include a lot of duplicate code.
Any help, or nudge in the right direction, would be greatly appreciated! :)
You should not do that. Please, don't let me be misunderstood, your intentions are good but the implementation you describe will grip in some point in the future. I know because I did something similar when I debuted with Ext. The idea of tuning the component declaration to your tastes/need/whatever may seem like a pleasant simplification... Unfortunately, in practice what you want to do is to give another meaning to an existing construct (items in your case). Here's what it will really bring you:
All code external to your application (that includes Ext, and Ext future releases!) will expect components/container to behave the classic way. That is, that the items of a container are really the items it contains, not the items of one of its children. Unexpected behaviour is to be expected.
You'll inevitably want to customize this component in some ways. You've already started, with the layout of the center region. If you rewrite the way the component work, you'll have to write some kind of config proxy to any feature you want to use. Big burden instead of a little saving. Doesn't worth it.
And finally, in some time you'll have forgotten all about what you've done with this component. And you'll have to debug your code just to understand what it is supposed to do (that is, before debugging the real issues).
Sorry for lecturing... All that being said, that doesn't mean there's not a way to come close to what you want without falling prey to reframing the framework.
Here's how I would do it (fiddle):
Ext.define('My.custom.BorderContainer', {
extend: 'Ext.container.Container'
// xtype is used in Ext3 and Touch... Ext4 uses aliases
,alias: 'widget.contentview'
,layout: 'border'
,items: [{
region: 'north'
,xtype: 'container'
,html: "<h1>Some header</h1>"
,style: 'background-color: lightblue;'
},{
region: 'west'
,xtype: 'container'
,split: true
,html: "<h1>Some menu</h1>"
,style: 'background-color: purple;'
},{
region: 'center'
,xtype: 'container'
}]
/**
* Configuration of the center panel.
*
* #cfg {Object/Ext.Component}
*/
,center: null
,initComponent: function() {
var center = this.center;
if (center) {
if (center instanceof Ext.Component) {
center.region = 'center';
} else {
// never modify a passed config object, that could
// break the expectations of the using code
center = Ext.clone(center);
// apply default config, including the region
center = Ext.applyIf(center, this.items[2]);
}
this.items[2] = center;
}
// else use default config, already in place
this.callParent(arguments);
}
});
Notice how I added a new center config option instead of trying to recycle existing ones (items, layout, etc.). That allows me to put anything I want, customized to the bone, and with usual syntax, in that. Future me and coworkers will probably send me chocolates for that! For example:
Ext.widget('contentview', {
renderTo: Ext.getBody()
,height: 300
,center: {
layout: {
type: 'vbox'
,align: 'center'
}
,defaults: {
xtype: 'component'
,margin: 10
,padding: 10
}
,items: [{
html: 'Red'
,style: 'background-color: green;'
},{
html: 'Green'
,style: 'background-color: blue;'
},{
html: 'Blue'
,style: 'background-color: red;'
}]
}
});
Ext.widget('contentview', {
renderTo: Ext.getBody()
,height: 300
,center: {
xtype: 'tabpanel'
,tabPosition: 'bottom'
,items: [{
title: 'First Tab'
,html: "I'm empty!"
},{
title: 'Second Tab'
}]
}
});
Ext.widget('contentview', {
renderTo: Ext.getBody()
,height: 300
// passing a component instance instead of a config object
,center: Ext.widget('button', {
text: "Foo"
})
});
I checked out g.Raphael for creating simple charts. I managed to display them on a demo website, but I don't know how I can integrate them into my Sencha Touch 2 app now. I managed integrating it by using an iframe but this is not dynamic and performance lacks a bit too.
Can somebody please help or show me a tutorial?? Need help quickly.
Thanks!
Sorry had some code formatting issues ^^
Can you please point me into a direction? Do I have to put this into my view or a controller? I've included the Raphael files in my index.html for the ST2 app.
Heres my View:
Ext.define('Demo.view.Configurator', {
extend: 'Ext.carousel.Carousel',
xtype: 'configurator',
requires: [
'Demo.store.SampleStore'
],
config: {
title: 'Konfigurator',
iconCls: 'home',
direction: 'horizontal',
directionLock: true,
//Will be applied to every object in the array by default
defaults: {
styleHtmlContent: true,
cls: 'configurator-item',
scrollable: true,
},
items: [
{}
]
}
}
)
Thanks
What's preventing you from using both in the same page? Just include the Raphael's files, and you can use it to draw in Ext components.
For example:
var win = Ext.widget('window', {width: 600, height: 600, autoShow: true}),
r = Raphael(win.body.id);
r.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2]);
Jeees, I finally found it here - works perfectly:
Link
I'm following examples in the "ExtJS in Action" book and I ran into a problem with one of them. The code intends to add new panels to a window, unfortunately when the panels being added are collapsed by default, they are not rendered correctly.
Here is the code in question:
var childPnl1 = {
frame: true,
height: 50,
html: 'My First Child Panel',
title: 'First children are fun'
};
var myWin = new Ext.Window({
height: 300,
width: 300,
title: 'A window with a container layout',
autoScroll: true,
items: [
childPnl1
],
tbar: [
{
text: 'Add child',
handler: function() {
var numItems = myWin.items.getCount() + 1;
myWin.add({
title: 'Child number ' + numItems,
height: 60,
frame: true,
collapsible: true,
collapsed: true,
html: 'Yay, another child!'
});
myWin.doLayout();
}}
]
});
myWin.show();
When I run it, I get the result presented in this fiddle:
http://jsfiddle.net/PHaP4/
When I hit the 'Add child' button, the collapsed panels are rendered as very narrow elements, as if width was not properly set.
Is this a bug in Ext or is there a new way of doing this properly in ExtJS4?
The new public 4.0.7 release seems no to have this bug fixed yet.
Looks like a bug in ExtJS 4.0.2, and appears to be fixed in ExtJS 4.0.5. Here is what I found in the release notes:
[EXTJSIV-2547] - Child components not rendered.sized in initially
collapsed, uncontained Panel.
My job has a premium account, so I was able to download and check 4.0.5. You'll have to wait for the general release, though.
I am unable to render google pie chart in my border layout of the interface. Though the pie chart works fine on separate html page.
The div is as follows:
The javascript code looks like this:
{
title: 'View Interactive Reports',
ContentEl: "pChartMap",
plain: true,
bodyStyle: 'padding:5px',
border: false,
autoScroll: true
}
I am not sure about the ContentEl thing. It works fine, if there is simple text there but since the google chart is based on google visualisation api and an AJAX call where there is a function call as:
google.setOnLoadCallback(createChart);
Any ideas how to render this will be appreciated.
Cheers
Ali
Have you check this? http://www.sencha.com/blog/2008/10/13/google-visualization/
Sadly the example page is broken, but is just because the sencha site has not the 2.2 source of ExtJS anymore; or at least not there where the sample expect it; but if you download the page and use ExtJS 2.3.0 it will work.
Anyway, you only need to download this js: http://dev.sencha.com/playpen/google-visualization/GVisualizationPanel.js
And then just use the Ext.ux.GVisualizationPanel. Here is an example I tested:
Ext.onReady(function() {
var lineChartDs = new Ext.data.SimpleStore({
fields: [
{name: 'yr', type: 'string'}
,{name: 'sales', type: 'int'}
,{name: 'expenses', type: 'int'}
],
data: [['2004',1000,400],['2005',1170,460],['2006',860,580],['2007',1030,540]]
});
var lineChart = new Ext.ux.GVisualizationPanel({
id: 'lineChart',
visualizationPkg: 'linechart',
title: 'Company Performance Sample',
store: lineChartDs,
columns: [
{dataIndex: 'yr', label: 'Year'}
,{dataIndex: 'sales', label: 'Sales'}
,{dataIndex: 'expenses', label: 'Expenses'}
]
})
new Ext.Viewport({
layout: 'fit',
items: [lineChart]
});
});