ExtJS4: Passing parameters / properties from Treestore to Controller - extjs

I´m using a simple TreeStore without proxies for building my Menu. Here is a simple Example:
Store:
Ext.define('LT.store.MnuApplication', {
extend: 'Ext.data.TreeStore',
root: {
expanded: true,
children: [{
text: "Lists",
expanded: true,
children: [{
text: "Countries",
leaf: true,
}]
}]
}
});
In the controller I´ve added a listener to the "click" event:
Controller:
init: function() {
this.control({
/**
* Catch the treepanels in the menu accordion
*/
'menu-main treepanel': {
itemclick: function (view, record, item, index, event){
var clickedMnuNode = record;
var tabPanel = this.getTabPanel();
// Open tab only if the menu node is a leaf node
if (clickedMnuNode.isLeaf()) {
tabPanel.add({
xtype: clickedMnuNode.raw.loadTabComponent
}).show();
}
}
}
});
this.callParent();
}
And now to my problem with this solution: I want to define in the TreeStore, which actions should be done by the controller - especially which component should be loaded.
For example I would like that the TreeStore looks like this:
Ext.define('LT.store.MnuApplication', {
extend: 'Ext.data.TreeStore',
root: {
expanded: true,
children: [{
text: "Lists",
expanded: true,
children: [{
text: "Countries",
leaf: true,
loadComponent: 'country-list',
loadTarget: 'tabPanel'
}]
}]
}
});
As you can see I´ve added two new parameters to the Tree Leaf. Now I cann access those datasets via the "RAW" method of the record. But that´s not really a nice solution - isn´t it?
So has anyone an idea for me, how to pass additional parameters (like "loadComponent" or "loadTaget") from my TreeStore to the controller?
Thanks in advance & cheers,
Michael

In the past I created similar tree with my custom parameters and I used a custom model for my TreeStore. Because by default your node, just has properties of NodeInterface. Something like this:
Ext.define('TreeConfig.model.Config', {
extend: 'Ext.data.Model',
fields: ['properties', 'id', 'text', 'guid'],
proxy: {
type: 'ajax',
url: rootConfigURL,
actionMethods: 'POST',
reader: {
type: 'json'
}
}
});
Ext.define('TreeConfig.store.CurrentConfig', {
extend: 'Ext.data.TreeStore',
model: 'TreeConfig.model.Config',
requires: 'TreeConfig.model.Config',
root: {
text: 'Config root',
expanded: true,
properties: []
}
});

Related

ExtJs panel ViewModel getStore() call returns null instead of returning local ajax store object with URL bound to ViewModel data member

