Beispiel #1
0
 /**
  * Begins the PJAX container
  */
 protected function beginPjax()
 {
     if (!$this->pjax) {
         return;
     }
     $view = $this->getView();
     if (empty($this->pjaxSettings['options']['id'])) {
         $this->pjaxSettings['options']['id'] = $this->options['id'] . '-pjax';
     }
     $container = 'jQuery("#' . $this->pjaxSettings['options']['id'] . '")';
     $js = $container;
     if (ArrayHelper::getvalue($this->pjaxSettings, 'neverTimeout', true)) {
         $js .= ".on('pjax:timeout', function(e){e.preventDefault()})";
     }
     $loadingCss = ArrayHelper::getvalue($this->pjaxSettings, 'loadingCssClass', 'kv-grid-loading');
     $postPjaxJs = "setTimeout({$this->_gridClientFunc}, 2500);";
     if ($loadingCss !== false) {
         $grid = 'jQuery("#' . $this->containerOptions['id'] . '")';
         if ($loadingCss === true) {
             $loadingCss = 'kv-grid-loading';
         }
         $js .= ".on('pjax:send', function(){{$grid}.addClass('{$loadingCss}')})";
         $postPjaxJs .= "{$grid}.removeClass('{$loadingCss}');";
     }
     if (!empty($postPjaxJs)) {
         $event = 'pjax:complete.' . hash('crc32', $postPjaxJs);
         $js .= ".off('{$event}').on('{$event}', function(){{$postPjaxJs}})";
     }
     if ($js != $container) {
         $view->registerJs("{$js};");
     }
     Pjax::begin($this->pjaxSettings['options']);
     echo ArrayHelper::getValue($this->pjaxSettings, 'beforeGrid', '');
 }
Beispiel #2
0
 protected function renderPjax()
 {
     if (!$this->pjax) {
         return;
     }
     $view = $this->getView();
     if (empty($this->pjaxSettings['options']['id'])) {
         $this->pjaxSettings['options']['id'] = $this->options['id'] . '-pjax';
     }
     $container = 'jQuery("#' . $this->pjaxSettings['options']['id'] . '")';
     if (ArrayHelper::getvalue($this->pjaxSettings, 'neverTimeout', true)) {
         $view->registerJs("{$container}.on('pjax:timeout', function(e){e.preventDefault()});");
     }
     $loadingCss = ArrayHelper::getvalue($this->pjaxSettings, 'loadingCssClass', 'kv-grid-loading');
     $postPjaxJs = '';
     if ($loadingCss !== false) {
         $grid = 'jQuery("#' . $this->containerOptions['id'] . '")';
         if ($loadingCss === true) {
             $loadingCss = 'kv-grid-loading';
         }
         $view->registerJs("{$container}.on('pjax:send', function(){{$grid}.addClass('{$loadingCss}')});");
         $postPjaxJs = "{$grid}.removeClass('{$loadingCss}');";
     }
     if (!empty($this->_jsExportScript)) {
         $id = 'jQuery("#' . $this->id . ' .export-csv")';
         $postPjaxJs .= "\n{$this->_jsExportScript}";
     }
     if (!empty($this->_jsFloatTheadScript)) {
         $postPjaxJs .= "\n{$this->_jsFloatTheadScript}";
     }
     if (!empty($postPjaxJs)) {
         $view->registerJs("{$container}.on('pjax:complete', function(){{$postPjaxJs}});");
     }
     Pjax::begin($this->pjaxSettings['options']);
     echo ArrayHelper::getValue($this->pjaxSettings, 'beforeGrid', '');
 }