i have problem can not find way how pagination php in json , here code :
$type_name = substr(trim($_post['type']),1); $criteria = new cdbcriteria(); $count=imagelibrary::model()->count($criteria); $pages=new cpagination($count); $pages->pagesize=10; $pages->applylimit($criteria); $criteria->select = 'name,type'; $criteria->condition = 'type=:type'; $criteria->params = array('type' => $type_name); $model = imagelibrary::model()->findall($criteria); foreach( $model $key => $data){ $json_data[$key]['name'] = $data->name; $json_data[$key]['type'] = $data->type; } echo cjson::encode($json_data); i'm getting data , have no idea , how bring json :( , or if exist way . thank !!!!
don't have way. can render out whole html result in have pagination widget.
example 1 of projects:
$count = adstavke::model()->count($criteria); $pages = new cpagination($count); $pages->pagesize = 20; $pages->applylimit($criteria); $stavke = adstavke::model()->findall($criteria); if (sizeof($stavke)) { $response = array( 'success' => true, 'html' => $this->renderpartial($types[$type]['view_file'], array( 'model' => $stavke, 'pages' => $pages, 'nezaduzene' => true, ), true), ); } in view:
<div id="apptable"> <table class="tablesorter stavke zaduzene table table-striped table-hover table-condensed table-bordered"> <thead> <tr class="descriptioner"> <th colspan="9"> <div class="pull-left"> lista <span class="label label-warning" style="font-size: 14px;">zaduženih</span> stavki u: <?= $model[0]->stavka->vrsta->naziv; ?> </div> <div class="pull-right"> <?php $this->widget('clinkpager', array( 'htmloptions' => array( 'class' => 'yiipager yiipager_2', ), 'pages' => $pages, 'header' => false, 'firstpagelabel' => 'prva', 'lastpagelabel' => 'zadnja', 'prevpagelabel' => 'prethodna', 'nextpagelabel' => 'sljedeća', )); ?> </div> <div class="clearfix"></div> </th> </tr> </thead> </table> </div> and can send simple ajax request change entrie view updated-pagination:
$.post('/aplikacije/ajax/fetch', { submit: true, type: 'stanja', seek: mapped.data('stanje'), vrsta_id: $('.vrstex.active').first().data('vid'), q: _mapped.val() }, function(data) { if(data.success) { $('#apptable').html( data.html ); } }, 'json'); note: code derived 1 of live-projects , can idea how yii-pagination ajax.
Comments
Post a Comment