dimanche 28 juin 2015

What Code To Add To TableSorter To Retrieve Data From A List Of Specific Columns?

I have a range of 34 districts and 34 postcodes in individually named columns in MySql and xml. A user inputs information and will select only 1 district and 1 postcode (also other information is input). This will leave 33 empty columns for postcodes and districts.

What code do I need to add to make TableSorter display (in child rows) only the single district and postcode that has been input and ignore the empty column (district & postcode) values?

I have TableSorter displaying most of my required data on the front end using the following code:

    <meta charset="utf-8">
    <!-- jQuery -->


<!-- Tablesorter: required -->
<link rel="stylesheet" href="../css/theme.blue.css">


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


    <script>
    $(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,
    // set number of rows to show; make sure to include this
    // value in the select options
    pager_size: 100,  
    // 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;
  });
});
</script>


<div id="demo">

<div class="pager">
    <img src="../assets/images/first.png" class="first" alt="First" />
    <img src="../assets/images/previous.png" class="prev" alt="Prev" />
    <span class="pagedisplay"></span> <!-- this can be any element, including an input -->
    <img src="../assets/images/next.png" class="next" alt="Next" />
    <img src="../assets/images/last.png" class="last" alt="Last" />
    <select class="pagesize" title="Select page size">
        <option value="10">10</option>
        <option value="20">20</option>
        <option value="30">30</option>
        <option value="40">40</option>
        <option value="50">50</option>
        <option value="100">100</option>
    </select>
    <select class="gotoPage" title="Select page number"></select>
</div>

<table class="tablesorter">
<colgroup>
    <col width="85" />
    <col width="110" />
    <col width="110" />
    <col width="100" />
    <col width="100" />
</colgroup>
<thead>
    <tr>
        <th>Id No #</th>
        <th>Province</th>
        <th>Date</th>
        <th>Country</th>
        <th>Package Type</th>
    </tr>
</thead>
<tbody>
    <!-- First row expanded to reveal the layout -->
[[+innerrows.row]]
    </tbody>
</table>

   </div>

I want to add code to the following so to include as child rows the only selected district and postcode:

        <tr>
<td rowspan="4"> <!-- rowspan="4" makes the table look nicer -->
    <a href="#" class="toggle">[[+id]] - More info</a> <!-- link to toggle view of the child row -->
</td>
<td>[[+province]]</td>
<td>[[+date132]]</td>
<td>[[+country]]</td>
<td>[[+packagetype]]</td>
</tr>
<tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Customer Name</div><div>[[+yourname]]<br></div></td></tr>
<tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Phone Number</div><div>[[+phonenumber]]<br></div></td></tr>
<tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Email Address</div><div>[[+email128]]<br></div></td></tr>
<tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Company Name</div><div>[[+companyname]]<br></div></td></tr>
<tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Package Weight</div><div>[[+weight]]<br></div></td></tr>
<tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Package Width</div><div>[[+width]]<br></div></td></tr>
<tr class="tablesorter-childRow"><td colspan="5"><div class="bold">package Height</div><div>[[+height]]<br></div></td></tr>
<tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Details</div><div>[[+details]]<br></div></td></tr>

Here is the xml including the 34 districts and postcodes:

    <model package="shipsaveeng" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="ShipSave" table="shipsaveeng" extends="xPDOSimpleObject">
<field key="id" dbtype="int" precision="11" phptype="integer" null="false" default=""/>
<field key="province" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district1" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district2" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district3" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district4" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district5" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district6" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district7" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district8" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district9" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district10" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district11" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district12" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district13" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district14" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district15" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district16" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district17" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district18" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district19" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district20" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district21" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district22" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district23" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district24" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district25" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district26" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district27" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district28" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district29" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district30" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district31" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district32" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district33" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district34" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="postcode1" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode2" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode3" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode4" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode5" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode6" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode7" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode8" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode9" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode10" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode11" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode12" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode13" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode14" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode15" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode16" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode17" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode18" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode19" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode20" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode21" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode22" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode23" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode24" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode25" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode26" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode27" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode28" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode29" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode30" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode31" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode32" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode33" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="postcode34" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="date132" dbtype="date" phptype="date" null="true" default="0000-00-00"/>
<field key="country" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="phonenumber" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="email128" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="companyname" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="packagetype" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="weightkgs" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="width" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="length" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="height" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
<field key="details" dbtype="text" phptype="string" null="false" default=""/>
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
    <column key="id" collation="A" null="false" />
</index>
    <aggregate alias="Resource" class="modResource" local="resource_id" foreign="id" cardinality="one" owner="foreign" />
    <aggregate alias="Creator" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign" />
</object>
</model>

Aucun commentaire:

Enregistrer un commentaire