Forum


03:43

27/12/2009

Hello to everyone !!
First of all, sorry for my english, I don't speak and write it well.
this is my code:
.....
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#list").jqGrid({
url:'example.php',
datatype: 'xml',
mtype: 'GET',
colNames:['id','titolo'],
colModel :[
{name:'id', index:'id', width:200},
{name:'titolo', index:'titolo', width:600, editable: true}
],
editurl: "edit.php",
pager: '#pager',
rowNum:10,
rowList:[10,20,30],
sortname: 'id',
sortorder: 'desc',
viewrecords: true,
caption: 'La mia tabella'
});
$("#bedata").click(function(){
var gr = jQuery("#list").jqGrid('getGridParam','selrow');
if( gr != null ) jQuery("#list").jqGrid('editGridRow',gr,{height:280,reloadAfterSubmit:false});
else alert("Seleziona una riga da modifcare !");
});
});
</script>
</head>
<body>
<table id="list"></table>
<div id="pager"></div>
<input type="button" id="bedata" value="edit selected" />
</body>
</html>
1st question)
I would like to open the formedit dialog with a "double clik" on the row that I choose, (I don't want press the button "edit selected"). How can I do it?
2nd question)
what kind of data is post the file "edit.php" and how can I use it for save the data in a mysql table?
Thank You for Everything !
Andrea
06:56

27/12/2009

edit,
I try to edit the code like this:
<script type="text/javascript">
var lastsel
jQuery(document).ready(function(){
jQuery("#list").jqGrid({
url:'example.php',
datatype: 'xml',
mtype: 'GET',
colNames:['id','titolo'],
colModel :[
{name:'id', index:'id', width:200},
{name:'titolo', index:'titolo', width:600, editable: true}
],
ondblClickRow: function(id){
if(id && id!==lastsel){
jQuery('#list').jqGrid('restoreRow',lastsel);
jQuery('#list').jqGrid('editGridRow',id);
lastsel=id;
}
},
editurl: "edit.php",
pager: '#pager',
rowNum:10,
rowList:[10,20,30],
sortname: 'id',
sortorder: 'desc',
viewrecords: true,
caption: 'La mia tabella'
});
});
</script>
now, on a doubleclick on o row, I can edit data using formedit dialog.
this is my file edit.php
<?php
//I connect to my database and it's all rigth
// How can I recovery the data passed from the formedit dialog ??
// $id = $_POST['id']; // like this ??
// $titolo = $_POST['titolo']; // like this ??
$sql=" UPDATE my_tab SET titolo='$titolo' WHERE id='$id' "
$res=mysql_query($sql,$db) or die(mysql_error());
?>
Most Users Ever Online: 715
Currently Online:
50 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66