Forum

November 2nd, 2014
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
Adjacency List Model problem
13/07/2009
00:23
Avatar
dana
Member
Members
Forum Posts: 3
Member Since:
13/07/2009
sp_UserOfflineSmall Offline

Hello,

I am using treeGrid as grid, Adjacency List Model.

jqGrid 3.4.4

I get this Javascript error message:
  error: '0' is null or not an object

I read your Trouble-Shooting :
  "'ts.p.colModel[...].align' is null or not an object
This one means you are sending too many columns of data from the server.
If you send too few, then the grid will appear but one or
 more columns may be missing with data showing up in the wrong column;
  if you have more hidden fields then missing columns,
   you might not see this effect until you edit a row and
    see that one or more fields are not showing up there."

What missing or worng  in my code?

My code:

... example_f1.php
<?php
class testJqGrid
{
   
function __construct()
   {
     $this->viewHtml();
   }

function viewHtml()
   {
    ?>
    <html>
<head>
<title>jqGrid Demo</title>
<link rel="stylesheet" type="text/css" media="screen" href="../themes/sand/grid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="../themes/jqModal.css" />
<script src="../jquery.js" type="text/javascript"></script>
<script src="../jquery.jqGrid.js" type="text/javascript"></script>
<script src="../js/jqModal.js" type="text/javascript"></script>
<script src="../js/jqDnR.js" type="text/javascript"></script>
<script src="../js/grid.treegrid.js" type="text/javascript"></script>
<script src="../js/jquery.jqTree.js" type="text/javascript"></script>

<script type="text/javascript">
gridimgpath = '../themes/sand/images';
jQuery(document).ready(function(){
jQuery("#navgridx").jqGrid({

    url:'server_f1.php',
 datatype: "json",
 mtype: "POST",
    colNames:['id','levelx','range', 'desc', 'parent_id','is_leaf'],
    colModel:[
        {name:'id',index:'id', width:1,hidden:true,key:true},
    {name:'levelx',index:'levelx', width:30, align:"left",editable:true,editoptions:{size:30}},
     {name:'range',index:'range', width:30,editable:true,editoptions:{size:30}},
     {name:'desc',index:'desc', width:50,editable:true,editoptions:{size:50}},
     {name:'parent_id',index:'parent_id', width:40,align:"right",editable:true,editoptions:{size:40}},
     {name:'is_leaf',index:'is_leaf', width:40,align:"right",editable:true,editoptions:{size:40}}
     ], 
    imgpath: gridimgpath,
    pager: jQuery('#pagernav'),
    width:  "800",
 height: "auto",
 treeGrid: true,
 treeGridModel : 'adjacency',
 ExpandColumn : 'levelx',
 tree_root_level :2,
 treeReader : { level_field: "levelx",
                parent_id_field: "parent_id",
                leaf_field: "is_leaf",
                expanded_field: "expanded" },
    caption:"My Tree Navigator Example",
    editurl:'someurl_f1.php'
    }).navGrid("#pagernav",{find:true,edit:true,add:false,del:false,position:"left"},
                       {reloadAfterSubmit:false}
                       );
});
</script>
</head>
<body>

<table id="navgridx" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pagernav" class="scroll" style="text-align:center;"></div>

</body>
</html>
<?

   }
}

$testJqGrid = new testJqGrid();
?>

.....  server_f1.php
<?php
class testJqGridArr
{

   
function __construct()
{
$this->viewHtmlArr();
}

function viewHtmlArr()
   {
include("JSON.php");
$json = new Services_JSON();

$count=9;

$page = 1;       //$_REQUEST['page']; // get the requested page
$limit = 10;     //$_REQUEST['rows']; // get how many rows we want to have into the grid
$sidx = 1;       //$_REQUEST['sidx']; // get index row - i.e. user click to sort
$sord = 'asc';   //$_REQUEST['sord']; // get the direction
$debug = $_REQUEST['debug'];

if(!$sidx) $sidx =1;

// array instead of use DB table

        if($debug ) echo $stat.'<br>';
    
        $myArr = array(
                       '0'=> array('ID'=>'1','LEVELX'=>1,'RANGE'=>'0-90','DESC'=>'ROOT','PARENT_ID'=>'','IS_LEAF'=>'false'),
                       '1' => array('ID'=>'2','LEVELX'=>2,'RANGE'=>'0-10','DESC'=>'GRP 1','PARENT_ID'=>'1','IS_LEAF'=>'false'),
                       '2' => array('ID'=>'3','LEVELX'=>3,'RANGE'=>'1-5' ,'DESC'=>'GRP 1A','PARENT_ID'=>'2','IS_LEAF'=>'true'),
                       '3' => array('ID'=>'4','LEVELX'=>3,'RANGE'=>'6-10','DESC'=>'GRP 1B','PARENT_ID'=>'2','IS_LEAF'=>'true'),
                       '4' => array('ID'=>'5','LEVELX'=>2,'RANGE'=>'11-30','DESC'=>'GRP 2','PARENT_ID'=>'1','IS_LEAF'=>'false'),
                       '5' => array('ID'=>'6','LEVELX'=>3,'RANGE'=>'11-15','DESC'=>'GRP 2A','PARENT_ID'=>'5','IS_LEAF'=>'true'),
                       '6' => array('ID'=>'7','LEVELX'=>3,'RANGE'=>'15-20','DESC'=>'GRP 2B','PARENT_ID'=>'5','IS_LEAF'=>'true'),
                       '7' => array('ID'=>'8','LEVELX'=>3,'RANGE'=>'21-25','DESC'=>'GRP 2C','PARENT_ID'=>'5','IS_LEAF'=>'true'),
                       '8' => array('ID'=>'9','LEVELX'=>3,'RANGE'=>'26-30','DESC'=>'GRP 2D','PARENT_ID'=>'5','IS_LEAF'=>'true')
                       );    

        $responce->page = 1;
        $responce->total = 9;
        $responce->records = $count;
        $i=0;
        foreach($myArr as $key => $row)
         {
           $responce->rows[$i]['id']=$row['ID'];
           $responce->rows[$i]['cell']=array($row['ID'],
                                              $row['LEVELX'],
                                              $row['RANGE'],
                                              $row['DESC'],
                                              $row['PARENT_ID'],
                                              $row['IS_LEAF']
                                              );
            $i++;
  }       

  echo $json->encode($responce); // coment if php 5
        if($debug )
        {
      echo '<br>  test';
      print_r($responce);
      echo '<br>';
         print_r($_REQUEST);
               echo '<br>';
        }          
   }
function Strip_x($value)
{
 if(get_magic_quotes_gpc() != 0)
   {
     if(is_array($value)) 
   if ( $this->array_is_associative($value) )
   {
    foreach( $value as $k=>$v)
     $tmp_val[$k] = stripslashes($v);
    $value = $tmp_val;
   }    
   else 
    for($j = 0; $j < sizeof($value); $j++)
           $value[$j] = stripslashes($value[$j]);
  else
   $value = stripslashes($value);
 }
 return $value;
}
function array_is_associative_x ($array)
{
    if ( is_array($array) && ! empty($array) )
    {
        for ( $iterator = count($array) - 1; $iterator; $iterator-- )
        {
            if ( ! array_key_exists($iterator, $array) ) { return true; }
        }
        return ! array_key_exists(0, $array);
    }
    return false;
}

  
}

$testJqGridArr = new testJqGridArr();
?>

... someurl_f1.php
<?php
?>

thanks

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
30 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