selectLimit in JQgrid
        Posted  
        
            by Leander
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Leander
        
        
        
        Published on 2010-04-15T11:39:06Z
        Indexed on 
            2010/04/15
            11:43 UTC
        
        
        Read the original article
        Hit count: 917
        
Hallo, I have a problem. I'am trying to get some data from my database. But with a limit. So i use the selectLimit command. But when i load the grid my firebug gives the following error:
"parsererror"?e:null},parse:function(d...d(a.fn.jqGrid,d);this.no_legacy_api||
When I go to the selectLimit in the jqgrid.php and print out what the function returns it normaly return an array with all 500 objects with the correct data. This is the code of the grid:
<?php
require_once ($_SERVER['DOCUMENT_ROOT'].'/includes_config/config.inc.php');
require_once ($_SERVER['DOCUMENT_ROOT'].'/portal/classes/core/database/class_Database_control.php');
$dtb = new clsDatabaseControl();
$dtb = $dtb->getDatabase(ConnectionString);
$dtb->doConnect();
require_once (ClassRoot.'/3rd/jqgrid/jq-config.php');
require_once (ClassRoot.'/3rd/jqgrid/php/jqGrid.php');
require_once (ClassRoot.'/3rd/jqgrid/php/jqGridPdo.php');
//require_once (ClassRoot.'/modules/logging/class_logging_control.php');
//
//$oLogginControl        = new clsLoggingControl($dtb);
//$sSQL                 = $oLogginControl->getAanmeldingenGrid();
$sSQL = "SELECT LogAanmeldID, LogAanmeldStamp, UserFirstName, UserLastName, LogAanmeldIP, LogAanmeldMethod, LogAanmeldHost, LogAanmeldAgent FROM log_aanmelden, user WHERE log_aanmelden.LogAanmeldUserID = user.UserID";
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
$conn->query("SET NAMES utf8");
$grid = new jqGridRender($conn);
//$grid->SelectCommand = $sSQL;
$grid->selectLimit($sSQL ,500,1);
$grid->dataType = 'json';
$grid->setColModel();
$grid->setUrl('modules/module_logging/index.php?grid=2');
$grid->setGridOptions(array(
"hoverrows"=>true,
//"sortname"=>"naam",
"height"=>450
));
// Enable toolbar searching
$grid->toolbarfilter = true;
$grid->setFilterOptions(array("stringResult"=>true));
$grid->navigator = true;
$grid->setNavOptions('navigator', array("excel"=>true,"add"=>false,"edit"=>false,"del"=>false,"view"=>true, "refresh"=>false));
$custom = <<<CUSTOM
$(document).ready(function()
{
        gridParentWidth  = $(window).width();
         $('#grid').jqGrid('setGridWidth',gridParentWidth-10);
})
$(window).resize(function()
{
        gridParentWidth  = $(window).width();
         $('#grid').jqGrid('setGridWidth',gridParentWidth-10);
});
function formatAddAdresboek(cellValue, options, rowObject)
{
    var imageHtml = "<a href='?FFID=51000&TID=1&INS=3&contactID=" + cellValue + "' originalValue='" + cellValue + "'><img border='0' alt='Toevoegen aan Persoonlijk Adresboek' src='images/16X16/new_user.gif'/></a>";
    imageHtml =    imageHtml + "    <a href='?FFID=51000&TID=2&INS=3&contactID=" + cellValue + "' originalValue='" + cellValue + "'><img border='0' alt='Toevoegen aan Praktijk Adresboek' src='images/16X16/new_usergroup.gif'/></a>";
return imageHtml;
}
function unformatAddAdresboek(cellValue, options, cellObject)
{
    return $(cellObject.html()).attr("originalValue");
}
CUSTOM;
$grid->setJSCode($custom);
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>
When I inspect the $_GET the answer is empty and in stead of a JSON tab there is an HTML tab. When i use the selectCommand in stead of the selectLimit it return all the data correct as an json object an parses it correcly in the grid but it doens't use the LIMIT, Because when i add the limit. PDO doens't work anymore. So how do I get the object from the selectLimit to the grid? Can someone please help me get the grid working?
© Stack Overflow or respective owner