This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

[RESOLVED] JQuery TableSorter with Symfony 1.4.6

Forum to discuss ExtJS and other JS plugins

[RESOLVED] JQuery TableSorter with Symfony 1.4.6

by CaMs » Tue Jul 20, 2010 12:55 pm

Hello,

First, i'm french so, sorry for my english ...

I'm newbie in developpement and particulary in symfony, i use it since few weeks ...

Today i would like, use the TableSorter JQuery plugin (http://tablesorter.com/docs/) to sort one form generated by symfony.

I do this :

1. Download and uncompress the jquery tablesorter in /web/js
2. In layout.php (head section) I add this :

Code: Select all
<script type="text/javascript" src="/js/jquery-latest.js"></script>
<script type="text/javascript" src="/js/jquery.tablesorter.js"></script>
<?php use_javascript('jquery-1.3.2.min.js') ?>


3. In my indexSuccess.php of my module "spending", i have this (generate by symfony):

Code: Select all
<table class="spending">
  <thead>
    <tr>
      <th>Id</th>
      <th>Date</th>
      <th>Label</th>
      <th>Amount</th>
      <th>Kilometer</th>
      <th>Person</th>
      <th>Spending category</th>
      <th>Status</th>
      <th>relevant document</th>
    </tr>
  </thead>
 
  <tbody>
    <?php foreach ($spendings as $spending): ?>
    <tr>
      <td><a href="<?php echo url_for('spending/show?id='.$spending->getId()) ?>"><?php echo $spending->getId() ?></a></td>
      <td><?php echo $spending->getDate() ?></td>
      <td><?php echo $spending->getLabel() ?></td>
      <td><?php echo $spending->getAmount() ?> €</td>
      <td><?php echo ($spending->spending_category_id == 3)?($spending->KilometricSpending->distance." km" ;) :("NA" ;); ?></td>
      <td><?php echo $spending->Person ?></td>
      <td><?php echo $spending->SpendingCategory ?></td>
      <td><?php echo $spending->Status ?></td>
      <td><?php echo $spending->binary_data_id ?>
      </td>
    </tr>
    <?php endforeach; ?>
  </tbody>
</table>


and i had add this :

Code: Select all
<script type="text/javascript">
$(document).ready(function() {
    // call the tablesorter plugin
    $("spending" ;).tablesorter({
        // sort on the first column and third column, order asc
        sortList: [[0,0],[2,0]]
    });
});
</script>


But it doesn't works ... i look the documentation but i think i have do the same things ... i search in google to find something of different because i use symfony but nothing ...

Do you have any ideas ?

Thanks for your help :)~ :-)~ :smile:
CaMs
CaMs
Junior Member
 
Posts: 3
Joined: Tue Jul 20, 2010 12:36 pm
Location: Clermont Ferrand

Re: JQuery TableSorter with Symfony 1.4.6

by esukf » Tue Jul 20, 2010 4:18 pm

You are missing the . in you jquery selector:

Code: Select all
$(".spending").tablesorter({


It also look like you included jquery twice:

Code: Select all
<script type="text/javascript" src="/js/jquery-latest.js"></script> //<--
<script type="text/javascript" src="/js/jquery.tablesorter.js"></script>
<?php use_javascript('jquery-1.3.2.min.js') ?> //<--


If you want the table to look like the tablesorter demo then you also need to download and include the tablesorter.css and add class="tablesorter" to the table.
esukf
Senior Member
 
Posts: 101
Joined: Wed Dec 06, 2006 1:08 am

Re: JQuery TableSorter with Symfony 1.4.6

by CaMs » Tue Jul 20, 2010 4:51 pm

Thanks to your answer !! :)~ :-)~ :smile:


i have add the "."
Code: Select all
<script type="text/javascript">
$(document).ready(function() {
    // call the tablesorter plugin
    $(".spending" ;).tablesorter({
        // sort on the first column and third column, order asc
        sortList: [[0,0],[2,0]]
    });
});
</script>


and i have delete the following line (i have 1.3.2, and the tablesorter need more than 1.2.1)

Code: Select all
<script type="text/javascript" src="/js/jquery-latest.js"></script>


and it doesn't work ... i really need of the css or i can click on the title and it's sufficient ?

can i check something else ?

thanks
CaMs
CaMs
Junior Member
 
Posts: 3
Joined: Tue Jul 20, 2010 12:36 pm
Location: Clermont Ferrand

Re: JQuery TableSorter with Symfony 1.4.6

by halfer » Tue Jul 20, 2010 4:53 pm

@CaMs - do you get any JS errors or warnings in Firefox/Firebug?
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK

Re: JQuery TableSorter with Symfony 1.4.6

by CaMs » Tue Jul 20, 2010 4:58 pm

thanks to your answer, i just to find the solution ...

it was a problem of right on the folder which contains the js files of tablesorter ...

one day to find this ...

thanks for your help and good evening

EDIT : i had no error in Firefox
CaMs
CaMs
Junior Member
 
Posts: 3
Joined: Tue Jul 20, 2010 12:36 pm
Location: Clermont Ferrand