简体   繁体   中英

EXTJS 6 Modern: buffered store + grid: Uncaught TypeError: Cannot read property 'length' of undefined

Here is the fiddle https://fiddle.sencha.com/?fiddle=1ahm#fiddle/1ahm

Classic theme with nearly the same code works fine.

This is a sencha bug you should report in the official forum in a timely manner.

  • store.getRange() can be called without start and end parameter. ( "The starting index. Defaults to zero."/"The ending index. Defaults to the last record. The end index is included." )
  • bufferedStore.getRange() does not explicitly tell us it can be called without parameters, but we can safely assume it implicitly should, because it is overriding the function definition of the parent class. At least the Modern Grid assumes so.
  • bufferedStore.getRange() then calls the private function rangeCached with start and end (which are both undefined)
  • rangeCached obviously expects these two to be numbers, or why else should they even use the strict equality operator at start === 0 ? 0 : start - 1 start === 0 ? 0 : start - 1 ?

If it were just this glitch, you could fix it with an override, something like:

Ext.define('MyBufferedStoreOverride',{
    override:'Ext.data.BufferedStore',
    getRange:function(start, end, options) {
        if(!Ext.isNumber(start)) start = 0;
        if(!Ext.isNumber(end)) end = this.getCount();
        me.callOverridden([start, end, options]);
    }
})

but I think that Sencha never tested their Modern Grid with a BufferedStore , because once you got around that first bug, the next error will be thrown.

尝试设置网格的高度,并使网格从“ Ext.grid.GridPanel”而不是“ Ext.grid.Grid”扩展。

ExtJS 6.6.0中, bufferedStore文档说,对于现代工具包,必须使用Ext.data.virtual.Store

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM