Ok, I've tried a few suggestions from people around here, and nothing so
far has worked - the numbers still get sorted as if they were strings:
Total Net Value:
0.441
101.404
107.558
107.558
108.48
108.945
11.195
12.143
12.801
131.73
Here is what I've got as far as the code goes:
<code>
YAHOO.example.DynamicData = function() {
// Column definitions
var myColumnDefs = [
{key:"NAME", label:"Name", width:200, resizeable:true,
sortable:true},
{key:"DATE", label:"Start Date", formatter:"date"},
{key:"NET", label:"Total Net Value", sortable:true}
];
// DataSource instance
var myDataSource = new YAHOO.util.DataSource("/?json&");
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
myDataSource.responseSchema = {
resultsList: "records",
fields: [
{key:"NAME"},
{key:"DATE"},
{key:"NET", parser:"number"}
],
metaFields: {
totalRecords: "totalRecords",
paginationRecordOffset : "startIndex",
paginationRowsPerPage : "pageSize",
sortKey: "sort",
sortDir: "dir"
}
};
// DataTable configuration
var myConfigs = {
initialRequest: "sort=NAME&dir=asc&startIndex=0&results=15", //
Initial request for first page of data
dynamicData: true, // Enables dynamic server-driven data
sortedBy : {key:"NAME", dir:YAHOO.widget.DataTable.CLASS_ASC},
// Sets UI initial sort arrow
paginator: new YAHOO.widget.Paginator({
rowsPerPage: 25,
template: YAHOO.widget.Paginator.TEMPLATE_ROWS_PER_PAGE,
rowsPerPageOptions: [10,25,50,100],
pageLinks: 3
})
};
// DataTable instance
var myDataTable = new YAHOO.widget.DataTable("tab1", myColumnDefs,
myDataSource, myConfigs);
// Update totalRecords on the fly with value from server
myDataTable.handleDataReturnPayload = function(oRequest, oResponse,
oPayload) {
oPayload.totalRecords = oResponse.meta.totalRecords;
return oPayload;
}
return {
ds: myDataSource,
dt: myDataTable
};
}();
</code>
What am I missing here? This is driving me bananas...