0
작동하지 않음 yur help! yo 적 jqgrid를 성공적으로 사용 했습니까?있는 jqGrid 복잡한 데모는 내가 내 컴퓨터에서 작업이 예제를 가지고 노력하고 하루 종일입니다
<table id="list2"> </table>
<div id="pager2" > </div>
다음은 내 자바 스크립트 섹션에있는 코드는 다음과 같습니다 :
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});
마지막이 내 PHP의 코드입니다 :
이이
내 HTML 파일의 코드입니다<?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);
?>
이제 표는 헤더를 표시하지만 편집 가능한 행은 표시하지 않습니다. 어떤 생각? 이 예제를 사용했는지 묻는 질문은 복잡한 질문입니다. 도와 줘서 고마워.
'셀 편집'모듈이 활성화되어 있습니까? 데모 패키지 (http://www.trirand.com/blog/?page_id=6)에서'celledit.html'을 jqGrid 번들과'jquery.jqGrid.min.js' 버젼으로 시도 했습니까? – tmuguet
친애하는 tmuguet, 네, 했어요. 그 예제는 심지어 내 localhost에서로드하려고 할 때 테이블을 표시하지 않습니다! – user1536396
음,별로 놀랍지는 않습니다. 처음에는 jqGrid의 데모가 신기하게도 "밖에서"작업하지 않는 것을 보았습니다. 죄송합니다. 더 이상 도와 드릴 수 없습니다. 셀 편집을 한 번도 해보지 않았습니다 ... – tmuguet