-
25 May 2010 8:25 PM #1
How to loop through an array in a store using tpl?
How to loop through an array in a store using tpl?
The scenario is like this:
I have an array which has a child array:
parent array
L child array
Both parent, and child arrays are flat arrays, not associative. Im loading the parent array into a store. Now, I want to use a tpl for my rowexpander. Im able to access the stores elements by using {name_of_element_in_store} syntax. Now the problem is Im unable to access the child array here.. As all examples for looping with templates involve using associative arrays, Id like to get a pointer or two from you guys on how to do the following with a flat array:
'<tpl for={Sources}>',
'<div>{.}</div>',
'</tpl>'
Sources is the corresponding name in the datastore. This element supposedly holds the child array. Any and all help will be greatly appreciated..Thanks in advance
No one stands taller than the last man standing
-
25 May 2010 10:57 PM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
It's:
Code:'<tpl for="Sources">', '<div>{.}</div>', '</tpl>'
-
25 May 2010 11:25 PM #3
I get an error saying Expected ')'. Just to make things clearer, the following is my code:
for (var i=0;i<count;i++)
{
childArr = new Array();
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
childArr.push("blank");
var sourceArr = new Array();
for (var j=0;j<10;j++)
{
sourceArr.push(j);
}
childArr.push(sourceArr);
myData.push(childArr);
}
var store = new Ext.data.ArrayStore({
id: 'configGridStore',
fields: [
{ name: 'dataProfiles' },
{ name: 'dataProfileID' },
{ name: 'status' },
{ name: 'totalNoOfSrcObjects', type: 'string' },
{ name: 'totalNoOfObjectsProcessed', type: 'string' },
{ name: 'noOfObjectsBeingProcessed', type: 'string' },
{ name: 'noOfObjectsFailed', type: 'string' },
{ name: 'avgProcessingTimePerObject', type: 'string' },
{ name: 'startDateTime', type: 'string' },
{ name: 'estimatedEndDateTime', type: 'string' },
{ name: 'controls', type: 'string' },
{ name: 'source', type: 'string' },
{ name: 'destination', type: 'string' },
{ name: 'noOfThreads', type: 'string' },
{ name: 'noOfObjectsPerThread', type: 'string' },
{name:'DPSources'}
]
});
store.loadData(myData);
The template is for a rowexpander:
tpl: new Ext.Template(
'<div id="div'+(globalIDCounter++)+'"><br><p><b>Source:</b> {source}</p>',
'<br>',
'<p><b>No Of Threads:</b> {noOfThreads}</p>',
'<br>',
'<p><b>No Of Objects Per Thread:</b> {noOfObjectsPerThread}</p>',
'<br>',
'<p><b>Destination:</b> {destination}</p>',
'<br>',
'<tpl for="DPSources">',
'<div>{.}</div>',
'</tpl>'
'<input type="button" value="Start Crawling" onclick="handleStartCrawling({dataProfileID});"></input></div>'
)No one stands taller than the last man standing
-
26 May 2010 12:21 AM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
You are missing a comma:
Code:'</tpl>',
-
26 May 2010 2:36 AM #5
cant believe I made such a stupid mistake... thank you for your help condor.. much appreaciated..
No one stands taller than the last man standing
-
20 Nov 2012 12:22 AM #6
tpl dataview problem
tpl dataview problem
I have this data
{- "total":2,
- "rows":[
- {
- "customer_group_id":"1",
- "customer_group_name":"Italian Restaurant",
- "sales":[
- {
- "item_group_name":"Artichoke",
- "current_month_revenue":"50",
- "previous_months_revenue_avg":85
- {
- "item_group_name":"Capers",
- "current_month_revenue":"30",
- "previous_months_revenue_avg":78
- {
- {
- "customer_group_id":"2",
- "customer_group_name":"Western Restaurant",
- "sales":[
- {
- "item_group_name":"Artichoke",
- "current_month_revenue":"150",
- "previous_months_revenue_avg":61
- {
- "item_group_name":"Capers",
- "current_month_revenue":"208",
- "previous_months_revenue_avg":111
- {
- {
I want to build an matrix table data view like
Artichoke Capers
Italian Restaurant 50 100
Any help would be appreciated.
Thanks.
Mike
Similar Threads
-
[FIXED][3.0RC2] store.execute() modifies store.modified array as a side-effect
By tymarats in forum Ext 3.x: BugsReplies: 4Last Post: 1 Jul 2009, 8:52 AM -
[solved] Json object with array of array root not loaded in store records
By PaoloZ in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 1 Apr 2009, 8:12 AM -
Array.sortDates ,Array.unique, and extended Array.indexOf
By wm003 in forum Ext 2.x: User Extensions and PluginsReplies: 3Last Post: 4 May 2008, 12:38 AM


Reply With Quote