PDA

View Full Version : EmptyText for dataview ? how to ?



gabrielstuff
19 Oct 2010, 2:32 AM
Hello all,

I am trying to use empty text or at least to display conventiently something based on if the data are fetched or not.

It gives this :


Ext.ns('Ext.ux');
Ext.regModel('Event', {
fields: [{name: 'id', type: 'int'},
{name: 'title', type: 'string'},
{name: 'start', type: 'date', dateFormat: 'c'},
{name: 'eventdescription', type: 'string'}
]
});

Ext.ux.EventList = Ext.extend(Ext.Container, {
layout: {
type: 'vbox',
align: 'stretch'
},
scroll:'vertical',
cls:'pwc',
style:'background:#f7eae1;padding:0px 8px',
scroll: 'vertical',
cls: 'pwc',
layoutOnActivate: 'true',

initComponent : function() {
this.t_store = new Ext.data.Store({
autoLoad: true,
model: 'Event',
proxy: {
url: fluxout,
type: 'scripttag',
reader: {
root: 'data'
}
},
data:{
data: [
{
"id" : 0,
"title" : 0,
"eventdescription" : 0,
"start" : 0
}]
}
});

this.t_list = new Ext.List({
cls: 'pwc',
style:'background:#f7eae1',
emptyText: 'No data',
scroll:false,
itemSelector: '.event',
tpl: '<tpl for="."><tpl if="id!=0"><div class="event listdata"><h3>{start:date("d.m.y")} {title}</h3><p>{eventdescription}</p></div></tpl><tpl if="id==0"><p>foo</p><tpl></tpl>',
store: this.t_store
});

this.t_list.addListener("itemtap",this.onItemTapHandler);
this.addListener("beforeactivate",this.onDisplayCard);

this.items = [
this.t_list];

Ext.ux.EventList.superclass.initComponent.call(this);
},

onItemTapHandler: function(pDataView, pIndex, pItem, pEvent){
var obj = this.store.getAt(pIndex);
selectedEvent = obj.data;
onglets.Calendrier.fireEvent('navigation', onglets.EventDisplay, onglets.Calendrier);
},

onDisplayCard : function(pComponent) {
this.t_list.update();
/*
if (this.t_store.getCount() == 0)
{
var htmlStr = '<div class="spacer"></div><div class="box"><p>No data</p></div>';
this.update(htmlStr);
this.doLayout();
}*/

}
});

It give me no result... any help, would be greatly appreciate.

jay@moduscreate.com
19 Oct 2010, 9:30 AM
1) Do not develop your application using Ext.ux.
2) Do not use Scripttag for LOCAL data loads!

gabrielstuff
19 Oct 2010, 10:03 AM
Hi and thank you for this helpful reply.
1. I am not in local and have at least a server up and running.
2. ok, this is because I might encounter difficulties with future release or just a view of your mind ?

Thank you.

do you have any suggestion regarding template and default text when no data are loaded ?

jay@moduscreate.com
19 Oct 2010, 10:21 AM
Hi and thank you for this helpful reply.
1. I am not in local and have at least a server up and running.
2. ok, this is because I might encounter difficulties with future release or just a view of your mind ?

Thank you.

do you have any suggestion regarding template and default text when no data are loaded ?

2) It's an application design pattern conflict. Not just something that I am "thinking up".
1) look at your code. do you see the "data" property set in the store?

taht said, emptyTxt will not be displayed if your store does not attempt a request to load data.

gabrielstuff
19 Oct 2010, 10:26 AM
OK...
Well thanks again. What could I do then.
1. rename my extend
2. remove data in local as I am using scripttag ? What should I use instead ?
3. how to display the empty text or something if the store stay empty ?

thank you