Can't get file size plug in to work for sorting - getting unknown parameter error
Can't get file size plug in to work for sorting - getting unknown parameter error
Hi - Here's my code. There's a table being rendered with a file size showing, 1mb, 24k, and so on. Does this code look right to do this ? I've attached the errror. It's in the columns definition line. Getting an unknown parameter. Any help would be appreciated. Thank you!
if (!orderAttachmentsDTO[orderItemID]) {
orderAttachmentsDTO[orderItemID] = $attachmentsTable.DataTable({
destroy:true,
data:itemAttachments,
columns:[orderAttachmentsMap["type": "file-size", "targets": 2]],
autoWidth:false,
order: [[ 0, 'asc' ]],
paging:false,
dom:'ft',
searching: false,
language: {
emptyTable: ax.L(911),
zeroRecords: ax.L(911)
}
});
Here's the data coming back in the JSON response.

And the error.

Below is the code from the file-size.js
jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) {
var units = data.replace( /[\d\.\s]/g, '' ).toLowerCase();
var multiplier = 1;
if ( units === 'kb' ) {
multiplier = 1000;
}
else if ( units === 'mb' ) {
multiplier = 1000000;
}
else if ( units === 'gb' ) {
multiplier = 1000000000;
}
else if ( units === 'tb' ) {
multiplier = 1000000000000;
}
else if ( units === 'pb' ) {
multiplier = 1000000000000000;
}
return parseFloat( data ) * multiplier;
};
This discussion has been closed.
Answers
The tech note link /tn/4 is provided so that you can follow the necessary diagnostic steps.
I'm not sure what
orderAttachmentsMapis but I suspect you want to assign the file-size type usingcolumnDefssince there is notargetsoption forcolumns. Maybe you want something like this?Kevin
Thank you. orderAttachmentsMap is just the map where all of the nodes get rendered and displayed in the table. I tried doing what you suggested but getting the same error
Can you post what the content of
orderAttachmentsMapis?If its an object then maybe all you need is this, along with the columnDefs:
columns: orderAttachmentsMapIf that doesn't help then post the contents so we can see how it lines up with your JSON response.
Kevin