Complex data types sorting

Complex data types sorting

tulumbastulumbas Posts: 1Questions: 0Answers: 0
edited March 2011 in General
Hello,

Your control is a really wonderful piece of software.
I'm using version 1.7.6 and have a small question, probably already asked by someone.
The table in my project is filled by JS using fnAddData. Data items are objects with fields, containg formatted (for display) and unformatted (for sorting) values, e.g. [code]{F:"11 and 3/4", V:11.45}[/code]

My initial idea was to bind the table with an 2D array of such objects, use fnRender to dispay formatted vals:
[code]fnRender: function(obj) { return obj.oData[obj.iDataRow][obj.iDataColumn].F; } [/code]
and custom sorting
[code]jQuery.fn.dataTableExt.oSort['pga-data-asc'] = function(a, b) { return a.V > b.V ? 1 : 0; }[/code]
with sSortDataType and sType set to specific type.

The problem is that AFAIU after loading and formatting all the data is stringified:
[code]
/* Cast everything as a string - so we can treat everything equally when sorting */
if ( typeof aData[i] != 'string' )
{
aData[i] += "";
}
[/code]

That means that complex data in fact is lost and I ought to use external data cache to support this approach.

What if this approach is extended the "stringifaction"vis bypassed if custom data type is passed through "sSortDataType" or some additional option.

Please let me know if my explanations are not clear enough.
Thanks.
This discussion has been closed.