shmoyko
25 Jun 2009, 5:21 AM
Hello all,
I've spent hours trying to find the solution to this one, but couldn't find it for whatever reason (possibly my ignorance regarding EXT).
Basically, I have a search field that takes a string. Clicking on the 'search' button produces a nice blue grid with the Paging Toolbar at the bottom. Clicking again on the 'search' button reproduces the results, but adds another paging Toolbar on top of the old one.
Here's the pic:
http://www.autorotation.org/temp/grid.jpg
And here's the code (JS and HTML):
<script type="text/javascript" src="ext-2.2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-2.2.1/ext-all-debug.js"></script>
<script type="text/javascript" src="js/RowExpander.js"></script>
<script language="javascript1.2" type="text/javascript">
Ext.onReady(function(){
var results;
var lastSearchText = '';
var btnSearch = Ext.get('btnSearch');
var inpSearchText = Ext.get('searchtext');
btnSearch.on('click', function(){
sendSearch(inpSearchText.getValue());
});
function sendSearch(text)
{
lastSearchText = text;
createDataStore(text);
}
function createDataStore(searchText)
{
var tmpStringURL = 'search.php?outputmode=json&searchtext='+searchText;
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: tmpStringURL
}),
reader: new Ext.data.JsonReader({
root: 'answers',
totalProperty: 'totalCount',
id: 'question_id',
fields: [
whatever ...
]
})
});
store.setDefaultSort('question_id', 'asc');
var cm = new Ext.grid.ColumnModel([
blah...
]);
cm.defaultSortable = true;
var pagination = new Ext.PagingToolbar({
pageSize: 25,
store: store,
displayInfo: true
});
var grid = new Ext.grid.GridPanel({
el:'grid',
width:700,
height:500,
title:'Blah',
store: store,
cm: cm,
sm: new Ext.grid.RowSelectionModel({selectRow:Ext.emptyFn}),
loadMask: true,
iconCls: 'icon-grid',
plugins: expander,
collapsible: true,
stripeRows: true,
bbar: pagination
});
grid.render();
store.load({params:{start:0, limit:25}});
}
function toggleDetails(btn, pressed){
var view = grid.getView();
view.showPreview = pressed;
view.refresh();
}
});
</script>
<link rel="stylesheet" type="text/css" href="ext-2.2.1/resources/css/ext-all.css" />
Search: <input type="text" id="searchtext" /><button id="btnSearch">Search</button>
<div id="grid">
</div>
Any ideas?
I've spent hours trying to find the solution to this one, but couldn't find it for whatever reason (possibly my ignorance regarding EXT).
Basically, I have a search field that takes a string. Clicking on the 'search' button produces a nice blue grid with the Paging Toolbar at the bottom. Clicking again on the 'search' button reproduces the results, but adds another paging Toolbar on top of the old one.
Here's the pic:
http://www.autorotation.org/temp/grid.jpg
And here's the code (JS and HTML):
<script type="text/javascript" src="ext-2.2.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-2.2.1/ext-all-debug.js"></script>
<script type="text/javascript" src="js/RowExpander.js"></script>
<script language="javascript1.2" type="text/javascript">
Ext.onReady(function(){
var results;
var lastSearchText = '';
var btnSearch = Ext.get('btnSearch');
var inpSearchText = Ext.get('searchtext');
btnSearch.on('click', function(){
sendSearch(inpSearchText.getValue());
});
function sendSearch(text)
{
lastSearchText = text;
createDataStore(text);
}
function createDataStore(searchText)
{
var tmpStringURL = 'search.php?outputmode=json&searchtext='+searchText;
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: tmpStringURL
}),
reader: new Ext.data.JsonReader({
root: 'answers',
totalProperty: 'totalCount',
id: 'question_id',
fields: [
whatever ...
]
})
});
store.setDefaultSort('question_id', 'asc');
var cm = new Ext.grid.ColumnModel([
blah...
]);
cm.defaultSortable = true;
var pagination = new Ext.PagingToolbar({
pageSize: 25,
store: store,
displayInfo: true
});
var grid = new Ext.grid.GridPanel({
el:'grid',
width:700,
height:500,
title:'Blah',
store: store,
cm: cm,
sm: new Ext.grid.RowSelectionModel({selectRow:Ext.emptyFn}),
loadMask: true,
iconCls: 'icon-grid',
plugins: expander,
collapsible: true,
stripeRows: true,
bbar: pagination
});
grid.render();
store.load({params:{start:0, limit:25}});
}
function toggleDetails(btn, pressed){
var view = grid.getView();
view.showPreview = pressed;
view.refresh();
}
});
</script>
<link rel="stylesheet" type="text/css" href="ext-2.2.1/resources/css/ext-all.css" />
Search: <input type="text" id="searchtext" /><button id="btnSearch">Search</button>
<div id="grid">
</div>
Any ideas?