PDA

View Full Version : Paging Issue - Only 1 Page Displays



cassebn
17 Apr 2007, 4:49 PM
I have a working example of the paging grid, but it is giving me some wierd results. I am using classic ASP (due to work constraints), SQL 2000 and returning a converted ADO recordset into JSON. That part looks OK, but I can only display 1 page, even though there should be 3 pages. It shows the 50 records, but only gives me 1 page. If I change the parameter in the ds.load({params:{start:0, limit:50}}); to ds.load({params:{start:1, limit:50}});, then it starts on page 2 and all of the paging footer numbers are messed up.

Any help would be greatly appreciated!!

Here are the code snippets. Please let me know if you need more information.

Paging.js:

// create the Data Store
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'http://localhost/wlpmiscapps/hrs/pagingGrid/jsonPagingGrid.asp',
method : 'POST'
}),

// create reader that reads the Topic records
reader: new Ext.data.JsonReader({
totalProperty: 'RecordCount',
root: 'Records',
id: 'rowid'
}, [
{name: 'rowid', mapping: 'rowid'},
{name: 'id', mapping: 'id'},
{name: 'headline', mapping: 'headline', type: 'string'},
{name: 'client', mapping: 'client', type: 'string'},
{name: 'requestType', mapping: 'requesttype', type: 'string'},
{name: 'dateopen', mapping: 'dateopen', type: 'date'},
{name: 'status', mapping: 'status', type: 'string'},
{name: 'issue', mapping: 'issue', type: 'string'},
{name: 'resolution', mapping: 'resolution', type: 'string'}
]),

// turn on remote sorting
remoteSort: true
});
ds.setDefaultSort('rowid', 'asc');
...

var gridFoot = grid.getView().getFooterPanel(true);

// add a paging toolbar to the grid's footer
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 50,
displayInfo: true,
displayMsg: 'Displaying requests {0} - {1} of {2}',
emptyMsg: "No topics to display"
});
// add the detailed view button
paging.add('-', {
pressed: false,
enableToggle:true,
text: 'Detailed View',
cls: 'x-btn-text-icon details',
toggleHandler: toggleDetails
});

// trigger the data store load
ds.load({params:{start:0, limit:50}});

function toggleDetails(btn, pressed){
cm.getColumnById('requestTitle').renderer = pressed ? renderTopic : renderTopicPlain;
grid.getView().refresh();
}

---------------------------------------------------------------------

jsonPagingGrid.asp:

<!-- #include file="../resources/connection.asp" -->
<!-- #include file="includes/RStoJSON.inc" -->
<%

start = request.form("start") + 1
limit = request.form("limit")
dir = request.form("dir")

'start = 1
'dir = "asc"
'limit = 50

set rst = server.CreateObject("adodb.recordset")

rst.Open "DECLARE @startRowIndex INT " & _
"SET @startRowIndex = " & start & _
"SELECT TOP 50 * " & _
"FROM " & _
"( " & _
"SELECT " & _
"( " & _
"SELECT COUNT(*) " & _
"FROM " & _
"hrs_helpdesk hd2 " & _
"WHERE " & _
"hd2.id <= hd.id " & _
"AND visible = '1' " & _
") AS rowid " & _
", hd.id " & _
", client " & _
", headline " & _
", databaseimpacted " & _
", state " & _
", userdepartment " & _
", CAST(issue AS VARCHAR(255)) AS issue " & _
", support " & _
", dateadded " & _
", CAST(resolution AS VARCHAR(255)) AS resolution " & _
", supportpersonnel " & _
", assistedby " & _
", requesttype " & _
", contactmethod " & _
", dateopen " & _
", dateclose " & _
", resolvetime " & _
", status " & _
"FROM " & _
"dbo.hrs_helpdesk hd " & _
"LEFT OUTER JOIN hrs_helpdesk_status hs on hd.id = hs.dhrid " & _
"WHERE " & _
"visible = '1' " & _
"GROUP BY " & _
"hd.id " & _
", client " & _
", headline " & _
", databaseimpacted " & _
", state " & _
", userdepartment " & _
", CAST(issue AS VARCHAR(255)) " & _
", support " & _
", dateadded " & _
", CAST(resolution AS VARCHAR(255)) " & _
", supportpersonnel " & _
", assistedby " & _
", requesttype " & _
", contactmethod " & _
", dateopen " & _
", dateclose " & _
", resolvetime " & _
", status " & _
") a " & _
"WHERE " & _
"rowid >= @startRowIndex " & _
"ORDER BY " & _
"rowid " & dir & " " , cnnDb

response.Write RStoJSON(rst)

response.flush
rst.Close
set rst = nothing
cnnDb.close
set cnnDb = nothing

tryanDLS
17 Apr 2007, 5:06 PM
What does your json response look like? Is the grid showing 'page 1 of 3' when it loads?

cassebn
17 Apr 2007, 5:19 PM
Please see attached JSON response text. I took out some lines (ids 31-40) to be able to attach the file...

The grid only shows 1 of 1.

cassebn
17 Apr 2007, 5:22 PM
Please see attached screenshot.

xmrcivicboix
17 Apr 2007, 5:34 PM
Your JSON must look something like this:



({"count":2, "employees":[{"0":"[email protected]","email":"[email protected]","1":"Hanna"

,"first":"Hanna","2":"Forbes","last":"Forbes","3":"P.O. Box 645, 9184 Ornare Rd.","address":"P.O. Box

645, 9184 Ornare Rd.","4":"P.O. Box 844, 7658 Cras St.","address2":"P.O. Box 844, 7658 Cras St.","5"

:"Provo","city":"Provo","6":"ND","state":"ND","7":"09596","zipcode":"09596","8":"(877) 908-6491","phone"

:"(877) 908-6491","9":"(825) 521-4625","mobile":"(825) 521-4625"},{"0":"[email protected]

.edu","email":"[email protected]","1":"Lesley","first":"Lesley","2":"Foster","last"

:"Foster","3":"Ap #387-6186 Diam Avenue","address":"Ap #387-6186 Diam Avenue","4":"375-6168 Etiam Road"

,"address2":"375-6168 Etiam Road","5":"Shreveport","city":"Shreveport","6":"ND","state":"ND","7":"99977"

,"zipcode":"99977","8":"(908) 465-0390","phone":"(908) 465-0390","9":"(922) 875-4799","mobile":"(922

) 875-4799"}]})


notice the 'count'. That is what used to determine the number of pages you have to page.

tryanDLS
17 Apr 2007, 5:40 PM
notice the 'count'. That is what used to determine the number of pages you have to page.

In your case it should be 'RecordCount' since that's what you specified in totalProperty.

cassebn
17 Apr 2007, 5:53 PM
I have RecordCount in my JSON response. It is at the end.
], "RecordCount":"50" } ). Does this need to be higher than 50, since I have a total of 117 records that are in my table?

cassebn
17 Apr 2007, 5:58 PM
Ok, RecordCount has to be at the beggining of the JSON. I will re-work my conversion from ADO to make this change. I hard-coded it and it WORKED! Thanks so MUCH!

tryanDLS
17 Apr 2007, 5:59 PM
Yes, it's the total. That's how the paging toolbar knows that you have 3 pages. It doesn't have to be at the beginning - there's no ordering to the properties when evaling. Also, when it's a numeric value, it shouldn't have quotes.