Problem with jqgrid

Hi all, I'm trying to use jqgrid for my grids, I tested two extensions and they are great, part of my code is from them (I hope the authors don't care), but I like to make it work because I want to learn.

Maybe someone with jquery knowledge (and jqgrid) want to  help me with this or give me some examples, here is my code and thanks!

(sorry for me bad English  :) )


      $baseUrl = Yii::app()->baseUrl . '/jqGrid';

      $files = array();

      $subdir = '';

      $subfile = '';

      $clientScript = Yii::app()->getClientScript();




      if (true) {



      else {

         $subdir = 'min/';

         $subfile = '-min';





      $files[] = "{$subdir}grid.base{$subfile}.js"; // jqGrid base

      $files[] = "{$subdir}grid.common{$subfile}.js"; // jqGrid common for editing

      $files[] = "{$subdir}grid.formedit{$subfile}.js"; // jqGrid Form editing

      $files[] = "{$subdir}grid.inlinedit{$subfile}.js"; // jqGrid inline editing

      $files[] = "{$subdir}grid.celledit{$subfile}.js"; // jqGrid cell editing

      $files[] = "{$subdir}grid.subgrid{$subfile}.js"; // jqGrid subgrid

      $files[] = "{$subdir}grid.treegrid{$subfile}.js"; // jqGrid treegrid

      $files[] = "{$subdir}grid.custom{$subfile}.js"; // jqGrid custom

      $files[] = "{$subdir}grid.postext{$subfile}.js"; // jqGrid postext      

      $files[] = "{$subdir}grid.setcolumns{$subfile}.js"; // jqGrid setcolumns

      $files[] = "{$subdir}grid.import{$subfile}.js"; // jqGrid import

      $files[] = "{$subdir}jquery.fmatter{$subfile}.js"; // jqGrid formater

      $files[] = "{$subdir}json2{$subfile}.js"; // json utils

      $files[] = "{$subdir}JsonXml{$subfile}.js"; // xmljson utils

      $plugins[] = "jquery.contextmenu.js"; // jqGrid table to grid

      $plugins[] = "jquery.tablednd.js"; // jqGrid table to grid

      foreach ($files as $file) {



      foreach ($plugins as $file) {




<script type="text/javascript">





    mtype: 'GET',

    colNames:['id','Nivel', 'Curso','Nombre','Archivo'],

    colModel :[ 

      {name:'id', index:'', width:65}, 

      {name:'nivel', index:'nivel', width:100}, 

      {name:'curso', index:'curso', width:100}, 

      {name:'nombre', index:'t.nombre', width:100}, 

      {name:'archivo', index:'archivo', width:100} ], 

    pager: jQuery('#pager'),



    sortname: '',

    sortorder: "desc",

    viewrecords: true,

    imgpath: '/iae/jqGrid/themes/redmond/images/',

    caption: 'My first grid'




<table id="list" class="scroll" cellpadding="0" cellspacing="0"></table> 

<div id="pager" class="scroll" style="text-align:center;"></div> 

Y acá está la acción que devuelve los datos:


	public function actionExample(){


		$page = $_REQUEST['page'];

		$limit = $_REQUEST['rows'];

		$sidx = $_REQUEST['sidx'];

		$sord = $_REQUEST['sord'];

		if(!$sidx) $sidx =1;

		$command = yii::app()->db->createCommand("SELECT COUNT(*) AS count FROM trabajo");

		$count = $command->queryScalar();

		if( $count >0 ) {

			$total_pages = ceil($count/$limit);

		} else {

			$total_pages = 0;


		if ($page > $total_pages) $page=$total_pages;

		$start = $limit*$page - $limit; // do not put $limit*($page - 1)

		if($start <0) $start = 0;

		$SQL = "SELECT id, nombre, archivo 

		from trabajo t

		ORDER BY $sidx $sord 

		LIMIT $start , $limit";

		$result = yii::app()->db->createCommand($SQL )->query() or die("Couldn t execute query.");

		// constructing a JSON

		$responce->page = $page;

		$responce->total = $total_pages;

		$responce->records = $count;


		while($row = $result->read()) {





		echo json_encode($responce);




Looking again for an error so that dataType must be lowercase, so now data is visible, my new problem is that the theme is not working, well I’ll try to discover what is happening  ;D

You might have to install the themes depending on the extension. I know ,y extension has the themes included (pogostick yii extensions).

can you please extend on that? what do you mean by install the theme?

I'm not using extensions (I think) I copied the files to my webpath/jQuery and trying to get all from there.

Thanks for your quick answer Jerry, I'm glad because it works and I'm getting some things from de jqgrid demo page to work, but all looks very washed or doesn't look at all because of the theme not applying or the images, don't know how to do now

I'm not familiar with the extension that you're using. The theme files come with the jqGrid installation, but not necessarily with the extension you've downloaded. You need to check with the author of the extension. Sorry.

thanks Jerry, it's working now, I fell a little insecure yet because there are so many new concepts, but I'm glad because people here are very helpful, thanks again