Programmatically sorting a column throws a javascript "eval code" error?
Programmatically sorting a column throws a javascript "eval code" error?
mvelasquez
Posts: 17Questions: 0Answers: 0
I'm programmatically sorting my grid by using the fnSort() method as follows:
var sortData = document.getElementById('sortDataHiddenField').value;
var sortArray = sortData.split("|");
oTable.fnSort(sortArray);
In this case, it's a single element array as there is only one sort.
The string going into the 0 element of the sortArray is:
5,'asc'
it's throwing an error in debug mode at this line:
fnLocalSorting = function(a,b){var iTest;iTest = oSort['string-,']( aoData[a]._aData[5], aoData[b]._aData[5] );if (iTest===0) return oSort['numeric-,'](a, b); return iTest;}
specifically on the "iTest = oSort['string-,']( aoData[a]._aData[5], aoData[b]._aData[5] )"
I'm not sure why.
Can anyone shed any light onsomething I may be doing wrong?
Thanks in advance.
var sortData = document.getElementById('sortDataHiddenField').value;
var sortArray = sortData.split("|");
oTable.fnSort(sortArray);
In this case, it's a single element array as there is only one sort.
The string going into the 0 element of the sortArray is:
5,'asc'
it's throwing an error in debug mode at this line:
fnLocalSorting = function(a,b){var iTest;iTest = oSort['string-,']( aoData[a]._aData[5], aoData[b]._aData[5] );if (iTest===0) return oSort['numeric-,'](a, b); return iTest;}
specifically on the "iTest = oSort['string-,']( aoData[a]._aData[5], aoData[b]._aData[5] )"
I'm not sure why.
Can anyone shed any light onsomething I may be doing wrong?
Thanks in advance.
This discussion has been closed.
Replies
[code]
fnSort( [ [ 5, "asc" ] ] );
[/code]
So if you manipulate your string into that format, it should work fine.
Allan
the fnSort function didn't like that at all. it required an actual array object.
so i had to programmatically build an array in the javascript by splitting and iterating through the string.
that worked. :)
thanks.