This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » Javascript plugins » [RESOLVED] JQuery TableSorter with Symfony 1.4.6
[RESOLVED] JQuery TableSorter with Symfony 1.4.6 [message #102794] Tue, 20 July 2010 12:55 Go to next message
CaMs  is currently offline CaMs
Messages: 3
Registered: July 2010
Location: Clermont Ferrand
Junior Member
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 :

<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):

<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 :

<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

[Updated on: Tue, 20 July 2010 16:58]


CaMs
Re: JQuery TableSorter with Symfony 1.4.6 [message #102805 is a reply to message #102794 ] Tue, 20 July 2010 16:18 Go to previous messageGo to next message
esukf  is currently offline esukf
Messages: 65
Registered: December 2006
Member
You are missing the . in you jquery selector:

$(".spending").tablesorter({


It also look like you included jquery twice:

<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.

Re: JQuery TableSorter with Symfony 1.4.6 [message #102809 is a reply to message #102794 ] Tue, 20 July 2010 16:51 Go to previous messageGo to next message
CaMs  is currently offline CaMs
Messages: 3
Registered: July 2010
Location: Clermont Ferrand
Junior Member
Thanks to your answer !! Smile


i have add the "."
<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)

<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
Re: JQuery TableSorter with Symfony 1.4.6 [message #102810 is a reply to message #102794 ] Tue, 20 July 2010 16:53 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
@CaMs - do you get any JS errors or warnings in Firefox/Firebug?


Remember Palestine
Re: JQuery TableSorter with Symfony 1.4.6 [message #102812 is a reply to message #102794 ] Tue, 20 July 2010 16:58 Go to previous message
CaMs  is currently offline CaMs
Messages: 3
Registered: July 2010
Location: Clermont Ferrand
Junior Member
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

[Updated on: Tue, 20 July 2010 17:02]


CaMs
Previous Topic:Jquery rating system and symfony
Next Topic:PEAR.php error when installing sfJqueryReloadedPlugin-1.4.1
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software