Forum

July 12th, 2025
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Data doesn"t load in the Grid (Json encoding)
22/02/2010
19:54
Avatar
infsy
Member
Members
Forum Posts: 3
Member Since:
22/02/2010
sp_UserOfflineSmall Offline

Hi,

I'm trying to load data in a grid with Json enconding. Everything works fine, except that nothing appear in the Grid !!!???

I shearched in logs something wrong, but no. I verifyed that data is correctly extract from my database (mysql).

I don't understand what kind of problem could be it.

Please Help !

Thk's a lot..

Configuration :

Jquery 1.4.2 (same problem with 1.3.2)

Jquery-ui 1.7.2

JQgrid 3.6.4.

My JS file :

jQuery(document).ready(function(){
jQuery("#list").jqGrid({
    url:'../fonctions/ajax/ajax_search.php',
    datatype: "xml",
    mtype: 'GET',
    colNames:['NFic','Date','Organisme','Objet','Gravité','Etat','Dirisi','Cirisi'],
    colModel:[ {name:'ID',index:'ID', width:55},
        {name:'Date_Debut',index:'Date_Debut', width:90},
        {name:'Armee',index:'Armee', width:100},
        {name:'Libelle',index:'Libelle', width:80, align:"right", sortable:false},
        {name:'Gravite',index:'Gravite', width:80, align:"right"},
        {name:'Etat',index:'Etat', width:80,align:"right"},
        {name:'dirisi',index:'dirisi', width:80,align:"right"},
        {name:'cirisi',index:'cirisi', width:80,align:"right"} ],
  rowNum:10,
  rowList:[10,20,30],
  pager: '#pager',
  sortname: 'ID',
  viewrecords: true,
  sortorder: "desc",
  caption:"Recherche de Fic" }).navGrid('#pager',{edit:false,add:false,del:false});
});

My PHP file :

<?php
session_start();

include_once($_SESSION["chemin"].'/bdd/FicDAO.class.php');
include_once($_SESSION["chemin"].'/class/Config.class.php');
include_once($_SESSION["chemin"].'/bdd/FiltreDAO.class.php');
//require_once($_SESSION["chemin"].'/class/jqGrid/jquery.jqGrid.min.js');

$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction
if(!$sidx) $sidx =1;

$filtres = getFiltreByUser($_SESSION["ut_id"]);

$dao = new FicDAO();
$sql = $dao->getSQLsearchFic($filtres);
$count=$dao->createViewUser($sql,$_SESSION["ut_id"]);
$dao->close();

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)

$db = new PDO ("mysql:host=".Config::$host.";dbname=".Config::$database."", Config::$user, Config::$pass);
$sql="select ID, Date_Debut, Armee, Libelle, Gravite, Etat, dirisi, cirisi from view".$_SESSION["ut_id"]
        . " ORDER BY $sidx $sord LIMIT $start , $limit";
$db->exec('SET CHARACTER SET utf8');
$stm = $db->query($sql);

$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;

$i=0;
while($row = $stm->fetch(PDO::FETCH_ASSOC)) {
        $responce->rows[$i]['id']=$row['ID'];
        $responce->rows[$i]['cell']=array($row['ID'],$row['Date_Debut'],$row['Armee'],$row['Libelle'],$row['Gravite'],$row['Etat'],$row['dirisi'],$row['cirisi']);
        $i++;
        }

echo json_encode($responce);

?>

23/02/2010
09:37
Avatar
sam zhou
China
New Member
Members
Forum Posts: 1
Member Since:
23/02/2010
sp_UserOfflineSmall Offline

pls change datatype from xml to json in your js code...

23/02/2010
12:29
Avatar
infsy
Member
Members
Forum Posts: 3
Member Since:
22/02/2010
sp_UserOfflineSmall Offline

I am ashamed !!!! Embarassed

Thank you very much for your help !

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
46 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information