can I sort only part of one column?

can I sort only part of one column?

AluminumCatAluminumCat Posts: 23Questions: 0Answers: 0
edited April 2014 in DataTables 1.10
Hi,
recently I've been pondering if it's possible to sort only certain rows in one column.

For example... in one column, I have a lot of numbers and then a "-" in the place where numbers arent relevant to the overall item... would look something like this:

|_column_|
|___1_____|
|___4_____|
|___2_____|
|___9_____|
|___-_____|
|___-_____|
|___-_____|
|___-_____|
|___-_____|

Is it possible to make it so that when clicking the header to sort, only the rows with numbers are affect, leaving the "-"-rows static and unaffected... remaining right where they are?

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    edited April 2014
    Not really no. The whole row is sortable. You could write a plug-in sorting function that will keep your `-` values in the same place though. Just have it return 0 but I haven't tried it...

    Allan
  • AluminumCatAluminumCat Posts: 23Questions: 0Answers: 0
    I might try.... But when you say "just have it return 0" what exactly are you referring to? :)
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    The sorting function. See: http://datatables.net/development/sorting#type_based
This discussion has been closed.