Reputation: 619
I am able to populate a grid as well as perform update, both via a php call to server. I cannot seem to construct a grid that does both. In the code below, I have both url and editurl. Both point to the same php page, but I think this is necessary. On the php page, I am collecting the contents of the cells via POST and printing them to a file. I know this code is accurate because it works when I use it with a grid that only saves data and doesn't attempt to populate with a php server call. Being fairly new to JQGrid, I'm not sure how data is saved and sent. Also note that I had to use datatype: 'local' to save the data, but I have to use datatype: 'xml' to populate the grid. Perhaps this is the problem?
$("#list").jqGrid({
url:'functions.php',
datatype:'xml',
mtype:'POST',
colNames:['Label','Account_Num','Amount', 'Type Code', 'Record Code', 'Sequence','Actions'],
colModel :[
{name:'label', index:'label', width:150, align:'center', sortable:false, editable:true},
{name:'cntrct_id', index:'cntrct_id', width:150, align:'center', sortable:true},
{name:'amount', index:'amount', width:150, align:'center', sortable:false, editable:true},
{name:'type_cd', index:'type_cd', width:150, align:'center', sortable:false, editable:true},
{name:'rec_cd', index:'rec_cd', width:150, align:'center', sortable:false},
{name:'db_seq', index:'db_seq', width:150, align:'center', sortable:false},
{ name:'actions',
classes:'jg_actions',
formatter:"actions",
editable:false,
sortable:false,
resizable:false,
fixed:true,
width:120,
formatoptions:{
keys:true,
delbutton:true,
onSuccess: function(response){
},
},
},
],
editurl: 'functions.php',
postData: {
action:'popGrid',
sqlCount:sqlCount,
sqlSelect:sqlSelect,
sqlSelect2:sqlSelect2,
label1:label1,
label2:label2,},
onSelectRow: function(id){
if(id && id!==lastSel){
jQuery('#list').restoreRow(lastSel);
jQuery('#list').editRow(id,true);
lastSel=id;
}
},
pager: '#pager',
rowNum:100,
rowList:[100,200,300,400,500,600,700,800,900,1000],
sortname: 'cntrct_id',
sortorder: 'desc',
viewrecords: true,
caption: 'Adjustments'
});
<?php
$label = $_POST['label'];
$cntrct_id = $_POST['cntrct_id'];
$amount = $_POST['amount'];
$type_cd = $_POST['type_cd'];
$rec_cd = $_POST['rec_cd'];
$db_seq = $_POST['db_seq'];
$myfile = "text.txt";
$fh = fopen($myfile,'a');
fwrite($fh,$label.' '.$cntrct_id.' '.$amount.' '.$type_cd.' '.$rec_cd.' '.$db_seq);
fclose($fh);
?>
Upvotes: 0
Views: 270
Reputation: 3123
I think you are confused on XML vs Local datatypes. What the datatype specifies is where the data to feed the grid will come from. Local means that you are providing a variable that has data in it from some other portion on the client side where XML means that you will provide XML formatted data from a URL. (Server side process)
You should be able to use Firebug/Chrome to see the data your grid sends out after an update, the format it is in and where it is going. After your edit, the post to your functions.php
your grid should reload with that reload reflecting the changes to your dataset from your edit.
Upvotes: 1