extjs Dynamically load nodes on scroll down - extjs4.1

I am new to Ext Js 4.1, I have 5000 child nodes and need to load only 50 nodes on load,after scrolling down have to load another 50 nodes and continues. I am trying from past 2 days with different scenarios, but I didn't find anything related, can anu one please help me how to do, if possible with sample code.
Thanks in Advance

The only way to do this with a server that gives you your's 5000 child nodes is to use a buffered store.
Using a buffered store you can set your page dimensions and scrolling down changing the page you will be able to load your datas 50 by 50 records.
check all you need here http://docs.sencha.com/extjs/5.1/5.1.2-apidocs/#!/api/Ext.data.BufferedStore
buffered store disponible also on ext 4.1
also some examples on sencha examples
you can watch this
http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/infinite-scroll.html

Finally i find the solution that we need to use 'bufferedrenderer' Plugin.Infinite grid uses a buffered store, and is not supported for trees.
Here is the sample code
Ext.onReady(function () {
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'http://localhost/codig/index.php/user/jsonusers',
extraParams:limitValue
}
});
store.reload();
var treePanel = Ext.create('Ext.tree.Panel', {
id:'mytree',
title: 'Infinite nodes tree',
width: 200,
height: 400,
store: store,
rootVisible: false,
plugins: {
ptype: 'bufferedrenderer'
},
renderTo: Ext.getBody()
});
});

Related

Adjusting Context when using rallystandardreport

I'm utilizing the rally standard report to generate an iteration burndown, but given that i want post this on a wiki/web page. Looking for a way to point this to a project/subproject so that I can have several instances of this on one page. I tried it via context, but I'm obviously missing something. The code is below, any guidance/recommendation would be greatly appreciated!
Thanks!
Mark
Ext.create('Ext.Container', {
context : {
workspace : 'https://rally1.rallydev.com/slm/webservice/v2.0/workspace/50876644101',
project : 'https://rally1.rallydev.com/slm/webservice/v2.0/project/50891172431'
},
items: [{
xtype: 'rallystandardreport',
width: 750,
height: 500,
reportConfig: {
report: 'IterationBurndown',
subchart: 'hide',
title : 'IterationBurndown',
project : 'Harrier'
}
}],
renderTo: Ext.getBody().dom
});
You're on the right track. The StandardReport component was one of the earliest ones written and so it doesn't quite follow the standard ability to pass in a context like most of the rest of the SDK.
You're on the right path with the project config above- it just needs to be the ref of the project you're targeting rather than the name, and it goes right on the root component config instead of beneath reportConfig. There are also projectScopeUp and projectScopeDown.
There's also a full example here: https://help.rallydev.com/apps/2.0/doc/#!/example/standard-report
{
xtype: 'rallystandardreport',
width: 750,
height: 500,
reportConfig: {
report: 'IterationBurndown',
subchart: 'hide',
title : 'IterationBurndown'
},
project: '/project/12345',
projectScopeUp: false,
projectScopeDown: true
}

Sencha Architect (touch) - Use camera photos

I have implemented my sencha architect project with a possibility to do a photo (with phonegap). After taking a photo, I need to see the photo directly into another container with other information (the picture will be smaller than the original...and there will be written above and below).
How do I open the new container and display the image in a smaller size?
please help me, I don't understand how can I manage the photo
Now I use this code but if you have something better....
var me = this;
Ext.device.Camera.capture({
success: function(image) {
me.add({
xtype:'image', // Commento
src: image
});
},
source: 'camera',
cameraDirection: navigator.camera.Direction.FRONT,
destination: 'file'bu
});
thank you
Carlo
Sencha documentation got an example for it. See http://docs.sencha.com/touch/2.3.1/#!/api/Ext.device.Camera
Ext.device.Camera.capture({
success: function(image) {
imageView.setSrc(image);
},
quality: 75,
width: 200,
height: 200,
destination: 'data'
});
You can also use
destination: 'url'
in that case the image argument of the callback function will be a file URL what you can use in a container template as the source of the html image.

Sencha touch 2 : List shows only last item retrieved from API

