$colNames = "''"; } /*end if count columns*/ $colModel = ''; if (count($columnsModel)) { $n = 0; foreach ($columnsModel as $row) { $colModel .= ($n === 0 ? '' : ',') . "\n {"; $i = 0; foreach ($row as $k => $v) { $colModel .= ($i === 0 ? '' : ',') . $k . ':' . (is_string($v) ? "'" . $v . "'" : ($v === true ? 'true' : ($v === false ? 'false' : $v))); $i++; } $colModel .= "}"; $n++; } /*end foreach row*/ } else { $colModel = "\n {name:'colModel',width:99}"; } /*end if count columnsModel*/ Yii::app()->getClientScript()->registerScript('grid[' . $gridId . ']', "\njQuery('#" . $gridId . "').removeClass('w3-hidden');\njQuery('#" . $gridPagerId . "').removeClass('w3-hidden');\njQuery('#" . $gridId . "').jqGrid({\n url:'" . $url . "',\n datatype: '" . $datatype . "',\n mtype: '" . $mtype . "',\n colNames: [" . $colNames . "],\n colModel: [" . $colModel . "],\n pager: '#" . $gridPagerId . "',\n rowNum: " . $rowNum . ",\n rowList: " . $rowList . ",\n sortname: '" . $sortname . "',\n sortorder: '" . $sortorder . "',\n viewrecords: " . ($viewrecords === false ? 'false' : 'true') . "," . ($displayTitlebar ? "\n caption: '" . $title . "'," : '') . "\n height: " . $height . ",\n gridComplete: function(){" . ($displaySGrid === true ? "\n if(jQuery('#" . $sGridWrapperId . "').css('display') != 'none')\n jQuery('#" . $sGridWrapperId . "').hide();" : '') . "\n },\n loadComplete: function(){" . ($displaySGrid === true && $hasLinkIcon === true ? ' ' . MClientScript::registerScript('linkIcon', array('box' => 'w3-ig'), true) . ($registerGridLinkIcon ? ' ' . MClientScript::registerScript('gridLinkIcon', array('controllerId' => $controllerId, 'gridId' => $gridId), true) : '') : '') . "\n }\n});\njQuery('#" . $gridId . "').jqGrid('navGrid','#" . $gridPagerId . "',{edit:false,add:false,del:false});"); /* gridComplete is called after most of the grid changes * loadComplete is called only after data is loaded*/ Yii::app()->getClientScript()->registerCssFile(Yii::app()->request->baseUrl . '/static/css/jqgrid/ui.jqgrid.css'); Yii::app()->getClientScript()->registerScriptFile(Yii::app()->request->baseUrl . '/static/js/jqgrid/i18n/grid.locale-' . (MPath::jqGridLocaleExists(Yii::app()->language) ? Yii::app()->language : 'en') . '.js', CClientScript::POS_BEGIN); Yii::app()->getClientScript()->registerScriptFile(Yii::app()->request->baseUrl . '/static/js/jqgrid/jquery.jqGrid.min.js', CClientScript::POS_BEGIN); } /*end if displayGrid*/