1

ページネーションを使用したいテーブルがあります。テーブル データは Ajax によって入力されます。

これは私が働いているテーブルです:

<div class="portlet box green Report index">
    <div class="portlet-title">
        <div class="caption"><i class="icon-globe"></i>Report Summary</div>
        <div class="tools">
            <a href="javascript:;" class="collapse"></a>
        </div>
    </div>
    <div class="portlet-body">
    <div id="content">
        <table class="table table-striped table-bordered table-hover table-full-width" id="sample_1">
            <thead>
            <tr id='content2'>
                <?php //echo $content_for_layout; ?>
                <th><?php echo $this->Paginator->sort('name); ?></th>
                <th><?php echo $this->Paginator->sort('clicks); ?></th>
                <th><?php echo $this->Paginator->sort('conversions'); ?></th>
                <th><?php echo $this->Paginator->sort('payout'); ?></th>
                <th><?php echo $this->Paginator->sort('ltr'); ?></th>
                <th><?php echo $this->Paginator->sort('cpc'); ?></th>
            </tr>
            </thead>
            <tbody class="report_data">
            </tbody>
        </table>
    </div>
    </div>
</div>

私の見解の上に、私は次のものを持っています:

  $this->Paginator->options(array(
    'update' => '#content2',
    'evalScripts' => true,
));

そして、私のコントローラーには、次のヘルパーとコンポーネントがあることを思い出しました。

    public $components = array('RequestHandler');

public $helpers = array('Js' => array('Jquery'), 'Paginator');

そして、私の見解の最後に私は追加しました:

<?php echo $this->Js->writeBuffer(); ?>

テーブル リンクの 1 つをクリックすると、サイトがリロードされますが、主な問題が 2 つあります。

  1. ページネーターに送り返されたデータには、並べ替えも順序も含まれていません (つまり、サイトは基本的にリロードしているだけです)。

  2. サイトのレンダリングがめちゃくちゃです (これは小さな問題ですが、それでも非常に厄介です)

誰が私が間違っているのか教えてもらえますか?

ケーキ バージョン 2.3

マイコントローラー

    class ReportsController extends AppController
{
    public $name = 'Reports';

        public $components = array( 'BloglicHelper', 'RequestHandler', 'HasOffers');

        public $helpers = array('Js' => array('Jquery'), 'Paginator');
        public $paginate = array(
        'fields' => array(
         'Stat.clicks'
        ,'Offer.name'
        ,'Stat.currency'
        ,'Stat.conversions'
        ,'Stat.payout'
        ,'Stat.ltr'
        ,'Stat.cpc'
        ,'Stat.affiliate_id')

    ,'conditions' => array(    'Stat.affiliate_id' => array(
            'conditional' => "EQUAL_TO",
            'values' => array(1002)
        )

        , 'Stat.date' => array(
                'conditional' => 'BETWEEN'
            , 'values' => array(
                )
            ),
        ),
        'group' =>array('Offer.name'),
        'Method' => 'getStats',
        'totals' => true

    );
    public function index(){
        $this->layout = 'client_layout';
    }

    public function ajax_index(){
        if ($this->RequestHandler->isAjax())
        {
            $this->autoLayout = false;
            $this->autoRender = false;
            $this->layout = 'ajax';
        }

        //request selected dates
        $startDate = $this->request->data['startDateTime'];
        $endDate = $this->request->data['endDateTime'];

        array_push($this->paginate['conditions']['Stat.date']['values'], $startDate, $endDate);
;

        $finalData = array( 'table' => $this->paginate());
        print json_encode($finalData);

    }

}
4

1 に答える 1