2017-09-18 221 views
0

我的一个项目,我需要显示在为此表格形式记录我使用Guriddo jqGrid PHP显示的记录,但我收到错误,如:致命错误:未捕获的错误:类“jqGridRender”未找到

"Fatal error: Uncaught Error: Class 'jqGridRender' not found....."

我正在使用PDO来连接数据库。 任何人都可以帮助我解决这个错误吗?

请对我的代码来看看:

require_once 'jqgrid/jq-config.php'; 
// include the jqGrid Class 
require_once ABSPATH."jqgrid/php/PHPSuito/jqGrid.php"; 
// include the driver class 
require_once ABSPATH."jqgrid/php/PHPSuito/DBdrivers/jqGridPdo.php"; 
// Connection to the server 
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); 
// Tell the db that we use utf-8 
$conn->query("SET NAMES utf8"); 

// Create the jqGrid instance 
$grid = new jqGridRender($conn); 
     // Write the SQL Query 
     $sql = 'select member_id,members.full_name, email, mobile, member_type, state_name, city_name, location_name, IF(status=1,"YES","NO") as status, IF(validation_success=1,"YES","NO") as validation_success, profile_picture, date_added, date_updated, last_seen, isloggedin'; 

     $sql .= " from members "; 

     $grid->SelectCommand = $sql; 
     // Set the table to where you add the data 
     $grid->table = 'members'; 
     // set the ouput format to json 
     $grid->dataType = 'json'; 
     // Let the grid create the model 
     $grid->setColModel(); 
     // Set the url from where we obtain the data 
     $grid->setUrl('manage_member_grid.php'); 
     // Set some grid options 
     $grid->setGridOptions(array("rowNum"=>100,"sortname"=>"full_name","sortorder"=>"asc","height"=>150,"multiselect"=>true,"hoverrows"=>true,"rowList"=>array(10,20,30,40,50,100),"shrinkToFit"=>false,"width"=>1140,"height"=>500));// 

     //Set Primary Key for row 
     $grid->setPrimaryKeyId("member_id"); 

     // Hide fields 
     $grid->setColProperty("member_id", array("hidden"=>true)); 

     //Change some property of the full_name field 
     $grid->setColProperty("full_name", array("label"=>array("Name"))); 
     $grid->setColProperty("full_name", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 

     //Change some property of the email field 
     $grid->setColProperty("email", array("label"=>array("Email"))); 
     $grid->setColProperty("email", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 

     // Change some property of the mobile field 
     $grid->setColProperty("mobile", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));//,"width"=>300,"lable"=>array("Added Date") 
     $grid->setColProperty("mobile", array("label"=>array("Mobile"))); 

     // Change some property of the member_type field 
     $grid->setColProperty("member_type", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en"))));//,"width"=>300,"lable"=>array("Added Date") 
     $grid->setColProperty("member_type", array("label"=>array("Member Type"))); 

     // Change some property of the State field 
     $grid->setColProperty("state_name", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 
     $grid->setColProperty("state_name", array("label"=>array("Satate"))); 

     // Change some property of the City field 
     $grid->setColProperty("city_name", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 
     $grid->setColProperty("city_name", array("label"=>array("City"))); 

     // Change some property of the Address field 
     $grid->setColProperty("location_name", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 
     $grid->setColProperty("location_name", array("label"=>array("Location No"))); 

     // Change some property of the date_added field 
     $grid->setColProperty("date_added", array("formatter"=>"date","formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"d/m/Y h:i a")));//,"lable"=>array("Added Date") 
     $grid->setColProperty("date_added", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 
     $grid->setColProperty("date_added", array("label"=>array("Added Date"))); 
     $grid->setDatepicker('date_added'); 
     $grid->setColProperty('date_added', array("editable"=>false)); 
     // Change some property of the date_updated field 
     $grid->setColProperty("date_updated", array("formatter"=>"date","formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"d/m/Y h:i a"))); 
     $grid->setColProperty("date_updated", array("label"=>array("Last Update"))); 
     $grid->setColProperty('date_updated', array("editable"=>false)); 

     // Change some property of the status field 
     $grid->setColProperty("status", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 
     $grid->setColProperty("status", array("label"=>array("isActive"))); 

     // Change some property of the validation_success field 
     $grid->setColProperty("validation_success", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 
     $grid->setColProperty("validation_success", array("label"=>array("isEmail Validate"))); 

     // Change some property of the profile_picture field 
     $grid->setColProperty("profile_picture", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 
     $grid->setColProperty("profile_picture", array("label"=>array("Profile Picture"),"formatter"=>"js:formatLinkImages")); 
     $grid->setColProperty('profile_picture', array("editable"=>false)); 
     // Change some property of the last_seen field 
     $grid->setColProperty("last_seen", array("formatter"=>"date","formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"d/m/Y h:i a")));//,"lable"=>array("Added Date") 
     $grid->setColProperty("last_seen", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 
     $grid->setColProperty("last_seen", array("label"=>array("Last Seen"))); 
     $grid->setDatepicker('last_seen'); 
     $grid->setColProperty('last_seen', array("editable"=>false)); 
     // Change some property of the isloggedin field 
     $grid->setColProperty("isloggedin", array("searchoptions"=>array("sopt"=>array("cn","eq","ne","le","ge","gt","nc","bw","bn","ew","en")))); 
     $grid->setColProperty("isloggedin", array("label"=>array("isLoggedin Now"))); 
     $grid->setColProperty('isloggedin', array("editable"=>false)); 

     // Enable toolbar searching 
     $grid->toolbarfilter = true; 
     $grid->setFilterOptions(array(
     "stringResult"=> true, 
     "searchOperators"=>true 
     )); 


     // We can put JS from php 
     $custom = <<<CUSTOM 
     /*function formatLinkMember(cellValue, options, rowData) { 
     return "<a class='button' href='#login_form' id='login_pop' onclick='getMemberDetails("+rowData.member_id+")' >"+rowData.full_name+"</a>"; 
     //return "<input type='button' value='somevalue' onclick='some_function'\>"; 
     }*/ 
     function formatLinkImages(cellValue, options, rowData) { 
     var path = "'"+rowData.member_id+"', '"+rowData.profile_picture+"'"; 
     return '<a class="button" href="#login_form" id="login_pop" onclick="javascript:getImagesDetails('+path+');" >'+rowData.profile_picture+'</a>'; 
     //return "<input type='button' value='somevalue' onclick='some_function'\>"; 
     } 

     CUSTOM; 
     // Let set the code which is executed at end 
     $grid->setJSCode($custom); 


     //add on double clicl event (This will take to the View Records) 
     $ondblclick = <<<DBLCLICK 
     function(rowId, iRow, iCol, e) 
     { 
     if(rowId) 
     { 
     // this refers to grid 
     $(this).jqGrid('viewGridRow',rowId,{}); 
     } 
     } 
     DBLCLICK; 
     $grid->setGridEvent('ondblClickRow',$ondblclick); 

     // add a custom button via the build in callGridMethod 
     // note the js: before the function 
     $buttonoptions = array("#pager", 
     array("caption"=>"Pdf", "title"=>"Export to Pdf", "onClickButton"=>"js: function(){ 
     jQuery('#grid').jqGrid('excelExport',{tag:'pdf', url:'manage_member_grid.php'});}" 
     ) 
     ); 
     $grid->callGridMethod("#grid", "navButtonAdd", $buttonoptions); 

     // Enable navigator searching 
     $grid->navigator = true; 
     // Set which buttons should be visible 
     $grid->setNavOptions('navigator',array("add"=>false,"edit"=>false,"del"=>false,"view"=>true,"excel"=>true,"recreateForm"=>true)); 
     // Enjoy 
     $grid->renderGrid('#grid','#pager',true, null, null, true,true); 

回答

0

知道使用哪种Guriddo Suito PHP的版本是很重要的。在最新版本中(不记得哪一个)使用自动加载器类。

也许你可以尝试加载呈现类insted的jqGrid的一个即与此一

// include the jqGrid Class 
require_once ABSPATH."jqgrid/php/PHPSuito/jqGridRender.php"; 
更换

// include the jqGrid Class 
require_once ABSPATH."jqgrid/php/PHPSuito/jqGrid.php"; 

相关问题