To reproduce this issue, I created a fiddle: https://fiddle.sencha.com/#view/editor&fiddle/3mk0 . The steps to reproduce are as follows:
Open your favorite browser and open the debugging tools to be able to view the JavaScript console
Navigate to the fiddle and run it
Double-click on a row - the grid is empty. Check the JS console: Uncaught TypeError: store is null (I used FF). The crux of the issue is that, in this line, let store = vm.getStore('testStore');, vm.getStore('testStore') returns null the first time. That's what I am trying to understand - why doesn't ExtJs initialize completely the ViewModel and the store, and instead it returns null. The problem is the binding in the url of the proxy. If the store doesn't have any binding in the url, it's going to work the first time as well.
Close the window, and double-click again on a row. This time the grid will show the data.
I know how to fix this - if I issue a vm.notify() before I set the store, it's going to work properly (I added a commented out line in the code).
Here is the source code from the fiddle:
app.js
/// Models
Ext.define('App.model.GroupRecord', {
extend: 'Ext.data.Model',
alias: 'model.grouprecord',
requires: [
'Ext.data.field.Integer',
'Ext.data.field.String'
],
fields: [{
type: 'int',
name: 'id'
}, {
type: 'string',
name: 'description'
}]
});
Ext.define('App.model.SomeRecord', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.field.Integer',
'Ext.data.field.String'
],
fields: [{
type: 'int',
name: 'id'
}, {
type: 'string',
name: 'description'
}, {
type: 'int',
name: 'groupId'
}]
});
//// SomeGridPanel
Ext.define('App.view.SomeGridPanel', {
extend: 'Ext.grid.Panel',
alias: 'widget.somegridpanel',
requires: [
'App.view.SomeGridPanelViewModel',
'App.view.SomeGridPanelViewController',
'Ext.view.Table',
'Ext.grid.column.Number'
],
controller: 'somegridpanel',
viewModel: {
type: 'somegridpanel'
},
bind: {
store: '{testStore}'
},
columns: [{
xtype: 'numbercolumn',
dataIndex: 'id',
text: 'ID',
format: '0'
}, {
xtype: 'gridcolumn',
dataIndex: 'description',
text: 'Description'
}]
});
Ext.define('App.view.SomeGridPanelViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.somegridpanel',
requires: [
'Ext.data.Store',
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json'
],
data: {
groupId: null
},
stores: {
testStore: {
model: 'App.model.SomeRecord',
proxy: {
type: 'ajax',
url: 'data1.json?groupId={groupId}',
reader: {
type: 'json'
}
}
}
}
});
Ext.define('App.view.SomeGridPanelViewController', {
extend: 'Ext.app.ViewController',
alias: 'controller.somegridpanel',
onRefresh: function (groupId) {
console.log('calling the grid panel onrefresh for groupId: ' + groupId);
let vm = this.getViewModel();
console.log(vm);
vm.set('groupId', groupId);
//vm.notify(); // <- uncomment this line to make it work properly
let store = vm.getStore('testStore');
//tore.proxy.extraParams.groupId = groupId;
store.load();
}
});
// TestWindow
Ext.define('App.view.TestWindow', {
extend: 'Ext.window.Window',
alias: 'widget.testwindow',
requires: [
'App.view.TestWindowViewModel',
'App.view.TestWindowViewController',
'App.view.SomeGridPanel',
'Ext.grid.Panel'
],
controller: 'testwindow',
viewModel: {
type: 'testwindow'
},
height: 323,
width: 572,
layout: 'fit',
closeAction: 'hide',
bind: {
title: '{title}'
},
items: [{
xtype: 'somegridpanel',
reference: 'someGrid'
}]
})
Ext.define('App.view.TestWindowViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.testwindow',
data: {
title: 'Test Window'
}
});
Ext.define('App.view.TestWindowViewController', {
extend: 'Ext.app.ViewController',
alias: 'controller.testwindow',
listen: {
controller: {
'*': {
loadData: 'onLoadData'
}
}
},
onLoadData: function (groupRecord) {
console.log('Loading data...');
console.log(groupRecord);
let vm = this.getViewModel();
vm.set('title', 'Group: ' + groupRecord.get('description'));
this.lookup('someGrid').getController().onRefresh(groupRecord.get('id'));
}
});
// ViewPort
Ext.define('App.view.MainViewport', {
extend: 'Ext.container.Viewport',
alias: 'widget.mainviewport',
requires: [
'App.view.MainViewportViewModel',
'App.view.MainViewportViewController',
'Ext.grid.Panel',
'Ext.view.Table',
'Ext.grid.column.Number'
],
controller: 'mainviewport',
viewModel: {
type: 'mainviewport'
},
height: 250,
width: 400,
items: [{
xtype: 'gridpanel',
title: 'Main Grid - double-click on a row',
bind: {
store: '{groupRecords}'
},
columns: [{
xtype: 'numbercolumn',
dataIndex: 'id',
text: 'Group id',
format: '00'
}, {
xtype: 'gridcolumn',
flex: 1,
dataIndex: 'description',
text: 'Group'
}],
listeners: {
rowdblclick: 'onGridpanelRowDblClick'
}
}]
});
Ext.define('App.view.MainViewportViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.mainviewport',
requires: [
'Ext.data.Store',
'Ext.data.proxy.Memory'
],
stores: {
groupRecords: {
model: 'App.model.GroupRecord',
data: [{
id: 1,
description: 'Group 1'
}, {
id: 2,
description: 'Group 2'
}, {
id: 3,
description: 'Group 3'
}, {
id: 4,
description: 'Group 4'
}, {
id: 5,
description: 'Group 5'
}],
proxy: {
type: 'memory'
}
}
}
});
Ext.define('App.view.MainViewportViewController', {
extend: 'Ext.app.ViewController',
alias: 'controller.mainviewport',
onGridpanelRowDblClick: function (tableview, record, element, rowIndex, e, eOpts) {
if (!this._testWindow) {
this._testWindow = Ext.create('widget.testwindow');
}
this._testWindow.show();
this.fireEvent('loadData', record);
}
});
Ext.application({
//name : 'Fiddle',
models: [
'SomeRecord',
'GroupRecord'
],
views: [
'MainViewport',
'TestWindow',
'SomeGridPanel'
],
name: 'App',
launch: function () {
Ext.create('App.view.MainViewport');
}
});
}
data1.json:
function(params, req, Fiddle) {
var range = [];
for (var i = 1; i <= 50; i++) {
var obj = {
id: i,
description: `Item ${i}`,
groupId: Math.floor( (i - 1) / 10) + 1
}
range.push(obj);
}
let allData = range.filter(it => it.groupId === params.groupId )
//console.log(params);
//console.log(req);
return allData;
}
The code is a bit contrived but it follows an issue (though not identical) I had in the real app. In the real app I have a weird intermittent issue, where I have a complex form with subcomponents, and a vm.notify() call made in a subcomponent, fires a method bound to a ViewModel data member (in other words it fires when that data member changes), which in turn tries to refresh a local store in another subcomponent but this subcomponent's ViewModel getStore() call returns null. The proxy of that store has the url property bound to a ViewModel data member. That's the common pattern. It seems to me that stores with proxies that have the url property bound to a ViewModel data property (ex: url: 'data1.json?groupId={groupId}') are not initialized properly by the time the form is rendered, and eventually, after some ViewModel computation cycles, they get initialized finally.
TIA
Update: There was a question below whether the url attribute of the proxy is bindable. I think it is bindable. Sencha Architect shows it as bindable, though, when enabled, it doesn't place the property in a bind object.
I did search the ExtJs 7.6.0 code base for samples where the {...} expressions are used in the url attribute, and I stumbled upon this test case:
packages\core\test\specs\app\ViewModel.js from line 7237:
describe("initial", function() {
it("should not create the store until a required binding is present", function() {
viewModel.setStores({
users: {
model: 'spec.User',
proxy: {
type: 'ajax',
url: '{theUrl}'
}
}
});
notify();
expect(viewModel.getStore('users')).toBeNull();
setNotify('theUrl', '/foo');
var store = viewModel.getStore('users');
expect(store.isStore).toBe(true);
expect(store.getProxy().getUrl()).toBe('/foo');
});
it("should wait for all required bindings", function() {
viewModel.setStores({
users: {
model: 'spec.User',
proxy: {
type: 'ajax',
url: '{theUrl}',
extraParams: {
id: '{theId}'
}
}
}
});
notify();
expect(viewModel.getStore('users')).toBeNull();
setNotify('theUrl', '/foo');
expect(viewModel.getStore('users')).toBeNull();
setNotify('theId', 12);
var store = viewModel.getStore('users');
expect(store.isStore).toBe(true);
expect(store.getProxy().getUrl()).toBe('/foo');
expect(store.getProxy().getExtraParams().id).toBe(12);
});
});
What is interesting is that it is expected in the test that viewmodel getStore would return null before setting the value for theUrl: expect(viewModel.getStore('users')).toBeNull(); !
Maybe it is by design...
Reason for the issue is - triggered event listener is getting executed before the View Model is initialised and grid is rendered
We can use following approach to fix these issues
Add delay before triggering the event
Listen for initViewModel method in controller and then load the store
Or add afterrender event on the grid, read its store and then load it
// Add delay to ensure view model is initialized
Ext.defer(function() {
this.fireEvent('loadData', record);
}, 1000, this);
There is a override function called "init" in each controller so use your initial code in this function. This function invokes every time when UI refresh/added new.
Example:
init: function() {
var vm = this.getViewModel();
var store = vm.data.myCurrentStore;
store.load();
}

