DIR : /home/kozerus/public_html/ko_center/js/jqgrid_demo35/toolbar.html

/home/kozerus/public_html/ko_center/js/jqgrid_demo35

<div style="font-size:12px;">
    This example show how we can add toolbars at top or bottom of the body
</div>
<br />
<table id="toolbar1" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pgtoolbar1" class="scroll" style="text-align:center;"></div>
<br/>
<table id="toolbar2" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pgtoolbar2" class="scroll" style="text-align:center;"></div>
<script src="toolbar.js" type="text/javascript"> </script>
<br />
<div style="font-size:12px;">
<b> HTML </b>
<XMP>
...
<table id="toolbar1" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pgtoolbar1" class="scroll" style="text-align:center;"></div>
<br/>
<table id="toolbar2" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pgtoolbar2" class="scroll" style="text-align:center;"></div>
<script src="toolbar.js" type="text/javascript"> </script>
</XMP>    
<b>Java Scrpt code</b>
<XMP>
...
jQuery("#toolbar1").jqGrid({
   	url:'server.php?q=1',
	datatype: "xml",
   	colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
   	colModel:[
   		{name:'id',index:'id', width:55},
   		{name:'invdate',index:'invdate', width:90},
   		{name:'name',index:'name', width:100},
   		{name:'amount',index:'amount', width:80, align:"right"},
   		{name:'tax',index:'tax', width:80, align:"right"},		
   		{name:'total',index:'total', width:80,align:"right"},		
   		{name:'note',index:'note', width:150, sortable:false}		
   	],
   	rowNum:10,
   	rowList:[10,20,30],
   	imgpath: gridimgpath,
   	pager: jQuery('#pgtoolbar1'),
   	sortname: 'id',
    viewrecords: true,
    sortorder: "desc",
    caption:"Toolbar Example",
    editurl:"someurl.php",
	toolbar: [true,"top"]
}).navGrid('#pgtoolbar1',{edit:false,add:false,del:false});

$("#t_toolbar1").append("<input type='button' value='Click Me' style='height:20px;font-size:-3'/>");
$("input","#t_toolbar1").click(function(){
	alert("Hi! I'm added button at this toolbar");
});
jQuery("#toolbar2").jqGrid({        
   	url:'server.php?q=1',
	datatype: "xml",
   	colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
   	colModel:[
   		{name:'id',index:'id', width:55},
   		{name:'invdate',index:'invdate', width:90},
   		{name:'name',index:'name', width:100},
   		{name:'amount',index:'amount', width:80, align:"right"},
   		{name:'tax',index:'tax', width:80, align:"right"},		
   		{name:'total',index:'total', width:80,align:"right"},		
   		{name:'note',index:'note', width:150, sortable:false}		
   	],
   	rowNum:10,
   	rowList:[10,20,30],
   	imgpath: gridimgpath,
   	pager: jQuery('#pgtoolbar2'),
   	sortname: 'id',
    viewrecords: true,
    sortorder: "desc",
    caption:"User Data Example",
    editurl:"someurl.php",
	toolbar: [true,"bottom"],
	loadComplete: function() {
		var udata = $("#toolbar2").getUserData();
		$("#t_toolbar2").css("text-align","right").html("Totals Amount:"+udata.tamount+" Tax: "+udata.ttax+" Total: "+udata.ttotal+ "&nbsp;&nbsp;&nbsp;");
	}
}).navGrid('#pgtoolbar2',{edit:false,add:false,del:false});

</XMP>
<b>PHP with MySQL</b>
<XMP>
$result = mysql_query("SELECT COUNT(*) AS count, SUM(amount)AS amount, SUM(tax) AS tax, SUM(total) AS total FROM invheader a, clients b WHERE a.client_id=b.client_id ".$wh);
$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)
if ($start<0) $start = 0;
$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".$wh." ORDER BY ".$sidx." ". $sord." LIMIT ".$start." , ".$limit;
$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());

if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
header("Content-type: application/xhtml+xml;charset=utf-8"); } else {
header("Content-type: text/xml;charset=utf-8");
}
$et = ">";
echo "<?xml version='1.0' encoding='utf-8'?$et\n";

echo "<rows>";
echo "<page>".$page."</page>";
echo "<total>".$total_pages."</total>";
echo "<records>".$count."</records>";
echo "<userdata name='tamount'>".$row['amount']."</userdata>";
echo "<userdata name='ttax'>".$row['tax']."</userdata>";
echo "<userdata name='ttotal'>".$row['total']."</userdata>";
// be sure to put text data in CDATA
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
	echo "<row id='". $row[id]."'>";			
	echo "<cell>". $row[id]."</cell>";
	echo "<cell>". $row[invdate]."</cell>";
	echo "<cell><![CDATA[". $row[name]."]]></cell>";
	echo "<cell>". $row[amount]."</cell>";
	echo "<cell>". $row[tax]."</cell>";
	echo "<cell>". $row[total]."</cell>";
	echo "<cell><![CDATA[". $row[note]."]]></cell>";
	echo "</row>";
}
echo "</rows>";		
</XMP>
</div>
//


koh5_pano



Your browser does not support the HTML5 canvas element.


Drag mouse to navigate.

Navigation





17.Aug.2010, Martin Wengenmayer