Sort on String in column begins with "foo"

Sort on String in column begins with "foo"

orangeorange Posts: 20Questions: 0Answers: 0
edited April 2011 in General
I've been searching the docs and forum but I just can't come up with the answer.

I want to sort a column on "begins with this string".

This is where I am now: oTable.fnSort( [ [ 2, $('#name').val() ] ] );

I receive this error: "oSort[iDataType + "-" + aaSort[i][1]] is not a function".

Thank you.

[code]
oTable = $('#expanded_table').dataTable({
"aaData": smallTable,
"aoColumns": [{
"sTitle": "Customer Number"
}, {
"sTitle": "Location"
}, {
"sTitle": "Customer Name"
}, {
"sTitle": "Street Address"
}, {
"sTitle": "City"
}, {
"sTitle": "State"
}, {
"sTitle": "Zip Code"
}],
"bRetrieve": true,
"bJQueryUI": true
});

oTable.fnClearTable();
oTable.fnAddData(smallTable);
// oTable.fnFilter('^' + $('#name').val(), 2, true);
//I don't want fnFilter because it removes the results

oTable.fnSort( [ [ 2, $('#name').val() ] ] );

[/code]

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    I'm not quite 100% sure what you mean I'm afraid. Where you have $('#name').val() at the moment that must be either 'asc' or 'desc' - since that parameter tells DataTables what the direction of sorting should be. If you want to find a column with a given name, then you'll need to loop over the column names in the DOM and get the required index.

    Allan
This discussion has been closed.