How to call other view in Sencha Touch

How can I call a new view on image tap which is defined in tpl.
Code:
tpl: Ext.create('Ext.XTemplate','<tpl for="sample">',
'<div> {tittle}</div>
<div><img src="{photo}"/></div>',
'</tpl>',
/////////////////////////////////////////
After your directions, I'm sure I have something wrong. I just want to know how to link an image to puncture it take you to another view. Let me explain better?
Thank you very much for your time and dedication.
//MyController
Ext.define('DemoApp.controller.ControllerR', {
extend: 'Ext.app.Controller',
config: {
refs: {
res: 'res',
},
control: {
'rest list': {
itemtap: 'showR' },
}
},
onCreateNewView: function() {
if(document.getElementById('something')) {
Ext.Viewport.setActiveItem(Ext.create('DemoApp.view.DetalTwo'));
}
},
});
//My Template
Ext.define('DemoApp.view.ViewR', {
extend: 'Ext.Panel',
xtype: 'res',
config: {
title: 'Res',
iconCls: 'info',
scrollable: true,
data: {
res: [ model: 'DemoApp.model.ModelR',
autoLoad: true,
storeId: 'resStore',
proxy: {
type: 'ajax',
url: 'data/res.json',
reader: {
type: 'json',
rootProperty:'wha.res'
}
}]
},
tpl: Ext.create('Ext.XTemplate','<tpl for="sample">',
'<div> {tittle}</div>
<div><img id="something "src="{photo}"/></div>',
'</tpl>',
{
join: function(value) {
return value.join(', ');
}
})
}
});
You can give an id to image tag i.e. <img id = "something"/> and if tpl is defined for list then go to that list's handling function in controller or in view(where you defined a list and listeners) and write this code:
if(document.getElementById('Your img tag id')) {
// create a view and active it
}
For Example:
onCreateNewView: function() {
if(document.getElementById('something')) {
Ext.Viewport.setActiveItem(Ext.create('DemoApp.view.NewView'));
}
}
First thing first... you should do some google before putting such question in Stack.Your Code is totally wrong as well as it contains major syntax errors. And we are not here to solve some stupid syntax errors.Anyways Let me explain something..
1.) In your controller you are trying to bind 'itemtap' event.You can only bind 'itemtap' event if there is a list in your view. Here, in your case there is no list.
2.) And in controller it's look like something this:
refs: {
imageList: '#imageList',
},
control: {
'imageList': {
itemtap: 'onCreateNewView'
},
}
3.) Create a list in your view:
config: {
items: [
{
xtype: 'list',
id: 'imageList',
itemId: 'imageList',
tpl:'Your tpl code'
}
]
}

