PDA

View Full Version : Hello friends, I am having difficulty working with the component Treview



isilva73
27 Sep 2011, 5:50 AM
Hello friends, I am having difficulty working with the component Treview, I am sending a json file to load the page but it returns the following error, "is undefined c.tpl
Source file: http://localhost:8080/webdip/js/ext4/ext-all.js
Line: 15, "someone could answer me what this error, I look back. Thank you.

below is the file json

ext': '.','children': {'codigo': '0','descricaoCorte': 'NODE RAIZ','rendimento': '0','leaf': false, iconCls:'task-folder', 'expanded': true,
'children': [{'codigo': '100','descricaoCorte': 'CORTE 100','rendimento': '1.00','leaf': false,iconCls:'task-folder','expanded': true,
'children': [{'codigo': '110','descricaoCorte': 'CORTE 110','rendimento': '1.00','leaf': true,iconCls:'task']}]}}}


code html


Ext.require([
'Ext.data.*',
'Ext.grid.*',
'Ext.tree.*'
]);

Ext.onReady(function() {
//we want to setup a model and store instead of using dataUrl
Ext.define('Task', {
extend: 'Ext.data.Model',
fields: [
{name: 'codigo', type: 'string'},
{name: 'descricaoCorte', type: 'string'},
{name: 'rendimento', type: 'string'}
]
});

var store = Ext.create('Ext.data.TreeStore', {
model: 'Task',
proxy: {
type: 'ajax',
//the store will get the content from the .json file
url: '/webdip/js/ext4/examples/tree/treegrid2.json'
// url: '/pcp/paramRendimento/listaParametros.json'
},
folderSort: true
});

//Ext.ux.tree.TreeGrid is no longer a Ux. You can simply use a tree.TreePanel
var tree = Ext.create('Ext.tree.Panel', {
title: 'Ítens - Rendimento do Abate',
width: 500,
height: 300,
renderTo: Ext.getBody(),
collapsible: true,
useArrows: true,
rootVisible: false,
store: store,
multiSelect: true,
singleExpand: true,
//the 'columns' property is now 'headers'
columns: [{
xtype: 'treecolumn', //this is so we know which column will show the tree
text: 'codigo',
flex: 2,
sortable: true,
dataIndex: 'Produto'
},{
//we must use the templateheader component so we can use a custom tpl
xtype: 'templatecolumn',
text: 'descricaoCorte',
flex: 1,
sortable: true,
dataIndex: 'descricao',
align: 'center'
},{
text: '% Rendimento',
flex: 1,
dataIndex: 'rendimento',
sortable: true
}]
});
});


tanks.

skirtle
28 Sep 2011, 12:57 AM
Please use CODE tags when posting code (# button on the editor toolbar).

The JSON you posted is a long way from being valid JSON. However, I suspect it isn't the cause of this particular error. I suggest you run your JSON through a validator anyway.

I'd also suggest that you use ext-all-debug.js rather than ext-all.js for debugging. That way you get meaningful line numbers, stacktraces and can use breakpoints.

Your second column is a templatecolumn but doesn't specify a template. I would image that's why you're getting this error.