Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
jquery dataTable
hnin
June 2014
Hi !! now i starts in learn fuelphp(beginner level)
i want to know how to use jquery dataTables in fuelphp.Pls share and explain with example
code.
but it doesn't appear in my view page!
here my code!
in view page
<script>
jQuery(document).ready(function() {
oTable = jQuery('#dtshops').dataTable({
"processing": true,
"serverSide": true,
"pagingType": "full_numbers",
"stateSave": true,
"jQueryUI": true,
"aaSorting": [[0,"asc"]],
"sAjaxSource": "shops/getlist",
"columns":[
{ "bSortable": true, "sWidth": "auto" },
{ "bSortable": true, "sWidth": "auto" },
{ "bSortable": true, "sWidth": "auto" },
{ "bSortable": false, "sWidth": "auto" }
]
});
jQuery('.dataTables_filter').hide();
} );
</script>
<table id="dtshops" name="dtshops" class="table table-striped">
<h1>Shops List</h1>
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>Rate</th>
<th>Action</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Address</th>
<th>Rate</th>
<th>Action</th>
</tr>
</tfoot>
<tbody>
<td colspan="4">Loading data server</td>
</tbody>
</table>
in contoller
public function action_getlist()
{
$offset = Input::get('iDisplayStart');
$max = Input::get('iDisplayLength');
$pref = Model_Shops::query()
->order_by('id', 'ASC')
->rows_offset($offset)
->rows_limit($max)
->get();
$iTotal = Model_Shops::count();
$data = array('sEcho'=>Input::get('sEcho'), 'iTotalRecords'=>$iTotal, 'iTotalDisplayRecords'=>$iTotal, 'aaData'=>array());
foreach ($pref as $prefecture)
{
$tmpentry = array();
$tmpentry[] = htmlspecialchars($prefecture->name);
$tmpentry[] = htmlspecialchars ($prefecture->address);
$tmpentry[] = htmlspecialchars ($prefecture->average_rate);
$tmpentry[]=array(Html::anchor('shops/editShops/'.$prefecture>id,'Update',array('class'=>'btn btn-default')),Html::anchor('shops/deleteShops/'.$prefecture->id, 'Delete', array('onclick' => "return confirm('Are you sure?')",'class'=>'btn btn-default')));
$data['aaData'][] = $tmpentry;
}
$this->template->content = View::forge('shops/index', $data);
}
codeyad
June 2014
hey i can suggest you tu put that in a separate file in assets an check your console on the browser, maybe you are not loading jquery or is not detecting it that sometimes is main problem.
hnin
September 2014
thanks you. i got it
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
codeyad
June 2014
hnin
September 2014