aedos
29 Jan 2010, 5:02 PM
(ExtJs 3.1) I found this plugin very useful, but encountered two issues.
First, when the containing PagingToolbar has other explicit child items and has prependButtons set to true, the following code hides the wrong paging controls and inserts the slider into the wrong position:
Ext.each(pbar.items.getRange(2,6), function(c){
c.hide();
});
...
pbar.insert(5, slider);
I worked around it with:
var inputIndex = pbar.items.indexOf(pbar.inputItem);
Ext.each(pbar.items.getRange(inputIndex - 2, inputIndex + 2), function(c) {
c.hide();
});
...
pbar.insert(inputIndex + 1, pbar.slider);
Second, when the total page count changes but the current page index remains the same, the slider thumb remains at the wrong position. (This is a pretty common scenario for my app: after refresh the grid, the user needs to stay on the same page, but the total # of rows in the grid store may change.) I worked around it by adding the line in bold:
pbar.on({
change: function(pb, data) {
this.slider.maxValue = data.pages;
this.slider.setValue(data.activePage);
this.slider.syncThumb(); // force sync slider thumb when maxValue changes but value doesn't change
},
...
Could someone review the change above, and fix the issues in the base product? Thanks!
First, when the containing PagingToolbar has other explicit child items and has prependButtons set to true, the following code hides the wrong paging controls and inserts the slider into the wrong position:
Ext.each(pbar.items.getRange(2,6), function(c){
c.hide();
});
...
pbar.insert(5, slider);
I worked around it with:
var inputIndex = pbar.items.indexOf(pbar.inputItem);
Ext.each(pbar.items.getRange(inputIndex - 2, inputIndex + 2), function(c) {
c.hide();
});
...
pbar.insert(inputIndex + 1, pbar.slider);
Second, when the total page count changes but the current page index remains the same, the slider thumb remains at the wrong position. (This is a pretty common scenario for my app: after refresh the grid, the user needs to stay on the same page, but the total # of rows in the grid store may change.) I worked around it by adding the line in bold:
pbar.on({
change: function(pb, data) {
this.slider.maxValue = data.pages;
this.slider.setValue(data.activePage);
this.slider.syncThumb(); // force sync slider thumb when maxValue changes but value doesn't change
},
...
Could someone review the change above, and fix the issues in the base product? Thanks!