A million of rows in ExtJS infinite grid (strange effect) - extjs

I've made an application with ExtJS infinite grid like this example.
My application receives data from a database.
It worked perfectly with the small amounts of rows (by 100000).
But now a database contains one million of rows. And I observed a strange effect: data are not loaded completely. Each time the grid shows different number of rows (maximum 859176). But I need to load all rows from a database.
Does anybody know how to solve this problem?
My code:
Ext.require ([
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.grid.plugin.BufferedRenderer'
]);
Ext.onReady(function () {
Ext.define('DoctorsList', {
extend: 'Ext.data.Model',
fields: [
'id', 'fio', 'specialization', 'photo'
],
idProperty: 'id'
});
var store = Ext.create('Ext.data.Store', {
id: 'store',
model: 'DoctorsList',
buffered: true,
pageSize: 100,
proxy: {
type: 'ajax',
url: 'get_doctors.jsp',
reader: {
root: 'data',
totalProperty: 'total'
}
},
autoLoad: true
});
Ext.create('Ext.grid.Panel', {
height: 600,
title: 'Doctor\'s list',
collapsible: true,
store: store,
columns: [
{
text: 'ID',
dataIndex: 'id',
width: 50,
sortable: true
},
{
text: 'Full name',
dataIndex: 'fio',
width: 300,
sortable: true
},
{
text: 'Specialization',
dataIndex: 'specialization',
width: 150,
sortable: true
},
{
text: 'Photo',
dataIndex: 'photo',
width: 100,
sortable: false,
renderer: function(value) {
return '<img width="100" src="images/' + value + '" />';
}
}
],
renderTo: 'doctors-list'
});
});
ADDITION:
Here you can see last request and response to get_doctors.jsp. You can notice there that the field 'total' has number 1005000 but last row has ID 423165. And here is the screen of MS SQL database selection. You can see there that used table has 1005000 rows totally.
ADDITION 2:
This bug appears in Firefox and IE8, but it does not appear in Opera, Google Chrome and Safari.
Thanks!

Related

ExtJS Paging Grid will not advance

