PDA

View Full Version : [FIXED-507][3.1] SlidingPager plugin bugs



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!

evant
31 Jan 2010, 3:04 PM
I can confirm the first issue, but could you post a test case for the second?

For example, using this sample code:



Ext.onReady(function(){
var s = new Ext.Slider({
width: 200,
renderTo: document.body,
value: 10,
minValue: 0,
maxValue: 20,
animate: false
});

new Ext.Button({
renderTo: document.body,
text: 'a',
handler: function(){
s.maxValue = 9;
s.setValue(10);
}
});
});


The thumb moves after the setValue() call.

aedos
1 Feb 2010, 11:18 PM
Hi Evan,

Thanks for looking into this so quickly. I believe you can reproduce the issue with a slight change to your example:

Change
s.maxValue = 9; to
s.maxValue = 15;It wasn't reproducible with the original example because the value (10) was beyond the maxValue (9), so it was normalized to a different value.

evant
3 Feb 2010, 6:42 PM
A fix was added to SVN.

aedos
3 Feb 2010, 7:02 PM
Thanks!