I'm using YUI 2.7.0, and I've gotten the client-side pagination down, and am now trying to get the server-side pagination down (The query could possibly return thousands of results). Right now, no results are being shown (I get the "No records found." message). Can't seem to find an answer on the web. The call to alert() shows the correct numbers, so I know something is being returned from the server. I suspect the issue is in jobsCallback or handleDataReturnPayload but am stuck from there. Any hints?
function jobStatusFormatter(elCell, oRecord, oColumn, oData)
{
var messages =
[
<c:forEach var="x" begin="0" end="17">
"<fmt:message key="job.status.${x}"/>",
</c:forEach>
];
elCell.innerHTML = messages[oData];
}
var jobColumns =
[
{key:"lotNumber", label:"<fmt:message key="job.lotNumber"/>", sortable:true},
{key:"scheduledStartDate", label:"<fmt:message key="job.startDate"/>", sortable:true, formatter:"date"},
{key:"scheduledCompletionDate", label:"<fmt:message key="job.completionDate"/>", sortable:true, formatter:"date"},
{key:"itemNumber", label:"<fmt:message key="job.itemNumber"/>", sortable:true},
{key:"statusType", label:"<fmt:message key="job.statusType"/>", sortable:true, formatter:jobStatusFormatter},
{key:"plannerCode", label:"<fmt:message key="job.plannerCode"/>", sortable:true},
{key:"scheduledGroup", label:"<fmt:message key="job.scheduledGroup"/>", sortable:true},
{key:"organization", label:"<fmt:message key="job.organization"/>", sortable:true}
];
var jobsDataSource = new YAHOO.util.DataSource("<%=request.getContextPath()%>/secure/xml/jobs.do?");
jobsDataSource.connMethodPost = true;
jobsDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
jobsDataSource.responseSchema =
{
resultNode: "job",
fields:
[
"id",
"lotNumber",
"plannerCode",
"scheduledGroup",
"scheduledStartDate",
"scheduledCompletionDate",
"itemNumber",
"statusType",
"organization"
],
metaNode: "jobs",
metaFields:
{
totalResultsAvailable : "totalResultsAvailable",
totalResultsReturned : "totalResultsReturned"
}
};
var jobsConfigs =
{
initialLoad: false,
dynamicData: true,
paginator: new YAHOO.widget.Paginator(
{
rowsPerPage:15,
rowsPerPageOptions : [15,25,50,100]
})
};
var jobsTable = new YAHOO.widget.DataTable("jobsDiv", jobColumns, jobsDataSource, jobsConfigs);
jobsTable.subscribe("rowMouseoverEvent", jobsTable.onEventHighlightRow);
jobsTable.subscribe("rowMouseoutEvent", jobsTable.onEventUnhighlightRow);
jobsTable.set("selectionMode","single");
jobsTable.subscribe("rowClickEvent", function(args)
{
var target = args.target;
var record = this.getRecord(target);
window.location="job.do?id="+record.getData("id");
});
jobsTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload)
{
alert("totalResultsAvailable="+oResponse.meta.totalResultsAvailable+", totalResultsReturned="+oResponse.meta.totalResultsReturned);
oPayload.totalRecords = oResponse.meta.totalResultsAvailable;
return oPayload;
};
var jobsCallback =
{
success : jobsTable.onDataReturnInitializeTable ,
failure : jobsTable.onDataReturnInitializeTable ,
scope : jobsTable
};
function getQueryParams()
{
var form = document.forms[0];
var lotNumber = form.lotNumber.value;
var itemNumber = form.itemNumber.value;
var plannerCode = form.plannerCode.value;
var scheduledGroup = form.scheduledGroup.value;
var statusType = form.statusType.value;
var organization = form.organization.value;
return "lotNumber="+lotNumber+
"&itemNumber="+itemNumber+
"&statusType="+statusType+
"&plannerCode="+plannerCode+
"&scheduledGroup="+scheduledGroup+
"&organization="+organization;
}
/* Called when submit button pressed */
function findJobs()
{
// Sends a request to the DataSource for more data
jobsTable.showTableMessage(YAHOO.widget.DataTable.MSG_LOADING);
jobsDataSource.sendRequest(getQueryParams(), jobsCallback);
}