I am trying to implement a grid with a paging toolbar in ExtJS 5. I get the first page of data, however when advancing the grid will not update new data.
It appears that data.asp page is not being updated with a new starting value to update the .AbsolutePosition property of my recordset. So the grid keeps displaying the 1st page of information.
My code is below...
var gridStore = Ext.create('Ext.data.JSonStore', {
autoLoad: false,
fields: [
{name: 'field1', type: 'int'},
{name: 'field2', type: 'int'}
],
pageSize: 25,
proxy: {
type: 'ajax',
url: 'Data.asp',
reader: {
type: 'json',
rootProperty: 'rows',
totalProperty: 'totalCount',
}
}
});
gridStore.load({
params: {
start: 0,
limit: 25
}
});
grid = Ext.create('Ext.grid.Panel', {
renderTo: 'grid-Spec',
store: gridStore,
columns: [
{text: 'Field 1', width: 10, sortable: true, dataIndex: 'field1'},
{text: 'Field 2', width: 10, sortable: true, dataIndex: 'field2'}
],
height: 100,
width: 20,
selModel: { mode: 'SINGLE' },
dockedItems: [{
xtype: 'pagingtoolbar',
store: gridStore,
dock: 'bottom',
displayInfo: true
}]
});
Your code has some typos, but in general it looks OK.
Problem may lay on server side - when using ajax proxy, you must implement paging on server side. If you have implemented paging on server side, use some developer tools (for example in Chrome) and see if page number is submitted correctly. You should see start/page number in address (eg: http://fiddle.jshell.net/echo/json/?_dc=1410854522824&page=2&start=5&limit=5).
I made fiddle: http://jsfiddle.net/seur2aLx/9/ you can compare your code to mine (note that Ext.ux.data.reader.Json is there only to fake some data for grid).

Infinite Grid only 1 column Issues

Here is the JS fiddle where I just copy pasted the sample example given by ExtJS and Kept only 1 column and that too locked. In this scenario we have 2 errors :
Its making continuous calls to backend till it gets last result. We
can check in fiddler that the calls are getting posted to backend
continously till the last page.
I am not able to scroll(vertical) in grid
Is it bug from ExtJS 4.2.1 Infinite Grid ? is there a solution ?
If we add 1 more column unlocked then its working fine (It will make only 1 request to backend and on scroll it will make next request depending on the scroller position)
Below is the same code :
Ext.onReady(function () {
Ext.define('ForumThread', {
extend: 'Ext.data.Model',
fields: [
'title', 'forumtitle', 'forumid', 'username', {
name: 'replycount',
type: 'int'
}, {
name: 'lastpost',
mapping: 'lastpost',
type: 'date',
dateFormat: 'timestamp'
},
'lastposter', ' ', 'threadid']
});
// create the Data Store
var store = Ext.create('Ext.data.Store', {
id: 'store',
model: 'ForumThread',
//remoteGroup: true,
// allow the grid to interact with the paging scroller by buffering
buffered: true,
leadingBufferZone: 300,
pageSize: 50,
proxy: {
// load using script tags for cross domain, if the data in on the same domain as
// this page, an Ajax proxy would be better
type: 'jsonp',
url: 'http://www.sencha.com/forum/remote_topics/index.php',
reader: {
root: 'topics',
totalProperty: 'totalCount'
}
},
autoLoad: true,
listeners: {
// This particular service cannot sort on more than one field, so if grouped, disable sorting
beforeprefetch: function (store, operation) {}
}
});
var grid = Ext.create('Ext.grid.Panel', {
width: 700,
height: 500,
collapsible: true,
title: 'ExtJS.com - Browse Forums',
store: store,
loadMask: true,
// grid columns
columns: [{
id: 'last',
text: "Last Post",
locked: true,
dataIndex: 'lastpost',
width: 130,
renderer: Ext.util.Format.dateRenderer('n/j/Y g:i A'),
sortable: true,
groupable: false
}],
renderTo: Ext.getBody()
});
});

extjs: Grid Buffered Scrolling with Row Editing/Deletion/Addition

Has anybody seen any sample of extjs grid with buffered scrolling with new row, row editing and row deletion support?
Can CellEditing and RowEditing plugins be used with Buffered Scrolling?
Is row editing even possible with buffered scrolling?
Cheers,
Avi
I had opened a thread at Ext forum and got the response, insertion and deletion is NOT supported with buffered scrolling.
http://forums.ext.net/showthread.php?27969-Buffered-Scrolling-with-Row-Editing-Deletion-Addition&p=124559&posted=1#post124559
Cheers,
Avi
I changed this example http://docs.sencha.com/extjs/4.2.2/#!/example/grid/infinite-scroll.html, added the row editor. Open this example: http://jsfiddle.net/zAnZg/1/, click on record, change values and then click "Update"
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.grid.plugin.BufferedRenderer'
]);
Ext.onReady(function(){
Ext.define('ForumThread', {
extend: 'Ext.data.Model',
fields: [
'title', 'forumtitle', 'forumid', 'username', {
name: 'replycount',
type: 'int'
}, {
name: 'lastpost',
mapping: 'lastpost',
type: 'date',
dateFormat: 'timestamp'
},
'lastposter', 'excerpt', 'threadid'
],
idProperty: 'threadid'
});
// create the Data Store
var store = Ext.create('Ext.data.Store', {
id: 'store',
model: 'ForumThread',
remoteGroup: true,
// allow the grid to interact with the paging scroller by buffering
buffered: true,
leadingBufferZone: 300,
pageSize: 100,
proxy: {
// load using script tags for cross domain, if the data in on the same domain as
// this page, an Ajax proxy would be better
type: 'jsonp',
url: 'http://www.sencha.com/forum/remote_topics/index.php',
reader: {
root: 'topics',
totalProperty: 'totalCount'
},
// sends single sort as multi parameter
simpleSortMode: true,
// sends single group as multi parameter
simpleGroupMode: true,
// This particular service cannot sort on more than one field, so grouping === sorting.
groupParam: 'sort',
groupDirectionParam: 'dir'
},
sorters: [{
property: 'threadid',
direction: 'ASC'
}],
autoLoad: true,
listeners: {
// This particular service cannot sort on more than one field, so if grouped, disable sorting
groupchange: function(store, groupers) {
var sortable = !store.isGrouped(),
headers = grid.headerCt.getVisibleGridColumns(),
i, len = headers.length;
for (i = 0; i < len; i++) {
headers[i].sortable = (headers[i].sortable !== undefined) ? headers[i].sortable : sortable;
}
},
// This particular service cannot sort on more than one field, so if grouped, disable sorting
beforeprefetch: function(store, operation) {
if (operation.groupers && operation.groupers.length) {
delete operation.sorters;
}
}
}
});
function renderTopic(value, p, record) {
return Ext.String.format(
'{0}',
value,
record.data.forumtitle,
record.getId(),
record.data.forumid
);
}
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
clicksToEdit: 1,
autoCancel: false,
listeners:{
edit: function(editor, e){
Ext.MessageBox.alert(
'Just create Ajax recuest here. Post changed record:<br/>' +
Ext.JSON.encode(e.record.data)
);
}
}
});
var grid = Ext.create('Ext.grid.Panel', {
width: 700,
height: 500,
collapsible: true,
title: 'ExtJS.com - Browse Forums',
store: store,
loadMask: true,
selModel: {
pruneRemoved: false
},
multiSelect: true,
viewConfig: {
trackOver: false
},
features:[{
ftype: 'grouping',
hideGroupedHeader: false
}],
plugins: [rowEditing],
// grid columns
columns:[{
xtype: 'rownumberer',
width: 50,
sortable: false
},{
tdCls: 'x-grid-cell-topic',
text: "Topic",
dataIndex: 'title',
flex: 1,
renderer: renderTopic,
sortable: true,
editor: {
allowBlank: false
}
},{
text: "Author",
dataIndex: 'username',
width: 100,
hidden: true,
sortable: true
},{
text: "Replies",
dataIndex: 'replycount',
align: 'center',
width: 70,
sortable: false,
editor: {
xtype: 'numberfield',
allowBlank: false,
minValue: 1,
maxValue: 150000
}
},{
id: 'last',
text: "Last Post",
dataIndex: 'lastpost',
width: 130,
renderer: Ext.util.Format.dateRenderer('n/j/Y g:i A'),
sortable: true,
groupable: false,
editor: {
xtype: 'datefield',
allowBlank: false,
format: 'm/d/Y',
minValue: '01/01/2006',
minText: 'Cannot have a start date before the company existed!',
maxValue: Ext.Date.format(new Date(), 'm/d/Y')
}
}],
renderTo: Ext.getBody()
});
});

