Home > Software engineering >  Extjs Buffered store not triggering multiple API/ajax calls
Extjs Buffered store not triggering multiple API/ajax calls

Time:03-17

I have a buffered store that makes an ajax call. I have the API defined to take some start and limit and only return the results between that start and limit. However, I am not seeing multiple API calls being made with different start and limits while scrolling. Instead, I only see one API call made, in this case with start as 0 and limit as 10. What causes the multiple API calls to be triggered with different start and limit in the buffered store?

My buffered store is as below:

Ext.define('myStore', {
extend: 'Ext.data.BufferedStore',

requires: [
    'myStoremodel' // model that the store takes in 
],

storeId: 'myTeststore',

model: 'myStoremodel',

remoteSort: true,
buffered: true,
leadingBufferZone: 2,
trailingBufferZone: 2,
pageSize: 10,
proxy: {
    type: 'ajax',
    url: "/fetch/getNameList" // the API which returns data to load,
    timeout: 5 * 60 * 1000,
    reader: {
        rootProperty: 'data.name',
        totalProperty: 'data.recordSize'
    },
    simpleSortMode: true
}
});

What is the issue here? Any help would be great!

To address one of the comments - the result of ajax call The payload that gets sent is:

_dc: 1647375142598
page: 1
start: 0
limit: 10

The ajax call response:

{success: true, errorCode: 0, errorMsg: null,…}
data: {recordSize: 10, limit: 9,…}
name: [{id: 1234, name: "Jake_Mar142022", appId: 1, isClosed: null,…},…]
0: {id: 1234, name: "TimMar142022", appId: 1, isClosed: null,…}
1: {id: 1252, name: "RatMar142022", appId: null, isClosed: null,…}
2: {id: 1253, name: "MycahMar142022", appId: null, isClosed: null,…}
3: {id: 1238, name: "MeganMar142022", appId: null, isClosed: null,…}
4: {id: 1191, name: "MikeMar092022", appId: null, isClosed: null,…}
5: {id: 1271, name: "TomMar142022", appId: null, isClosed: null,…}
6: {id: 1211, name: "RamMar092022", appId: null, isClosed: null,…}
7: {id: 1212, name: "JustinMar092022", appId: 1, isClosed: null,…}
8: {id: 1213, name: "AnnieMar092022", appId: null, isClosed: null,…}
9: {id: 1231, name: "AnnMar142022", appId: null, isClosed: null,…}
limit: 9
recordSize: 10
errorCode: 0
errorMsg: null
success: true

CodePudding user response:

your total count on the server is 10 and you are sending 10 items. You have to send the correct recordSize, which you defined as totalProperty

  • Related