Programmatically sorting a column throws a javascript "eval code" error?

Programmatically sorting a column throws a javascript "eval code" error?

mvelasquezmvelasquez Posts: 17Questions: 0Answers: 0
edited May 2010 in General
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.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    fnSort requires a 2D array, not a 1D array. I think you need to be passing something like this:

    [code]
    fnSort( [ [ 5, "asc" ] ] );
    [/code]
    So if you manipulate your string into that format, it should work fine.

    Allan
  • mvelasquezmvelasquez Posts: 17Questions: 0Answers: 0
    the problem was that it was a literal string.
    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.
This discussion has been closed.