<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: jqgrid edit delete add buttons</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-edit-delete-add-buttons</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/jqgrid-edit-delete-add-buttons/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on jqgrid edit delete add buttons</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-edit-delete-add-buttons#p31027</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-edit-delete-add-buttons#p31027</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Â </p>
<p>You define the pager as jQuery object.</p>
<p>Not sure, but try to define it only as string i.e</p>
<p>Â </p>
<p>pager: '#pager2',</p>
<p>Â </p>
<p>Regards</p>
]]></description>
        	        	<pubDate>Fri, 29 Aug 2014 11:00:27 +0300</pubDate>
        </item>
        <item>
        	<title>hindos on jqgrid edit delete add buttons</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-edit-delete-add-buttons#p31017</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-edit-delete-add-buttons#p31017</guid>
        	        	<description><![CDATA[<p>hiiiii im a newbie in using jqgrid the bottons in the navgrid are non cliquable ??? and pleaase i need someone to check and correct my code or provide me with an example to edit and delete and thanks a lotÂ </p>
<p>final.htmlÂ </p>
<p>&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;<br />
&#60;html xmlns="http://www.w3.org/1999/xhtml"&#62;<br />
&#60;head&#62;<br />
&#60;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&#62;<br />
&#60;title&#62;jqGrid Demo&#60;/title&#62;<br />
&#60;style&#62;<br />
html, body {<br />
 margin: 0; /* Remove body margin/padding */<br />
 padding: 0;<br />
 overflow: auto; /* Remove scroll bars on browser window */<br />
 font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;<br />
}<br />
&#60;/style&#62;<br />
&#60;!-- In head section we should include the style sheet for the grid --&#62;<br />
&#60;link rel="stylesheet" type="text/css" media="screen" href="themes/redmond/jquery-ui-1.8.2.custom.css" /&#62;</p>
<p>&#60;!-- Of course we should load the jquery library --&#62;<br />
&#60;script src="js/jquery.min.js" type="text/javascript"&#62;&#60;/script&#62;<br />
&#60;script src="js\src\i18n\grid.locale-fr.js" type="text/javascript"&#62;&#60;/script&#62;<br />
&#60;!-- and at end the jqGrid Java Script file --&#62;<br />
&#60;script src="js/jquery.jqGrid.min.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;script type="text/javascript"&#62;<br />
// We use a document ready jquery function.<br />
jQuery(document).ready(function(){<br />
jQuery("#list2").jqGrid({<br />
 // the url parameter tells from where to get the data from server<br />
 // adding ?nd='+new Date().getTime() prevent IE caching<br />
 url:'final.php?nd='+new Date().getTime(),<br />
 // datatype parameter defines the format of data returned from the server<br />
 // in this case we use a JSON data<br />
 datatype: "json",<br />
 // colNames parameter is a array in which we describe the names<br />
 // in the columns. This is the text that apper in the head of the grid.<br />
 colNames:['nom','prenom', 'date','cin','role'],<br />
 // colModel array describes the model of the column.<br />
 // name is the name of the column,<br />
 // index is the name passed to the server to sort data<br />
 // note that we can pass here nubers too.<br />
 // width is the width of the column<br />
 // align is the align of the column (default is left)<br />
 // sortable defines if this column can be sorted (default true)<br />
 colModel:[<br />
 {name:'nom',index:'nom', width:100, align:"center", editable:true},<br />
 {name:'prenom',index:'prenom', width:100, align:"center", editable:true},<br />
 {name:'date',index:'date', width:100, align:"center", editable:true},<br />
 {name:'cin',index:'cin', width:80, align:"right", align:"center", editable:true},<br />
 {name:'role',index:'role', width:150, align:"right", align:"center", editable:true} </p>
<p> ],<br />
 // pager parameter define that we want to use a pager bar<br />
 // in this case this must be a valid html element.<br />
 // note that the pager can have a position where you want<br />
 pager: jQuery('#pager2'),<br />
 // rowNum parameter describes how many records we want to<br />
 // view in the grid. We use this in example.php to return<br />
 // the needed data.<br />
 //rowNum:10,<br />
 // rowList parameter construct a select box element in the pager<br />
 //in wich we can change the number of the visible rows<br />
 //rowList:[10,20,30],<br />
 // sortname sets the initial sorting column. Can be a name or number.<br />
 // this parameter is added to the url<br />
 sortname: 'nom',<br />
 //viewrecords defines the view the total records from the query in the pager<br />
 //bar. The related tag is: records in xml or json definitions.<br />
 viewrecords: true,<br />
 gridview: true,<br />
 //mtype: 'GET',<br />
 autoencode: true,<br />
 //sets the sorting order. Default is asc. This parameter is added to the url<br />
 sortorder: "desc",<br />
 editurl: "finalEdit.php",<br />
 caption: "liste des utilisateurs"<br />
 //autowidth:true</p>
<p>});<br />
jQuery("#list2").jqGrid('navGrid','#pager2',{edit:true,add:false,del:false,search:true,refresh:true},<br />
 {},{},{},{multipleSearch:true});<br />
});</p>
<p>$("#bedata").click(function(){<br />
 var gr = mygrid.jqGrid('getGridParam','selrow');<br />
 if( gr != null )<br />
 mygrid.jqGrid('editGridRow',gr,{height:480,reloadAfterSubmit:false});<br />
 else alert("Please Select Row");<br />
 });<br />
 $("#dedata").click(function(){<br />
 var gr = jQuery("#delgrid").jqGrid('getGridParam','selrow');<br />
 //getSelectedRow();<br />
 if( gr != null ) jQuery("#delgrid").jqGrid('delGridRow',gr,{reloadAfterSubmit:false});<br />
 else alert("Please Select Row to delete!");<br />
});<br />
&#60;/script&#62;<br />
&#60;/head&#62;<br />
&#60;body&#62;<br />
&#60;center&#62;<br />
&#60;!-- the grid definition in html is a table tag with class 'scroll' --&#62;<br />
&#60;table id="list2"&#62;&#60;/table&#62;</p>
<p>&#60;!-- pager definition. class scroll tels that we want to use the same theme as grid --&#62;<br />
&#60;div id="pager2"&#62;&#60;/div&#62;<br />
&#60;center&#62;<br />
&#60;/body&#62;<br />
&#60;/html&#62;</p>
<p>final.php</p>
<p>&#60;?php<br />
// Include the information needed for the connection to<br />
// MySQL data base server.<br />
include("dbconfig.php");<br />
//since we want to use a JSON data we should include<br />
//encoder and decoder for JSON notation<br />
//If you use a php &#62;= 5 this file is not needed<br />
//include("JSON.php");</p>
<p>// create a JSON service<br />
//$json = new Services_JSON();</p>
<p>// to the url parameter are added 4 parameter<br />
// we shuld get these parameter to construct the needed query<br />
// for the pager</p>
<p>// get the requested page</p>
<p>$page = $_GET['page'];</p>
<p>// get how many rows we want to have into the grid<br />
// rowNum parameter in the grid<br />
$limit = $_GET['rows'];<br />
// get index row - i.e. user click to sort<br />
// at first time sortname parameter - after that the index from colModel<br />
$sidx = $_GET['sidx'];<br />
// sorting order - at first time sortorder<br />
$sord = $_GET['sord'];</p>
<p>// if we not pass at first time index use the first column for the index<br />
if(!$sidx) $sidx =1;<br />
// connect to the MySQL database server<br />
$db = mysql_connect("localhost", "root", "")<br />
or die("Connection Error: " . mysql_error());</p>
<p>// select the database<br />
mysql_select_db("gestion_conges") or die("Error conecting to db.");</p>
<p>// calculate the number of rows for the query. We need this to paging the result<br />
$result = mysql_query("SELECT COUNT(*) AS count FROM utilisateur ");<br />
$row = mysql_fetch_array($result,MYSQL_ASSOC);<br />
$count = $row['count'];</p>
<p>// calculation of total pages for the query<br />
if( $count &#62;0 ) {<br />
 $total_pages = ceil($count/$limit);<br />
} else {<br />
 $total_pages = 0;<br />
}</p>
<p>// if for some reasons the requested page is greater than the total<br />
// set the requested page to total page<br />
if ($page &#62; $total_pages) $page=$total_pages;</p>
<p>// calculate the starting position of the rows<br />
$start = $limit*$page - $limit; // do not put $limit*($page - 1)<br />
// if for some reasons start position is negative set it to 0<br />
// typical case is that the user type 0 for the requested page<br />
if($start &#60;0) $start = 0;</p>
<p>// the actual query for the grid data<br />
$SQL = "SELECT * FROM utilisateur ORDER BY $sidx $sord LIMIT $start , $limit";<br />
$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());</p>
<p>// constructing a JSON</p>
<p>$responce= new stdClass ();<br />
$responce-&#62;page = $page;<br />
$responce-&#62;total = $total_pages;<br />
$responce-&#62;records = $count;<br />
$i=0;<br />
$tab=array();<br />
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {</p>
<p>$element=array('id'=&#62;$row['cin'],<br />
 'cell' =&#62;array($row['nom'],$row['prenom'],$row['date'],$row['cin'],$row['role']));</p>
<p>// $responce-&#62;rows[$i]['id']=$row[0];<br />
 // $responce-&#62;rows[$i]['cell']=array($row[nom],$row[prenom],$row[date],$row[cin],$row[type],$row[num1],$row[num2],$row[adresse],$row[matricule]);<br />
 $i++;<br />
 $tab[]=$element;<br />
}<br />
$responce-&#62;rows=$tab;<br />
// return the formated data<br />
//echo $json-&#62;encode($responce);<br />
echo json_encode($responce);<br />
?&#62;</p>
<p>finalEdit.php</p>
<p>&#60;?php<br />
mysql_connect("localhost","root","");<br />
 mysql_select_db("gestion_conges");<br />
if (($_POST['oper']) == "edit") {<br />
 $updateSQL = sprintf("UPDATE utilisateur SET nom=%s, prenom=%s, date=%s, role=%s WHERE cin=%s",<br />
 GetSQLValueString($_POST['nom'], "text"),<br />
 GetSQLValueString($_POST['prenom'], "text"),<br />
 GetSQLValueString($_POST['date'], "date"),<br />
 GetSQLValueString($_POST['role'], "text"),<br />
 GetSQLValueString($_POST['cin'], "text"));</p>
<p> $Result1 = mysql_query($updateSQL) or die(mysql_error());<br />
}<br />
else if (($_POST['oper']) == "del") {</p>
<p> $deleteSQL = sprintf("DELETE FROM utilisateur WHERE id=%s",<br />
 GetSQLValueString($_POST['cin'], "text"));<br />
 mysql_select_db($database_intranet);<br />
 $Result1 = mysql_query($deleteSQL) or die(mysql_error());<br />
}<br />
?&#62;</p>
]]></description>
        	        	<pubDate>Thu, 28 Aug 2014 00:15:32 +0300</pubDate>
        </item>
</channel>
</rss>