PDA

View Full Version : Problems with DataView



spaff
22 Dec 2010, 7:29 AM
ExtJs: 3.3.1

I'm trying to fill a template in DataView, but i can't get it to work. I hope anyone can help me..



task.view = function(viewer, config) {
this.viewer = viewer;
Ext.apply(this, config);

this.store = new Ext.data.JsonStore({
url: urlLib.task.view,
root: 'data',
fields: [
{name: 'id'},
{name: 'subject', type: 'string', allowBlank: false},
{name: 'description', allowBlank: false},
{name: 'priority', allowBlank: false},
{name: 'due_date', type: 'date', allowBlank: true},
{name: 'done_at', type: 'date', allowBlank: true},
{name: 'category_id', allowBlank: true},
{name: 'author_id', allowBlank: true},
{name: 'created_at', type: 'date', allowBlank: true},
{name: 'updated_at', type: 'date', allowBlank: true},
{name: 'slug', allowBlank: true}
]
});

this.tpl = new Ext.XTemplate(
'<h1>Betreff: {subject}</h1>',
'<p>{description}</p>'
);
this.tpl.compile();

task.view.superclass.constructor.call(this, {

});
}

Ext.extend(task.view, Ext.DataView, {
loadView: function(id) {
this.store.baseParams = {
id: id
};

this.store.load();
console.log(this);
}
});

Ext.reg('apptaskview', task.view);
Call:

var record = grid.getStore().getAt(rowIndex);
var title = grid.formatRef(record.data.id);

view = new task.view(this, {});
view.loadView(record.data.id);

tabPanel.add({
title: title,
id: 'ctab_' + title,
closable: true,
items: [view]
}).show();


Responsedata:
{"data":[{"id":"121","subject":"test test test","description":null,"priority":"0","due_date":null,"done_at":null,"category_id":"2","author_id":"1","created_at":"2010-12-21 10:24:09","updated_at":"2010-12-21 10:24:09","slug":null}]}

The data is loaded into the store.

spaff
23 Dec 2010, 2:03 AM
no ideas?
I'm going crazy with this...

Condor
23 Dec 2010, 2:09 AM
1. Missing layout.

tabPanel.add({
title: title,
id: 'ctab_' + title,
closable: true,
layout: 'fit',
items: [view]
}).show();

2. Attach an 'exception' event handler to the store and see if it fires.

spaff
23 Dec 2010, 3:36 AM
Thank you for your answer, i added layout-prop and exception listener. There's no exception fired.

But i tried something new:

If i try refresh() the dataView firebug shows an error:

el is undefined
.../js/ext-3.3.1/ext-all-debug.js
Line 29054

maybe it helps figuring out my problem...

Condor
23 Dec 2010, 3:52 AM
Your 'tpl' is wrong. It's missing the <tpl for="."> tag and you need an element to use as itemSelector.

andredecotia
23 Dec 2010, 4:00 AM
I am facing a similar problem refresing DataView' store.

Condor
23 Dec 2010, 4:10 AM
You can only refresh a dataview after it has rendered (and rendered correctly - the above tpl is wrong).

spaff
23 Dec 2010, 7:52 AM
Thank you very, very much!
It works after adding tpl-tags to template.