0

Mac 開発環境で非常に基本的な jqGrid をセットアップします。すべてが正しく機能します。グリッドがレンダリングされ、データが問題なく読み込まれます。

サイト全体を Windows マシンに移動したところ、jqGrid を除いてサイトは正常に動作しました。何らかの理由で、グリッドがデータにアクセスできません。データベースに接続してクエリを実行するために PDO オブジェクトを使用しています。Mac から Windows ボックスに切り替えても、データベースの資格情報は変わりませんでした。グリッドとは別に PDO オブジェクトを使用できますが、オブジェクトをグリッドに渡すと、機能しないようです。

<?php

require_once '../Grid/jq-config.php';
// include the jqGrid Class
require_once "../Grid/php/jqGrid.php";
// include the PDO driver class
require_once "../Grid/php/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");

$selectCommand = "SELECT VolunteerID, FirstName, LastName, PhoneNumber, Email FROM Volunteers";

// Definition of the labels
$vLabels = array("VolunteerID"=>"Id",
    "FirstName" => "First Name",
    "LastName" => "Last Name",
    "PhoneNumber" => "Phone Number",
    "Email" => "Email");

// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = $selectCommand;
// set the ouput format to json
$grid->dataType = "json";
// Let the grid create the model
//$grid->setColModel(null, null, $vLabels);
$grid->setColModel();



// Set the url from where we obtain the data
$grid->setUrl('VolunteerListGrid.php');
// Set grid caption using the option caption

$grid->setGridOptions(array(
    "caption"=>"Volunteers",
    "rowNum"=>10,
    "sortname"=>"VolunteerID",
    "hoverrows"=>true,
    "rowList"=>array(10,20,50)
    ));

// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true, true);

//$test = $conn->query($selectCommand);
//$data = $test->fetchAll(PDO::FETCH_ASSOC);
//
//echo json_encode($data);


$conn = null;

?>

この問題を引き起こすために何が変更されたのかわかりません。

ありがとう、JA

4

1 に答える 1

0

$grid->setColModel();チャンスが必要だと思います$grid->setColModel($vLabels);

于 2011-08-23T22:38:58.607 に答える