Hello!
Kategori.png
First, I have a button with an ID that is linked to a view that lists the data from JSON (see code below):
Code:
Ext.define('LG.view.categories', {
extend: 'Ext.List',
xtype: 'categories',
requires: [
'Ext.dataview.List',
'Ext.data.proxy.JsonP',
'Ext.data.Store'
],
config: {
title: 'Kategorier',
cls: 'categories',
indexBar: true,
itemTpl: '<h2 class="YrkesBenamning">{YrkesBenamning}</h2>',
onItemDisclosure: true,
store: {
autoLoad: true,
fields: ['YrkesId', 'YrkesBenamning', 'antal'],
grouper: {
groupFn: function(record) {
return record.get('YrkesBenamning')[0];
}
},
proxy: {
type: 'jsonp',
url: 'http://api.xxx.se/API.mvc/GetLillaGulaYrken?apikey=XXX',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
}
}
}
}
});
Kategorilista.png
When you click on an item to activate the function in my controller, see code below:
Code:
showCompany: function(list, index, element, record) {
var YrkesId = record.get('YrkesId');
console.log('id:' + YrkesId);
/*
*
* Here I want to send the ID number to the next view, how do I do that?
*
*/
var companylistView = new Ext.create('LG.view.companylist');
companylistView.setRecord(YrkesId);
Ext.Viewport.setActiveItem(companylistView);
}
KategoriVald.png
In this function I create also a new view called 'companlistView' and contains the following code below. Right now I manually added an ID number (10) for the JSON stream, such as: http://api.xxx.se/API.mvc/GetLillaGulaKunderByYrkeId/10?apikey=xxx
But I need to get the ID number automatically for each item when you select a category, how do I do that? Do you understand what I mean?
Code:
Ext.define('LG.view.companylist', {
extend: 'Ext.navigation.View',
xtype: 'companylist',
id: 'companyList',
requires: [
'Ext.dataview.List',
'Ext.data.proxy.JsonP',
'Ext.data.Store'
],
config: {
title: 'Sökresultat',
cls: 'companylist',
items: {
xtype: 'list',
//itemTpl: '<h2 class="KNamn">{KNamn}</h2><p class="KAdress"><a href="http://maps.apple.com/?q={KAdress}, {KPostNr} {KOrt}">{KAdress}<br>{KPostNr} {KOrt}</a></p>',
itemTpl: '<h2 class="KNamn">{KNamn}</h2>',
onItemDisclosure: true,
title: 'Sökresultat',
cls: 'categorylist',
store: {
autoLoad: true,
fields: ['PhoneNumber', 'KNamn', 'KId', 'KAdress', 'KOrt', 'KPostNr'],
proxy: {
type: 'jsonp',
url: 'http://api.xxx.se/API.mvc/GetLillaGulaKunderByYrkeId/10?apikey=xxx',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
}
}
}
}
}
});
Foeretag.png
The last view is printed by means of a push (). Code below:
Code:
showCompanyDetails: function(list, index, element, record) {
this.getCompanylist().push({
xtype: 'panel',
title: record.get('KNamn'),
html: '<p style="border:solid 1px red;"><a href="tel:' + record.get('PhoneNumber') + '">' + record.get('KNamn') + '<br>' + record.get('PhoneNumber') + '</a><p><p style="border:solid 1px green;"><a href="rmaps:ll=63.288303,18.70905">' + record.get('KAdress') + '<br>' + record.get('KPostNr') + ' ' + record.get('KOrt') + '</a><p>',
scrollable: true,
styleHtmlContent: true
});
}
Please help me!