jQuery DataTable not displaying Show entries, Search and does not sort -
this first time trying use jquery datatable.
i read lot of articles, can't make work.
i hope can help.
i need build table displays rugby games scores. table building should this:
<table cellpadding="0" cellspacing="0" border="0" class="display datatable" id="example"> <thead> <tr> <th>match</th> <th colspan="3">results</th> </tr> </thead> <tbody> <tr> <th></th> <th>team</th> <th>halftime</th> <th>final score</th> </tr> <tr> <td colspan="4">match: aa</td> </tr> <tr> <td></td> <td>team a</td> <td class="center">1</td> <td class="center">2</td> </tr> <tr> <td></td> <td>team b</td> <td class="center">1</td> <td class="center">2</td> </tr> <tr> <td colspan="4">match: bb</td> </tr> <tr> <td></td> <td>team a</td> <td class="center">1</td> <td class="center">2</td> </tr> <tr> <td></td> <td>team b</td> <td class="center">1</td> <td class="center">3</td> </tr> </tbody> </table>
i want user able sort columns: match, team, halftime , final score.
the way code now, user can't sort on anything. when click on column head height grows , sort arrows display noting being sorted.
i alert error:
datatables warning (table id='example'): requested unknown parameter '1' data source row 0
my actual table looks this:
<table class="display datatable" id="example" border="0" cellpadding="0" cellspacing="0"> <thead> <tr> <th colspan="1" class="ui-state-default" rowspan="2"> <div class="datatables_sort_wrapper"> match<span class="datatables_sort_icon css_right ui-icon ui-icon-carat-2-n-s"></span></div> </th> <th rowspan="1" colspan="3" class="ui-state-default" style="text-align:center">results </th> </tr> <tr> <th colspan="1" rowspan="1" class="ui-state-default"> <div class="datatables_sort_wrapper"> team<span class="datatables_sort_icon css_right ui-icon ui-icon-triangle-1-s"></span></div> </th> <th colspan="1" rowspan="1" class="ui-state-default"> <div class="datatables_sort_wrapper">halftime<span class="datatables_sort_icon css_right ui-icon ui-icon-carat-2-n-s"></span> </div> </th> <th colspan="1" rowspan="1" class="ui-state-default"> <div class="datatables_sort_wrapper">final score<span class="datatables_sort_icon css_right ui-icon ui-icon-carat-2-n-s"></span> </div> </th> </tr> </thead> <tbody> <tr> <td> pbhs vs st stithians<br> 24/03/2012 </td> </tr> <tr> <td></td> <td>pbhs 1st</td> <td></td> <td>14</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td> pbhs vs st stithians<br> 24/03/2012 </td> ....
my jquery code:
$(function() { $('#example').datatable({ bjqueryui: true }); });
i include these 2 files on page:
<link rel="stylesheet" href="/shared/jquery/jquery-ui-1.10.3.custom/css/smoothness/jquery-ui-1.10.3.custom.min.css"> <script src="/shared/jquery/jquery.datatables.js"></script>
can please help?
your problem
html
<tr> <td colspan="4">match: aa</td> </tr>
here it's way can achieve same thing : (maybe can add css :) )
demo
i modify header :
<thead> <tr> <th>match</th> <th colspan="3">results</th> </tr> <tr> <th></th> <th>team</th> <th>halftime</th> <th>final score</th> </tr> </thead>
i added match name each row , javascript hide them , groups together
i hope it'll !
Comments
Post a Comment