I want to show the data from the following API in List :
http://customer.appxtream.com/astro.apps.cms/jsonFeed.action/?service=astroSportsDataService&action=grabJsonText&mimeType=application/json&p1=HighlightNewsList&p2=EURO2012
when I get the data, the Network of Chrome shows me that all elements have been retrieved but List shows only the data from the last item in the API here is my code:
View
Ext.define('astro.view.HighliteNews', {
extend: 'Ext.DataView',
xtype: 'highliteNews',
config:{
title:'xren',
store: 'highliteNewsStoreId',
itemtap: true,
scrollable:'horizontal',
inline:{
wrap:false
},
itemTpl:[
'<div><img src="{imageLink}"/> </div>',
],
},
});
Store
Ext.define('astro.store.HighliteNewsStore',{
extend: 'Ext.data.Store',
xtype:'highliteNewsStore',
config:{
model: 'astro.model.HighliteNewsModel',
autoLoad: true,
storeId: 'highliteNewsStoreId',
proxy:{
type:'ajax',
url :'http://customer.appxtream.com/astro.apps.cms/jsonFeed.action',
extraParams:{
service:'astroSportsDataService',
action:'grabJsonText',
p1:'HighlightNewsList',
p2:'EURO2012',
mimeType:'application/json'
},
reader:{
type:'json',
rootProperty:'cmsHighlightNewsList',
},
},
}
});
Model
Ext.define('astro.model.HighliteNewsModel',{
extend: 'Ext.data.Model',
config:{
fields: ['imageLink'],
}
});
So the network shows that 3 images are sent from API but the List shows ONLY LAST IMAGE.
Please help
I solved the problem guys :) , there is an conflict between Sencha and JsonP, so if you assign a idproperty to your Model, the problem will be sloved :
config:{
idProperty: 'HighliteIdProperty',
fields: ['imageLink'],
}
A few things I would suggest :
Add a listener to the load event of the store
This is just to check that all the data is load in your store.
You can do it in different ways :
In a controller
store.on({
load:function(){
console.log(store.getCount());
}
});
or directly in the store config with the listeners attribute
listeners:{
load:function(store){
console.log(store.getCount());
}
}
Check the DOM
In the Web Inspector / Firebug, check if your items are there or only the last one.
I think you could also try this command in the console :
Ext.DomQuery.select('div[class=x-dataview-item]').length
It will return the number of items in your dataview.
Set a width and height to your image
I also had the same problem with a dynamically loaded dataview. All the picture were there in the DOM but too small to be seen. So I suggest, you give them a CSS class with a defined width and height.
That's all I can think of for now.
Hope this helps
Thanks Arash for this question and answer. We are facing similar problem and found that we didn't have model defined. Defining the model worked in our case. However, it worked while we retrieved playlist from youtube and now while retrieving the list from google spreadsheet. Hope this helps others who are using google spreadsheet.
adjust the height in the config of view......this might be a problem

How to take a photo using Camera in Sencha App?

I am trying to take a picture using camera in Sencha Touch 2. Here i have one button 'Take a Picture', when i will press it, camera should start. As i am new to this sencha touch 2, i am unable to figure it out, how to do this?
For this i used the below code:
Sencha Fiddle Link
Please help me. I do not want to use Phone gap.
You have to add device folder of Sencha Library in root directory
and add below code in
Ext.require('Ext.device.Camera');
and use this code for capture image using camera
Ext.device.Camera.capture({
success: function(image) {
imageView.setSrc(image);
},
quality: 75,
width: 200,
height: 200,
destination: 'data'
});
If you want to use purely sencha, then you can check this code:
xtype: 'button',
handler: function(button, event) {
Ext.device.Camera.capture({
source: 'camera',
destination: 'data',
success: function(imagedata) {
var img = Ext.getCmp('theimage');
img.setSrc('data:image/jpeg;base64,' +imagedata);
},
failure: function() {
Ext.Msg.alert('Error', 'There was an error when acquiring the picture.');
},
scope: this
});
But if you want to use phonegap camera features, may be you have to change the code. As sencha is giving the default feature to handle the camera, i wish not to go with phonegap. Hope it will help..

ExtJS4 / Sencha Touch 2: Reuse data (loaded into store) in different views with different sorting

I have data in an external database which can be accessed via JSON. Now I want to provide different views on these data sets (eg. different sorting, ..). Is it possible to use one single store for this or do I need two stores accessing the same URL except with a different sorter?
My example code looks like this:
Ext.define('MyApp.store.MyStore', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.MyModel'
],
config: {
autoLoad: true,
model: 'MyApp.model.MyModel',
storeId: 'MyJsonStore',
proxy: {
type: 'ajax',
url: 'http://localhost/index.php?data=MyData&format=json',
reader: {
type: 'json'
}
},
sorters: [
{
direction: 'DESC',
property: 'MyRating'
},
{
direction: 'ASC',
property: 'MyLabel'
}
] } });
And one view should now render a list sorted by the rating and a second one should display a list sorted by the label.
Is there a way to prevent querying the DB twice?
Thanks - I just started out with Sencha Touch and ExtJS --- therefore please excuse my simple question ;)
Somehow I couldn't find any smart solution by asking Google for this basic task..
You don't have to worry about anything unless your two views are presented at the same time. Just re-sort the same store locally.
If they are presented at the same time you will have to create a copy of a store. Otherwise they will show exact same information.