custom javascript table sort function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • orientgaming
    New Member
    • Nov 2007
    • 2

    custom javascript table sort function

    Sorttable.js is a pretty useful script for sorting data in tables. However, there are certain bits of data that I don't want to be sorted.

    Therefore, what I'm looking for are functions which will remove specified table rows, sort the remaining rows (using sorttable.js), and then reinsert the removed rows into their proper place in the table.

    Basically, in each table two rows represent one item - the first row has 4 individual pieces of information which is sortable. The second row (using a colspan across the table) contains data which is not sortable and must be removed before a sort, then replaced after the sort. The two rows can be tied together by similar ID parameters (for example, id="abcde" for the first row, and id="i-abcde" for the second row.

    I suspect that using DOM may be the simplest way to do this.

    Basically, the table has four columns for price, name, rating, and category, easily sorted with sorttable. The first row for each item contains this data. The second row might be considered as a description of the item.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    welcome to TSDN ...

    please tell us which sorttable script you are using ... so that we may have a closer look at it ... or do you want to write your own script? then please show the code where you have problems ...

    kind regards

    Comment

    • orientgaming
      New Member
      • Nov 2007
      • 2

      #3
      Thanks for the welcome :)

      Actually, I'm using the original sorttable.js by Stuart Langridge (http://www.kryogenix.org/code/browser/sorttable/) - but there's probably no reason why I couldn't use the alternative version by Joost de Valk (http://www.joostdevalk.nl/code/sortable-table/).

      Sorttable itself works just fine. Click on any table header and it sorts all kinds of types.

      I imagine that it's probably not too complicated to add a function which runs before sorttable does its thing - perhaps I've been doing too much coding lately because my brain has run out of juice and my JS skills are pretty woeful (ie. cut and paste, nip and tuck, etc.) and my knowledge of DOM is non-existent. If I tried to work this out it would probably take days - but I imagine that someone's already tried or seen something similar and relatively simple.

      Thanks in advance.

      Comment

      Working...