Sencha Touch 2.3.0 NestedList doesn't display child items when tapping but only root items

Update:
Demo of the problem
I'm pretty new to Sencha Touch and am trying to get a NestedList working.
I've set up two model files, a store with an ajax proxy that loads a local json file and the view containing the NestedList.
The NestedList displays the root elements from my json file, so that's all working so far.
But when I click on one of those items, it animates the view but the resulting list is only showing the parent items again, but this time with a back button in the titlebar:
I really don't get what I am doing wrong here.
JSON (compact)
{
"countries":[
{"name":"Germany","countryCode":"de","cities":[
{"name":"Berlin"},{"name":"Muenchen"}]},
{"name":"France","countryCode":"fr","cities":[
{"name":"Paris"},{"name":"Lyon"}]},
{"name":"United Kingdom","countryCode":"uk","cities":[
{"name":"London"},{"name":"Leicester"}]}]
}
Models
City:
Ext.define('MyApp.model.City', {
extend: 'Ext.data.Model',
config: {
fields: [{ name: 'name', type: 'string' }]
}
});
Country:
Ext.define('MyApp.model.Country', {
extend: 'Ext.data.Model',
require: [
"MyApp.model.City"
],
config: {
fields: [
{ name: 'name', type: 'string' },
{ name: 'countryCode', type: 'string' }
],
hasMany: [{ model: "MyApp.model.City", name: "cities" }]
},
});
TreeStore
Ext.define('MyApp.store.CountryTreeStore', {
extend: 'Ext.data.TreeStore',
config: {
autoLoad: true,
model: "MyApp.model.Country",
defaultRootProperty: "countries",
proxy: {
type: "ajax",
url: "/data/data.json",
reader: {
type: "json"
}
}
}
});
part from the view
items: [
{
xtype: 'nestedlist',
store: "CountryTreeStore",
displayField: "name"
}
]
Update:
Setting a breakpoint in the load event listener of the TreeStore (proxy) and inspecting the "loaded" store object shows, that it has a cities property with the correct data.
hm I've tried to refactor your problem. When I set the key "cities" in the json to "countries", or the same key from the previous level, it seems to work. So it's your "hasMany"-relation which is not working. I've never tried to do it this way. So when you remove the "hasMany"-relation, and change the json to this, it will work:
[{
"countries":[
{"name":"Germany","countryCode":"de","countries":[
{"name":"Berlin", leaf: true},{"name":"Muenchen", leaf: true}]},
{"name":"France","countryCode":"fr","countries":[
{"name":"Paris", leaf: true},{"name":"Lyon", leaf: true}]},
{"name":"United Kingdom","countryCode":"uk","countries":[
{"name":"London", leaf: true},{"name":"Leicester", leaf: true}]}]
}]
and with "leaf: true" you can listen to the "leafitemtap" event, to do something when you reach the end of the tree.
Where have you found the example with the "hasMany"-relation? Maybe there's just a little thing missing ;)
have you tried to set leaf: true on the last item level? {"name":"Muenchen", "leaf": true}