ExtJS 4 infinite grid hangs on "Loading..." when applying sort to a column

I have an infinite grid that works great by default, it fetches pages nicely through the results.
However, when I click a column header to define a sort order on one of the columns, the grid just hangs with the "Loading" message even though I'm sending back the exact same data as I did before the sort (I'm ignoring the "sort" varible on the server side just for testing puposes at the moment.)
Since this is for an open source project any additional source you may need to assist can be made available.
Any help would be greatly appreciate. Thank you in advance.
Kind regards,
John.
I get this request on the server:
"GET /lextjsapi/reader/tblname?_dc=1361204535173&page=1&start=0&limit=10&sort=%5B%7B%22property%22%3A%22id%22%2C%22direction%22%3A%22DESC%22%7D%5D HTTP/1.1" 200 832 "http://lextjs/sa-test/app.html"
This is is the PHP server side code:
echo json_encode(array('success' => true, 'total' => 1000, $model_name => $tblNameRows));
This is the code for the store:
Ext.define('MyApp.store.tblnameStore', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.tblname'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
remoteSort: true,
storeId: 'tblnameStore',
model: 'MyApp.model.tblname',
buffered: true,
leadingBufferZone: 10,
pageSize: 10,
purgePageCount: 0,
trailingBufferZone: 10,
proxy: {
type: 'ajax',
url: 'http://lextjs/lextjsapi/reader/tblname',
reader: {
type: 'json',
root: 'tblname'
}
}
}, cfg)]);
} });
This is the code for the grid:
Ext.define('MyApp.view.MyGridPanel2', {
extend: 'Ext.grid.Panel',
height: 250,
width: 450,
title: 'My Grid Panel',
store: 'tblnameStore',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
viewConfig: {
},
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'id',
text: 'Id'
},
{
xtype: 'gridcolumn',
sortable: false,
dataIndex: 'name',
text: 'Name'
},
{
xtype: 'gridcolumn',
sortable: false,
dataIndex: 'address1',
text: 'Address1'
},
{
xtype: 'gridcolumn',
sortable: false,
dataIndex: 'city',
text: 'City'
}
]
});
me.callParent(arguments);
} });

