Php jqgrid复杂演示程序不工作

Php jqgrid复杂演示程序不工作,php,jquery,jqgrid,Php,Jquery,Jqgrid,我一整天都在努力让这个例子在我的电脑上运行: 我无法入睡,直到我有这个工作成功,因此我迫切需要你的帮助!你曾经成功地使用过jqgrid吗 这是我的HTML文件中的代码: <table id="list2"> </table> <div id="pager2" > </div> 以下是我的javascript部分中的代码: var theURL = 'matter_parties_model/<?php echo $matterID

我一整天都在努力让这个例子在我的电脑上运行:

我无法入睡,直到我有这个工作成功,因此我迫切需要你的帮助!你曾经成功地使用过jqgrid吗

这是我的HTML文件中的代码:

<table id="list2"> </table>
<div   id="pager2" > </div>

以下是我的javascript部分中的代码:

var theURL = 'matter_parties_model/<?php echo $matterID;?>';
alert('Donato');

$("#list2").jqGrid({
url:'server.php?q=2',
datatype: "json",
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
    {name:'id',index:'id', width:55},
    {name:'invdate',index:'invdate', width:90,editable:true},
    {name:'name',index:'name asc, invdate', width:100},
    {name:'amount',index:'amount', width:80, align:"right",editable:true,editrules:{number:true}},
    {name:'tax',index:'tax', width:80, align:"right",editable:true,editrules:{number:true}},        
    {name:'total',index:'total', width:80,align:"right"},       
    {name:'note',index:'note', width:150, sortable:false}       
],
rowNum:10,
rowList:[10,20,30],
pager: '#pcelltbl',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"Cell Edit Example",
forceFit : true,
cellEdit: true,
cellsubmit: 'clientArray',
afterEditCell: function (id,name,val,iRow,iCol){
    if(name=='invdate') {
        jQuery("#"+iRow+"_invdate","#celltbl").datepicker({dateFormat:"yy-mm-dd"});
    }
},
afterSaveCell : function(rowid,name,val,iRow,iCol) {
    if(name == 'amount') {
        var taxval = jQuery("#celltbl").jqGrid('getCell',rowid,iCol+1);
        jQuery("#celltbl").jqGrid('setRowData',rowid,{total:parseFloat(val)+parseFloat(taxval)});
    }
    if(name == 'tax') {
        var amtval = jQuery("#celltbl").jqGrid('getCell',rowid,iCol-1);
        jQuery("#celltbl").jqGrid('setRowData',rowid,{total:parseFloat(val)+parseFloat(amtval)});
    }
}});

jQuery("#celltbl").jqGrid('navGrid','#pgwidth',{edit:false,add:false,del:false});
var theURL='matter\u parties\u model/';
警惕(“多纳托”);
$(“#列表2”).jqGrid({
url:'server.php?q=2',
数据类型:“json”,
colname:['Inv No','Date','Client','Amount','Tax','Total','Notes',],
colModel:[
{名称:'id',索引:'id',宽度:55},
{名称:'invdate',索引:'invdate',宽度:90,可编辑:true},
{名称:'name',索引:'name asc,invdate',宽度:100},
{名称:'amount',索引:'amount',宽度:80,对齐:“right”,可编辑:true,可编辑规则:{number:true},
{name:'tax',index:'tax',width:80,align:“right”,edit:true,editrules:{number:true},
{名称:'total',索引:'total',宽度:80,对齐:“right”},
{名称:'note',索引:'note',宽度:150,可排序:false}
],
rowNum:10,
行列表:[10,20,30],
传呼机:“#pcelltbl”,
sortname:'id',
viewrecords:是的,
巫师:“描述”,
标题:“单元格编辑示例”,
forceFit:对,
是的,
cellsubmit:'客户端阵列',
afterEditCell:函数(id、名称、val、iRow、iCol){
如果(名称=='invdate'){
jQuery(“#“+iRow+”#invdate“,“#celltbl”).datepicker({dateFormat:“yy-mm-dd”});
}
},
afterSaveCell:函数(rowid、名称、val、iRow、iCol){
如果(名称=‘金额’){
var-taxval=jQuery(“#celltbl”).jqGrid('getCell',rowid,iCol+1);
jqGrid('setRowData',rowid,{total:parseFloat(val)+parseFloat(taxval)});
}
如果(名称=‘税’){
var amtval=jQuery(#celltbl”).jqGrid('getCell',rowid,iCol-1);
jqGrid('setRowData',rowid,{total:parseFloat(val)+parseFloat(amtval)});
}
}});
jQuery(“#celltbl”).jqGrid('navGrid','#pgwidth',{edit:false,add:false,del:false});
最后,这是我的php中的代码:

<?php
include("../../connections/xxxxxxxx");
$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;
// connect to the database
$db = mysql_connect($dbhost, $dbuser, $dbpassword)
or die("Connection Error: " . mysql_error());

mysql_select_db("griddemo") or die("Error conecting to db.");
$result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE          a.client_id=b.client_id");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];

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)
$SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a,     clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit";
$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$responce = new stdClass();
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
    $responce->rows[$i]['id']=$row[id];
    $responce->rows[$i] ['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[not e]);
    $i++;
}        
echo json_encode($responce);
?>


现在网格显示的是标题,而不是可编辑的行。有什么想法吗?我知道这是一个复杂的问题,我问你以前是否使用过这个例子?谢谢您的帮助。

在您的代码中,我看到了许多问题

  • 将所有出现的#celltbl替换为#list2,因为您的表id是list2
  • 出于同样的原因,将所有出现的#pgwidth和#pcelltbl替换为#pager2
  • 放置错误报告(E_全部和~E_通知);在php处理中,as代码包含与JSON响应不兼容的注意错误

  • 您还可以使用firebug>net>ajax响应对其进行调试,不管json输出是否出现。另外,请检查jqgrid php包装器,因为它使用起来非常方便。

    您确定启用了“单元格编辑”模块吗?您是否尝试过使用捆绑的jqGrid和您的
    jquery.jqGrid.min.js
    版本的演示包()中的
    celledit.html
    ?亲爱的tmuguet,是的,我尝试过。当我尝试从本地主机加载该表时,该示例甚至没有显示该表!嗯,我并不感到惊讶,这不是我第一次看到jqGrid的演示神秘地没有“开箱即用”。对不起,我帮不了你更多,我从来没有用过手机编辑。。。