Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Error row edit...
Tags: rowedit
19/12/2011
03:54
Avatar
kiked
New Member
Members
Forum Posts: 2
Member Since:
19/12/2011
sp_UserOfflineSmall Offline

Hi all and sorry for my english..

I have been investigating my code and I can't understand why don't work it...

I can get the rows from my MySQL database but when I edit a row, this is edited only local. The POST doesn't include the new information and when I press reload button, old value return again.

The example is here: /blog/jqgrid/jqgrid.html Row editing using events  -->

HTML

 ...

<table id="rowed3"></table>

<div id="prowed3"></div>

<br />

<script src="rowedex3.js" type="text/javascript"> </script>

Java Scrpt code

 ...

var lastsel;

jQuery("#rowed3").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', width:100,editable:true},

{name:'amount',index:'amount', width:80, align:"right",editable:true},

{name:'tax',index:'tax', width:80, align:"right",editable:true},

{name:'total',index:'total', width:80,align:"right",editable:true},

{name:'note',index:'note', width:150, sortable:false,editable:true}

],

rowNum:10,

rowList:[10,20,30],

pager: '#prowed3',

sortname: 'id',

viewrecords: true,

sortorder: "desc",

onSelectRow: function(id){

if(id && id!==lastsel){

jQuery('#rowed3').jqGrid('restoreRow',lastsel);

jQuery('#rowed3').jqGrid('editRow',id,true);

lastsel=id;

}

},

editurl: "server.php",

caption: "Using events example"

});

jQuery("#rowed3").jqGrid('navGrid',"#prowed3",{edit:false,add:false,del:false});

PHP with MySQL

...

$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($database) 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->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[note]);

$i++;

}

echo json_encode($responce);

...

19/12/2011
15:47
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Please look at documentation.

You will need to write a aditional code for the editing of the row.

jqGrid does not do this, since it does not know which is the server type ASP, PHP or etc.

Please write this code and use the editurl variable for this purpose

http://www.trirand.com/jqgridw.....ne_editing

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

19/12/2011
17:40
Avatar
kiked
New Member
Members
Forum Posts: 2
Member Since:
19/12/2011
sp_UserOfflineSmall Offline

Ok thx very much!

I will read it slowly.Smile

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
60 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information