PDA

View Full Version : Desktop with SearchField not showing up



Craig.Warren
28 Sep 2009, 3:28 PM
I am using the Desktop and I am creating a window with a dataview. The dataview has a tbar with a SearchField. When I click on the Desktop Icon and Open the application, My SearchField does not show up.

Code:


MyDesktop.OpenSearch = Ext.extend(Ext.app.Module, {
id:'grid-win',
init : function(){
Myapp.ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
api: {read:{url: '/search/',method:'GET'}}
}),
reader: new Ext.data.JsonReader({
root: 'rows',
totalProperty: 'totalCount',
}, [
{name: 'summary', mapping: 'summary'},
{name: 'title', mapping:'title'},
{name: 'author', mapping:'author'},
{name: 'pubdate',mapping:'pubdate'},
]),
baseParams: {limit:10,pr:"DEFAULT",start:1}
});
Myapp.ds.setBaseParam('st','ILS|DIRECT');

Myapp.sf = new Ext.ux.form.SearchField({
store: Myapp.ds,
width:420
});
// Custom rendering Template for the View
var resultTpl = new Ext.XTemplate(
'<tpl for=".">',
'<div class="search-item"><b>Title:&nbsp;</b>',
'<a href="javascript:alert(\'I got nothing\');">{title}</a><br/>',
'<b>Author:&nbsp;</b>{author}<br/>',
'<b>Pub Date:&nbsp;</b>{pubdate}<br/>',
'<b>Summary</b><br/><div style=\"padding:0px 0px 0px 10px;\">{summary}</div>',
'</div></tpl>'
);

var myPageSize = Myapp.ds.baseParams['limit'];

Myapp.dv = new Ext.Panel({
title:'Search',
height:650,
autoScroll:true,
items: new Ext.DataView({
tpl: resultTpl,
store: Myapp.ds,
itemSelector: 'div.search-item'
}),
tbar: [
'Search: ', '',
Myapp.sf
],
bbar: new Ext.PagingToolbar({
store: Myapp.ds,
pageSize: myPageSize,
displayInfo: true,
displayMsg: 'Topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
})
});

this.launcher = {
text: 'Open Search Example',
iconCls:'icon-grid',
handler : this.createWindow,
scope: this
}
},

createWindow : function(){

var desktop = this.app.getDesktop();
var win = desktop.getWindow('grid-win');

var myPageSize =10;
if(!win){
win = desktop.createWindow({
id: 'grid-win',
title:'Open Search Example',
width:740,
height:480,
iconCls: 'icon-grid',
shim:false,
animCollapse:false,
constrainHeader:true,
layout: 'fit',
items:[Myapp.dv],
});
}
win.show();
}
});16485

but at the end of this code where it says win.show() if I comment that out and reload the page, when I click the icon, the window appears in on the taskbar, then I can open the window by clicking on it in the taskbar and then the SearchField is then shown.

16486

Then when I close the window (using the x in the upper right hand side of the window), and then reopen the window, not only is the SearchField gone, but the whole tbar is gone

16487

thanks in advance

arislaw
4 Oct 2009, 10:18 AM
I have the same problem and i cant figure out the solution. tks!

Craig.Warren
8 Oct 2009, 3:23 PM
Well I fixed it sort of, put in a HACK. After much debugging, I found that if I call win.show() later, it works So I delay that call with a settimeout(). Oh, and tbar being gone, I moved creating the Dataview panel inline. So instead of doing
Myapp.dv = new Ext.Panel({..});
I moved all that code into
desktop.createWindow so that everytime it creates a window it creates a new panel, instead of using
the previously created one, that gets destroyed when you close the window

So here is my new code
createWindow : function(){

var desktop = this.app.getDesktop();
win = desktop.getWindow('grid-win');

Myapp.myPageSize =10;
if(!win){
win = desktop.createWindow({
id: 'grid-win',
title:'Open Search Example',
width:740,
height:480,
iconCls: 'icon-grid',
shim:false,
animCollapse:false,
constrainHeader:true,
layout: 'fit',
items:[new Ext.Panel({
title:'Search',
height:650,
autoScroll:true,
items: new Ext.DataView({
tpl: Myapp.resultTpl,
store: Myapp.ds,
itemSelector: 'div.search-item'
}),
tbar: [
'Search: ', '',new Ext.ux.form.SearchField({
store: Myapp.ds,
width:420
})
],
bbar: new Ext.PagingToolbar({
store: Myapp.ds,
pageSize: Myapp.myPageSize,
displayInfo: true,
displayMsg: 'Topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
})
})],
});
}

Myapp.win = win;
// HACK, for some reason
setTimeout("Myapp.win.show()",300);
}

Jose Gonzalez
12 Oct 2009, 7:57 AM
There seems to be a problem using the Desktop and animation.

See http://www.extjs.com/forum/showthread.php?t=82450

I bet you dollars to donuts that your problems go away. I am deep into trying to figure out the why and I believe that it has to do with the animation callbacks being called too soon.