Get an Ext.dataview.List instance to show up inside of an Ext.tab.Panel instance

I cannot figure out how to show my Ext.dataview.List object inside of another object. If I try to show the Ext.dataview.List object in the viewport, by itself, I can see my data. But if I try to include it as a component inside of another component, it thinks there is no data (judging from the HTML output), and doesn't appear to display anything.
So, if I have an app.js with the following code:
Ext.application({
name: 'MobileUnion',
views: ['LocalsList'],
models: ['Local'],
stores: ['Locals'],
launch: function() {
// Initialize the main view
var mainView = {
xtype: 'localslist'
};
Ext.Viewport.add([mainView]);
}
});
I can set up MobileUnion.view.LocalsList this way, which results in no list:
Ext.define('MobileUnion.view.LocalsList', {
extend: 'Ext.Container',
alias: 'widget.localslist',
requires: 'Ext.dataview.List',
config: {
items: [
{
itemId: 'localsList',
store: 'Locals',
loadingText: 'Loading Locals...',
emptyText: '<div>No locals found.</div>',
onItemDisclosure: true,
itemTpl: '<div>{localName}</div><div>{designation}</div>'
}
]
}
});
Or, I can set it up this way, which results in a populated list, but not inside of another component:
Ext.define('MobileUnion.view.LocalsList', {
extend: 'Ext.dataview.List',
alias: 'widget.localslist',
config: {
itemId: 'localsList',
store: 'Locals',
loadingText: 'Loading Locals...',
emptyText: '<div>No locals found.</div>',
onItemDisclosure: true,
itemTpl: '<div>{localName}</div><div>{designation}</div>'
}
});
The reason I am trying to pull this off is so that I can get a list component to display inside of a tab panel.
Note: I have assembled a Fiddle with everything, here: http://www.senchafiddle.com/#6nCH8
I must be missing something basic, but at this point, having gone through the documentation, and purchased two books, one of which I've read fully, and the other of which I am reading while coding, I am still without an answer. Any help would be most greatly appreciated.
Additional Code
app/model/Local.js
Ext.define('MobileUnion.model.Local', {
extend: 'Ext.data.Model',
config: {
idProperty: 'id',
fields: [
{ name: 'id', type: 'int' },
{ name: 'dateCreated', type: 'date', dateFormat: 'c' },
{ name: 'localName', type: 'string' },
{ name: 'designation', type: 'string' }
],
}
});
app/store/Locals.js
Ext.define('MobileUnion.store.Locals', {
extend: 'Ext.data.Store',
requires: ['MobileUnion.model.Local'],
config: {
model: 'MobileUnion.model.Local',
data: [
{ localName: 'ABCD', designation: '123' },
{ localName: 'WXYZ', designation: '456' }
],
autoLoad: true,
sorters: [{ property: 'dateCreated', direction: 'DESC'}]
}
});
In option 1, you define a container but you actually don't add items to you container. To add your list to the container, add xtype: 'list' to your items array. Next thing you have to do is to set the containers layout to fit, otherwise the list won't show up. This should work for you:
Ext.define('MobileUnion.view.LocalsList', {
extend: 'Ext.Container',
alias: 'widget.localslist',
requires: 'Ext.dataview.List',
config: {
layout: {
type: 'fit' //set containers layout
},
items: [
{
xtype: 'list', //add xtype
itemId: 'localsList',
store: 'Locals',
loadingText: 'Loading Locals...',
emptyText: '<div>No locals found.</div>',
onItemDisclosure: true,
itemTpl: '<div>{localName}</div><div>{designation}</div>'
}
]
}
});
More about layouts in Sencha: http://docs.sencha.com/touch/2-1/#!/guide/layouts
Good luck!

EXTJS MVC Tree store

