PDA

View Full Version : [INFOREQ] [EXT JS 5.0.0] : When I use scrollTo with the plugin bufferedrender I've a random err



kbenkhalifa
23 Sep 2014, 7:35 AM
Hello,

I use a grid with plugin bufferedrender.
In some cases, after the reconfigure event was launched, I execute scrollTo function to go to my row like this :


goToRowByModel : function(model, scroll) {
var me = this,
texteborderNorthGrid = Ext.ComponentQuery.query('#textegrid')[0];


if(texteborderNorthGrid) {
texteborderNorthGrid.getSelectionModel().select(model);
if(scroll) {
indexSelectedRow = texteborderNorthGrid.getStore().indexOf(texteborderNorthGrid.getSelectionModel().getSelection()[0]);
texteborderNorthGrid.getPlugin('texteGridBufferedRenderer').scrollTo(indexSelectedRow,false);
}
}

},


Sometimes I have this error : Uncaught TypeError: Cannot read property 'el' of null ext-all-debug.js:17260

if I look the code at that line I have :





getOffsetsTo: function(offsetsTo) {
var o = this.getXY(),
e = Ext.fly(offsetsTo.el || offsetsTo).getXY();
return [o[0] - e[0],o[1] - e[1]];
}

It seems that offsets is null at that moment.

Regards

mitchellsimoens
23 Sep 2014, 9:18 AM
Can I get a test case so I can see when you are executing things?

kbenkhalifa
24 Sep 2014, 4:56 AM
I have created a fiddle example but it works. If I can send to you a movie record of my app you can see that it doesn't works for me, but I do the same things of my fiddle.

Fiddle : https://fiddle.sencha.com/#fiddle/aqi

kbenkhalifa
24 Sep 2014, 8:42 AM
In the scrollTo method of BufferedRenderer, I found the line which returns null for offsetsTo argument of getOffsetTO method:


scrollTo: function(recordIdx, doSelect, callback, scope) {
var me = this,
view = me.view,
viewDom = view.el.dom,
store = me.store,
total = store.getCount(),
startIdx, endIdx,
targetRec,
targetRow,
tableTop,
groupingFeature,
group,
record;


// If we have a grouping summary feature rendering the view in groups,
// first, ensure that the record's group is expanded,
// then work out which record in the groupStore the record is at.
if ((groupingFeature = view.dataSource.groupingFeature) && (groupingFeature.collapsible !== false)) {


// Sanitize the requested record
recordIdx = Math.min(Math.max(recordIdx, 0), view.store.getCount() - 1);
record = view.store.getAt(recordIdx);
group = groupingFeature.getGroup(record);


if (group.isCollapsed) {
groupingFeature.expand(group.getGroupKey());
total = store.getCount();
}


// Get the index in the GroupStore
recordIdx = groupingFeature.indexOf(record);


} else {


// Sanitize the requested record
recordIdx = Math.min(Math.max(recordIdx, 0), total - 1);
}


// Calculate view start index
startIdx = Math.max(Math.min(recordIdx - (Math.floor((me.leadingBufferZone + me.trailingBufferZone) / 2)), total - me.viewSize + 1), 0);
tableTop = Math.max(startIdx * me.rowHeight - me.tableTopBorderWidth, 0);
endIdx = Math.min(startIdx + me.viewSize - 1, total - 1);


store.getRange(startIdx, endIdx, {
callback: function(range, start, end) {


me.renderRange(start, end, true);


targetRec = store.data.getRange(recordIdx, recordIdx + 1)[0];
targetRow = view.getNode(targetRec); // It returns null...

// tableTop property must track the translated position of the body
view.body.translate(null, me.bodyTop = tableTop);
me.position = me.scrollTop = tableTop = Math.min(Math.max(0, tableTop - view.body.getOffsetsTo(targetRow)[1]), viewDom.scrollHeight - viewDom.clientHeight);
view.setScrollY(tableTop);


// https://sencha.jira.com/browse/EXTJSIV-7166 IE 6, 7 and 8 won't scroll all the way down first time
if (Ext.isIE) {
view.setScrollY(tableTop);
}
if (doSelect) {
view.selModel.select(targetRec);
}
if (callback) {
callback.call(scope||me, recordIdx, targetRec);
}
}
});
},

kbenkhalifa
24 Sep 2014, 11:02 PM
I add an example and the code which cause problem. Can you help me to understand why ?