TableSorter odd sorting...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

TableSorter odd sorting...

Gabriel Porras

Hello.. I have an odd behavior with Table Sorter..


I have a page with a table and the tablesorter applyed to it.

I load this js:

        $('#gvMvtoInventarios').tablesorter(
                {
                        sortList: [[0,0]],
                        widgets: ['zebra']
        });


If I load this table (data) the sorting works perfect:

<table class="tablesorter" cellspacing="0" border="0"
id="gvMvtoInventarios" style="border-collapse:collapse;">
  <thead>
    <tr>
      <th scope="col">MARCA</th><th scope="col">INVENTARIO</th><th
scope="col">PROM. VENTAS</th><th scope="col">NRO. VECES</th>
    </tr>
  </thead><tbody>
    <tr>
      <td>AMERICANINO</td><td>581</td><td>52</td><td>11.17</td>
    </tr><tr>
      <td>CHEVIGNON</td><td>770</td><td>85</td><td>9.02</td>
    </tr><tr>
      <td>CONVERSE</td><td>179</td><td>13</td><td>13.42</td>
    </tr><tr>
      <td>DIESEL</td><td>559</td><td>61</td><td>9.21</td>
    </tr><tr>
      <td>ESPRIT</td><td>305</td><td>42</td><td>7.32</td>
    </tr><tr>
      <td>GIRBAUD</td><td>298</td><td>34</td><td>8.68</td>
    </tr><tr>
      <td>JHON JAIRO GIRALDO B</td><td>2</td><td>1</td><td>2</td>
    </tr><tr>
      <td>NO PROJECT</td><td>16</td><td>3</td><td>4.8</td>
    </tr><tr>
      <td>SLIK</td><td>28</td><td>4</td><td>7</td>
    </tr><tr>
      <td>TENNIS CONVERSE</td><td>344</td><td>22</td><td>15.88</td>
    </tr><tr>
      <td>TENNIS DIESEL</td><td>103</td><td>12</td><td>8.83</td>
    </tr><tr>
      <td>UNICO</td><td>225</td><td>21</td><td>10.71</td>
    </tr>
  </tbody><tfoot>
    <tr>
      <td>TOTAL</td><td>3410</td><td>350</td><td>9.74</td>
    </tr>
  </tfoot>
</table>


But with this other data (just the same table with other names and
numbers) the sorting dont works...

  <table class="tablesorter" cellspacing="0" border="0"
id="gvMvtoInventarios" style="border-collapse:collapse;">
    <thead>
      <tr>
        <th scope="col">MARCA</th><th scope="col">INVENTARIO</th><th
scope="col">PROM. VENTAS</th><th scope="col">NRO. VECES</th>
      </tr>
    </thead><tbody>
      <tr>
        <td>55DSL</td><td>0</td><td>1</td><td>0</td>
      </tr><tr>
        <td>AMERICANINO</td><td>616</td><td>277</td><td>2.22</td>
      </tr><tr>
        <td>CHEVIGNON</td><td>1089</td><td>346</td><td>3.14</td>
      </tr><tr>
        <td>CONVERSE</td><td>105</td><td>29</td><td>3.58</td>
      </tr><tr>
        <td>DIESEL</td><td>895</td><td>312</td><td>2.87</td>
      </tr><tr>
        <td>ESPRIT</td><td>291</td><td>96</td><td>3.03</td>
      </tr><tr>
        <td>FASHION NET</td><td>188</td><td>0</td><td>188</td>
      </tr><tr>
        <td>FRUTA-FRESCA</td><td>53</td><td>2</td><td>31.8</td>
      </tr><tr>
        <td>GIRBAUD</td><td>415</td><td>150</td><td>2.77</td>
      </tr><tr>
        <td>IMPULSADORA DE MODA S.A.</td><td>127</td><td>3</
td><td>38.1</td>
      </tr><tr>
        <td>JHON JAIRO GIRALDO B</td><td>7</td><td>2</td><td>4.2</td>
      </tr><tr>
        <td>MIRACLE ACCESORIOS</td><td>59</td><td>1</td><td>59</td>
      </tr><tr>
        <td>NO PROJECT</td><td>11</td><td>8</td><td>1.32</td>
      </tr><tr>
        <td>SLIK</td><td>18</td><td>6</td><td>3.18</td>
      </tr><tr>
        <td>SOMBREROS NYLON</td><td>0</td><td>0</td><td>0</td>
      </tr><tr>
        <td>TENNIS CONVERSE</td><td>376</td><td>151</td><td>2.48</td>
      </tr><tr>
        <td>TENNIS DIESEL</td><td>94</td><td>62</td><td>1.52</td>
      </tr><tr>
        <td>UNICO</td><td>166</td><td>56</td><td>2.98</td>
      </tr>
    </tbody><tfoot>
      <tr>
        <td>TOTAL</td><td>4510</td><td>1502</td><td>3.00</td>
      </tr>
    </tfoot>
  </table>



In the first table I can sort numbers as numbers and the third column
sorted is:
  15.88, 13.42, 11.17, 10.71, 9.21...
It's perfect!

But with the second table the resulting order of the third column is:
   59, 4.2, 38.1, 31.8, 3.58...
When the correct order is:
   188, 59, 38.1, 31.8, 4,2....


Why TableSorter works for the first table and the second one don't?
Remember that it's the same page, the same script code... The
difference is the data.

Thanks!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Plugins" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/jquery-plugins?hl=en
-~----------~----~----~----~------~----~------~--~---