Am having a tree view which gets its data from the tree store. But, however, am able to see only the small folders that gets displayed as part of a tree structure. the name of the nodes is not getting displayed, and when i try to print the record, it just says that its an empty string. Here is the code:
App/View
Ext.define('App.view.Hierarchy', {
alias: 'widget.hierarchy',
extend: 'Ext.panel.Panel',
initComponent: function () {
var config = {
xtype: 'panel',
border: false,
autoScroll: true,
baseCls: 'topMenu',
html: '<div class="PageTitle" style="width:600px;"><b>' + LANG.HIERARCHYT + '</b><br>' + LANG.HIERARCHYTxt + '<br>' + '</div>',
items: [{
xtype: 'toolbar',
border: false,
dock: 'top',
items: [{
xtype: 'button',
text: LANG.BTADDREG,
iconCls: 'icon-add-tb',
cls: 'tip-btn',
iconAlign: 'right',
action: 'addRegion',
id: 'ADDREGION'
}]
},
{
xtype: 'treepanel',
title: 'Hierarchy Tree',
id: 'hierarchyTree',
border: false,
alias: 'widget.hierarchyTree',
height: 1000,
viewConfig: {
enableDD: true,
plugins: {
ptype: 'treeviewdragdrop'
}
},
collapsible: false,
useArrows: true,
rootVisible: false,
store: Ext.create('Campus.store.HierarchyTree'),
displayField: 'Title',
multiSelect: false,
singleExpand: false,
}]
}
var holder = Ext.getCmp('center');
holder.remove(0);
holder.add(Ext.apply(config));
this.callParent(arguments);
}
});
Model
Ext.define('App.model.HierarchyTree', {
extend : 'Ext.data.Model',
fields : ['Title', 'ID', 'LevelID', 'ParentID']
});
Store
Ext.define('App.store.HierarchyTree', {
extend: 'Ext.data.TreeStore',
model: 'App.model.HierarchyTree',
storeID: 'HierarchyTree',
proxy: {
type: 'ajax',
url: 'data/Locations.aspx',
reader: {
},
actionMethods: {
create: 'POST',
read: 'POST',
update: 'POST'
},
extraParams: {
mode: 'HIERARCHYFULLLIST'
}
},
autoLoad: true
});
Controller
Ext.define('App.controller.Hierarchy', {
extend: 'Ext.app.Controller',
stores: ['Me', 'Regions', 'Areas', 'Towns', 'HierarchyTree'],
model: ['Me', 'Teams', 'Regions', 'User', 'HierarchyTree'],
views: ['App.view.Hierarchy', 'App.view.AddRegions'],
refs: [{
ref: 'myHierarchyTree',
selector: 'hierarchyTree'
}],
init: function () {
this.getHierarchyTreeStore().load();
this.control({
'button[action=addRegion]': {
click: this.addRegion
},
'#hierarchyTree': {
itemclick: this.itemclick
}
})
},
itemclick: function (view, record) {
console.log(record.get('Title'))
}
});
Also, the JSON thats being returned is:
{"text":".","children": [{"text":"Asia Pacific","id":"537","level":"1", "expanded":
false,"singleClickExpand":true,"children":[{"text":"Japan", "cls":"xtreenode-Level2-
Indent", "id":"538", "hl1":"537","level":"2","singleClickExpand":true, "expanded":
false, "children":[]},
Treepanel's display field defaults to text, which is ok with the json being returned, but the problem is the store model, which should include as fields the text, cls ..and other attributes you have in your json. Otherwise these will not be mapped to the records and you get empty text.
Ext.define('App.model.HierarchyTree', {
extend : 'Ext.data.Model',
fields : ['Title', 'ID', 'LevelID', 'ParentID', 'text', 'level','cls,....]
EDIT
You have modified the displayField to be the Title, but the json doesn't contain the title attribute. You have to simple fixes, either you modify the model if the text is actually the title. You can do this by setting a mapping to the field.
Ext.define('App.model.HierarchyTree', {
extend : 'Ext.data.Model',
fields : [{name:'Title',type:'string',mapping:'text'}, 'ID', 'LevelID', 'ParentID',]
This will cause the Title to be populated by the text values from the json.
Also you can remove the displayField config and then the text value will be applied, but this will still mean that the 'Title' value will be empty.
OK, finally got it:)
Set the displayfield in the tree to 'text'
displayfield : 'text'
And, Once again thank you nscrob
And one more question, could you please give me any guidance on how to open different views depending upon the level in the tree that is being clicked
This works.
if (record.get('level')==1)
{
this.erWin = Ext.create('App.view.EditRegions');
this.erWin.showWin();
}
else{
//open another_view
}

Resources