Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a table with jquery ui sortable and i dont want sort the first column, my table is something like that

Pos | Name | Age
----------------------
GK  | Dani | 16
ZQ  | Joe  | 17

JS

$(function(){
  $('#players').sortable();
});

Html:

<table>
  <thead>
    <tr>
      <th>Pos</th>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </thead>
  <tbody id="players">
    <tr>
      <td>Gk</td>
      <td>Dani</td>
      <td>16</td>
    </tr>
    <tr>
      <td>ZQ</td>
      <td>Joe</td>
      <td>11</td>
    </tr>
  </tbody>
</table>

Dont matter how I sort the lines I dont want that Pos collumn be sorted too, following my code, GK always have to stay on line one and ZQ always on line 2, I read this section of Jquery ui documentation but i confess that i dont understand how to apply this to my scenario.

share|improve this question
    
Do you have to use only one table? I would suggest having 2 tables with 1 table for the first column which should not be sortable and 1 table for the rest of the columns which should be sortable and you can apply the sortable for the 2nd table. I do not think the link you have given talks about your problem. It will disable entire rows based on class names –  arun15thmay Jan 17 at 13:49
add comment

1 Answer

You can use two tables. In first you will have Pos, in second - other data. And then you can apply .sortable() to the second table.

Code:

<table>
    <tr>
        <td>
            <table>
                <thead>
                    <tr>
                        <th>Pos</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Gk</td>
                    </tr>
                    <tr>
                        <td>ZQ</td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td>
            <table>
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Age</th>
                    </tr>
                </thead>
                <tbody id="players">
                    <tr>
                        <td>Dani</td>
                        <td>16</td>
                    </tr>
                    <tr>
                        <td>Joe</td>
                        <td>11</td>
                    </tr>
                </tbody>
            </table>
        </td>
    </tr>
</table>

Example

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.