0

First off, what a great plug in; Now, question: Is it possible to configure TableSorter to display dynamic data in 1 table? I have a form on the front end & once submitted is saved to mysql. This data is displayed in a table on the front end. This is where I'm encountering an issue implementing TableSorter. The table data is populated via a snippet call, because there is a lot of data I could see that the child rows in TableSorter was perfect for my requirement. What I'm finding is a table is created & populated by the first row in the database. Then the 2nd row is created in another new table & the 3rd row is in another new table & so on. Is there any code I could use to override this issue so everything will appear in 1 table? This is the html I am using:

<thead>
    <tr>
        <th>Id No #</th>
        <th>Collection City</th>
        <th>Delivery City</th>
        <th>Date</th>
        <th>Cubic Metres Available</th>
    </tr>
</thead>
<tbody>
    <!-- First row expanded to reveal the layout -->
    <tr>
        <td rowspan="2"> <!-- rowspan="2" makes the table look nicer -->
            <a href="#" class="toggle">[[+id]]</a> <!-- link to toggle view of the child row -->
        </td>
        <td>[[+deptown]]</td>
        <td>[[+arrtown]]</td>
        <td>[[+freightdate]]</td>
        <td>[[+cubmt]]</td>
    </tr>
    <tr class="tablesorter-childRow"><td colspan="4"><div class="bold">Vehicle Type</div><div>[[+vehicletype]]<br></div></td></tr>
    <tr class="tablesorter-childRow"><td colspan="4"><div class="bold">Job Details</div><div>[[+freightvehicledetail]]<br></div></td></tr>
    <tr class="tablesorter-childRow"><td colspan="4"><div class="bold">Contact Details</div><div>[[+freightvehiclecontact]]<br></div></td></tr>
    </tbody>

Here's hoping someone's got a solution because this plug in is awesome:-)

For clarity I am using the following unedited css & js files:

theme.blue jquery.tablesorter.pager

jquery.tablesorter jquery.tablesorter.widgets widget-pager

BloX Call

 [[!bloX? &packagename=`available-freight` &limit=`0` &classname=`AvailableFreight`     &tpls=`bloxouter:outerTpl||row:rowaTpl` &debug=`0`]]

outerTpl

<ul> [[+innerrows.row]] </ul>

rowaTpl (contains the above html (initial post) with the added tablesorter code, below)

<script src="js/jquery-latest.min.js"></script>

<!-- Tablesorter: required -->
<link rel="stylesheet" href="../css/theme.blue.css">
<script src="../js/jquery.tablesorter.js"></script>
<script src="../js/jquery.tablesorter.widgets.js"></script>

<!-- Tablesorter: pager -->
<link rel="stylesheet" href="../css/jquery.tablesorter.pager.css">
<script src="../js/widget-pager.js"></script>

<script id="js">$(function() {
$(".tablesorter")
    .tablesorter({
        theme : 'blue',
        // this is the default setting
        cssChildRow: "tablesorter-childRow",

        // initialize zebra and filter widgets
        widgets: ["zebra", "filter", "pager"],

        widgetOptions: {
            // output default: '{page}/{totalPages}'
            // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
            pager_output: '{startRow} - {endRow} / {filteredRows} ({totalRows})', // '{page}/{totalPages}'
            pager_removeRows: false,


            // include child row content while filtering, if true
            filter_childRows  : true,
            // class name applied to filter row and each input
            filter_cssFilter  : 'tablesorter-filter',
            // search from beginning
            filter_startsWith : false,
            // Set this option to false to make the searches case sensitive 
            filter_ignoreCase : true
        }

    });

// hide child rows
$('.tablesorter-childRow td').hide();

// Toggle child row content (td), not hiding the row since we are using rowspan
// Using delegate because the pager plugin rebuilds the table after each page change
// "delegate" works in jQuery 1.4.2+; use "live" back to v1.3; for older jQuery - SOL
$('.tablesorter').delegate('.toggle', 'click' ,function(){

    // use "nextUntil" to toggle multiple child rows
    // toggle table cells instead of the row
    $(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').toggle();

    return false;
});

// Toggle widgetFilterChildRows option
$('button.toggle-option').click(function(){
    var c = $('.tablesorter')[0].config.widgetOptions,
    o = !c.filter_childRows;
    c.filter_childRows = o;
    $('.state').html(o.toString());
    // update filter; include false parameter to force a new search
    $('table').trigger('search', false);
    return false;
});

});

Hopefully this what you want, if no please update & i'll dig deeper into BloX.

Mottie
  • 84,355
  • 30
  • 126
  • 241
Michael Joseph
  • 115
  • 1
  • 3
  • 13

1 Answers1

0

Sorry I'm not familiar with using MIGXDB or the BloX plug-in; but I will update the tags of this question.

I can help with part of the visual problem... The combination of rowspan and colspan do not match in the parent & child row groups. The rowspan is set to 2 but there are 3 child rows. So either set the rowspan to 4 (includes the parent) or make the third and fourth child rows have a colspan of 5 instead of 4.

<!-- First row expanded to reveal the layout -->
<tr>
    <td rowspan="4">
        <a href="#" class="toggle">[[+id]]</a>
    </td>
    <td>[[+deptown]]</td>
    <td>[[+arrtown]]</td>
    <td>[[+freightdate]]</td>
    <td>[[+cubmt]]</td>
</tr>
<tr class="tablesorter-childRow"><td colspan="4"><div class="bold">Vehicle Type</div><div>[[+vehicletype]]<br></div></td></tr>
<tr class="tablesorter-childRow"><td colspan="4"><div class="bold">Job Details</div><div>[[+freightvehicledetail]]<br></div></td></tr>
<tr class="tablesorter-childRow"><td colspan="4"><div class="bold">Contact Details</div><div>[[+freightvehiclecontact]]<br></div></td></tr>
Mottie
  • 84,355
  • 30
  • 126
  • 241
  • Hi Mottie, thanks for taking the time to look :-) I have updated your suggestion & now the child rows look much better. The multiple table issue sounds like it is an issue with Migx or the BloX call. I've posted on the appropriate Modx forum, if I find a resolution there I will post it here. – Michael Joseph Jun 22 '14 at 12:57
  • As I said I don't know anything about the template system you're using, but this looks wrong to me `
      [[+innerrows.row]]
    ` why are the rows within an unordered list?
    – Mottie Jun 22 '14 at 13:12
  • Just discovered some more general weirdness, when I update the data (by filling in form) the child rows can be expanded on every second update....There are currently 9 rows in total & the child rows can be expanded, if I add a tenth row then none of the child rows can be expanded until I add an eleventh row.....I found this pattern by increasing the data row by row from 3 rows up to 9. – Michael Joseph Jun 23 '14 at 03:17
  • Hi Mottie.....fyi....issue got solved on modx board.....your suspicion about how BloX called the tables was correct & the owner of that plug in provided some code that worked a treat.....[link](http://bit.ly/1wmADaN).....if click link the answer is in reply 7......I want to thank you for TableSorter it is awesome :-) – Michael Joseph Jun 23 '14 at 13:11
  • That's great! Add that solution as an answer so that it may benefit others. – Mottie Jun 23 '14 at 17:52