infinite scroll not rendering

I'm trying to use ExtJS4.1 infinite scroll feature.
The ajax calls are being made, the data returned, but only the first page loads.
What am I doing wrong? When I scroll down nothing happens.
My code:
Store:
Ext.define('BM.store.Tests', {
extend: 'Ext.data.Store',
model: 'BM.model.Test',
storeId: 'Tests',
buffered: true,
leadingBufferZone: 50,
pageSize: 25,
purgePageCount: 0,
autoLoad: true
});
The proxy is in the model:
proxy: {
type: 'ajax',
api: {
create: '../webapp/tests/create',
read: '../webapp/tests',
update: '../webapp/tests/update'
},
reader: {
type: 'json',
root: 'tests',
successProperty: 'success'
}
}
The grid:
Ext.define('BM.view.test.MacroList', {
extend: 'Ext.grid.Panel',
alias:'widget.macro-test-list',
store: 'Tests',
// loadMask: true,
// selModel: {
// pruneRemoved: false
// },
// viewConfig: {
// trackOver: false
// },
verticalScroller: {
numFromEdge: 5,
trailingBufferZone: 10,
leadingBufferZone: 20
},
initComponent: function() {
this.columns = [
{
xtype: 'gridcolumn',
dataIndex: 'name',
text: 'Name'
},
{
xtype: 'datecolumn',
dataIndex: 'created',
text: 'Date Created',
format: 'd-M-Y'
},
{
xtype: 'datecolumn',
dataIndex: 'changed',
text: 'Last Updated',
format: 'd-M-Y'
}
];
this.callParent(arguments);
}
The only thing that's different between my implementation and the one in the examples, is that my grid is not rendered to the body.
The viewport contains a border layout.
The grid is part of the west region panel:
{
collapsible: true,
region: 'west',
xtype: 'macro',
width: 500
}
The macro panel:
Ext.define('BM.view.Macro', {
extend: 'Ext.panel.Panel',
alias: 'widget.macro',
title: 'Tests',
layout: {
type: 'vbox',
align: 'stretch'
},
items: [
{
id: "macro-test-list-id",
xtype: 'macro-test-list',
flex: 1
},
{
id: "macro-report-panel-id",
xtype: 'macro-report-list',
title: false,
flex: 1
},
{
id: "macro-report-list-id-all",
xtype: 'macro-report-list-all',
flex: 1,
hidden: true,
layout: 'anchor'
}
]
});
I've tried many many things, changing layouts, giving the grid a fixed height, etc...
Nothing works, scroll down, and the grid doesn't refresh.
One other piece of information: The DB contains 53 records of data. I'm getting the 3 ajax calls, but only the first 25 records appear (as I requested).
Any thoughts?
It sounds like you might be forgetting to put the total property in the server's JSON response. Does your answer have a structure like this:
{
"total": 53,
"tests": [(...)]
}
The totalProperty name is defined in the Reader configuration and defaults to total.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.reader.Reader-cfg-totalProperty
You need to upgrade to ExtJS 4.2!

Resources