JSON with json_encode IN CODEIGNITER

Hi,

I have a problem.

I’m trying to make a json_encode in php to provide the grid datas in codeigniter.

This is the controller:

[code]//cargamos el modelo de usuario
$this->load->model(‘user/user’);

	if($this->user->get_users_list())
	{
			
		//convertimos el array que nos llega en el formato que espera el sistema
		$n = 0;
		
		$rows['total_count']	= 2;
		$rows['pos']			= 0;
		
		foreach($this->user->_aUsersList as $key => $user)
		{
			
			$rows['data'][$n]	= $user;
			
			$n++;
		}
		/*
		print('<pre>');
		print_r($rows);
		print('</pre>');
		 * */
		
		$data['usersList'] = $rows;[/code]

And this is the JSON result:

{"total_count":2,"pos":0,"data":[{"id":"1","id_group":"1","id_theme":"1","id_languaje":"1","fecha_alta":"2011-05-03 12:00:43","lastLogin":"2011-09-11 07:14:40","name":"Sergio","surname":"Guti\u00e9rrez S\u00e1nchez","email":"s.gutierrez@prisma-mpa.com","password":"d5dec8dd6a7cbe33c3e13dfc672e5cb1","activo":"1"},{"id":"3","id_group":"1","id_theme":"1","id_languaje":"1","fecha_alta":"2011-09-11 08:48:02","lastLogin":"2011-09-11 08:48:02","name":"Ra\u00fal","surname":"Guti\u00e9rrez","email":"info@todokarts.com","password":"7411","activo":"1"}]}

This is the code of grid

[code]

[/code]

But i don’t understand what happends. The grid don’t show anything.

Could someone help me?

Kind regards.

I also tryed this json encode, but doesn’t work:

{"rows":[{"id":1,"data":["Sergio","Guti\u00e9rrez S\u00e1nchez","s.gutierrez@prisma-mpa.com","d5dec8dd6a7cbe33c3e13dfc672e5cb1","2011-05-03 12:00:43","2011-09-11 07:56:49","1"]},{"id":2,"data":["Ra\u00fal","Guti\u00e9rrez","info@todokarts.com","7411","2011-09-11 08:48:02","2011-09-11 08:48:02","1"]}]}

I also tryed this

[code]

[/code]

And you can see the result in attachment file.

What happend? What am i doing wrong?


Examples don’t work.

I tryed to make a simple xhtml (without codeigniter) only loading a json datas into grid.

The code is.

[code]

CRUDIGNITER
[/code] And you can see the result in attachment file.

Your code works well for us.
Make sure that you have dhtmlxgrid_json.js in your library.