Bug #8
Pagination not working..
| Status : | Closed | Start : | 03/03/2008 | |
| Priority : | Normal | Due date : | ||
| Assigned to : | Davide D'Agostino | % Done : | 100% |
|
| Category : | - | Spent time : | - | |
| Target version : | 0.9 | |||
Description
Pagination does not seem to work..
When you go to the next page the content of the grid does not update.
Article counting, pagenumbers, and everything else works fine. But grid is not updated.. Bug is confirmed in both my own project and in the demo.
I've added tons of articles to http://demoadmin.lipsiasoft.org/admin so you can check for yourself.
History
03/03/2008 04:06 PM - Davide D'Agostino
Thanks so much Gabrio,
at the moment yes pagination is not implemented yet, in the next relase will be aviable.
03/07/2008 12:15 PM - Gabrio gabs
Just wanted to let you know that I almost have it working myself..
Just have to figure out where you assign the item Total to the pagination control. The one in the controller is overridden somewhere..
Let me know if you want the code..
03/07/2008 12:18 PM - Davide D'Agostino
Ok, thanks
I followed this code http://rails.lipsiasoft.com/boards/1/topics/show/8 posted by Philippe is also right for u?
03/07/2008 01:14 PM - Gabrio gabs
aah, haven't seen that one I'll check it out.
I used this ext_scaffold generator as a base for my fix:
03/11/2008 12:42 AM - Anonymous
The following is a fix for the search if you follow the implementation of: http://rails.lipsiasoft.com/boards/1/topics/show/8
Inside your controller add something like, you could also use Sphinx or Ferret, but they require gem installed. This is just an example with using one column....
query = (params[:query] || nil)
if query.nil? || query.length == 0 then
@users = User.paginate :page => page, :order => sort, :per_page => size
else
@users = User.paginate :all, :conditions => [ 'email LIKE ?' , "%#{query}%" ],
:page => page, :order => sort, :per_page => size
end
return_data = Hash.new()
- Use the total_entries of the Paginate object returned result for the count
- This replaces User.count
return_data[:Total] = @users.total_entries
And I changed the search-field.js code to the one used by the original ExtJS developers in an example (http://extjs.com/), this will work out of the box with the changes in the controller. This can probably be tweaked a little more, but it works for me.
/*
* Ext JS Library 2.0.2
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/
Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
initComponent : function(){
Ext.app.SearchField.superclass.initComponent.call(this);
this.on('specialkey', function(f, e){
if(e.getKey() == e.ENTER){
this.onTrigger2Click();
}
}, this);
},
validationEvent:false,
validateOnBlur:false,
trigger1Class:'x-form-clear-trigger',
trigger2Class:'x-form-search-trigger',
hideTrigger1:true,
width:180,
hasSearch : false,
paramName : 'query',
onTrigger1Click : function(){
if(this.hasSearch){
this.el.dom.value = '';
var o = {start:0, limit:100};
this.store.baseParams = this.store.baseParams || {};
this.store.baseParams[this.paramName] = '';
this.store.load({params:o});
this.triggers[0].hide();
this.hasSearch = false;
}
},
onTrigger2Click : function(){
var v = this.getRawValue();
if(v.length < 1){
this.onTrigger1Click();
return;
}
var o = {start:0, limit:100};
this.store.baseParams = this.store.baseParams || {};
this.store.baseParams[this.paramName] = v;
this.store.reload({params:o});
this.hasSearch = true;
this.triggers[0].show();
}
});