DIR : /home/kozerus/public_html/ko_center/js/jqgrid_demo35/searching.html
/home/kozerus/public_html/ko_center/js/jqgrid_demo35
<div style="font-size:12px;">
This example show how we can add dialog for live data search.<br/>
See below for all available options. <br/>
</div>
<br />
<table id="search" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pagersr" class="scroll" style="text-align:center;"></div>
<input type="BUTTON" id="bsdata" value="Search" />
<script src="searching.js" type="text/javascript"> </script>
<br /><br />
<div style="font-size:12px;">
<b> Description </b>
<br />
This method uses <b>colModel</b> names and <b>url</b> parameters from jqGrid <br/>
<code>
Calling:
jQuery("#grid_id").searchGrid( options );
</code>
<br/>
<b> options </b> <br/>
<b>top : 0</b> the initial top position of search dialog<br/>
<b>left: 0</b> the initinal left position of search dialog<br/>
If the left and top positions are not set the dialog apper on<br/>
upper left corner of the grid <br/>
<b>width: 360</b>, the width of serch dialog - default 360<br/>
<b>height: 70</b>, the height of serch dialog default 70<br/>
<b>modal: false</b>, determine if the dialog should be in modal mode default is false<br/>
<b>drag: true</b>,determine if the dialog is dragable default true<br/>
<b>caption: "Search..."</b>,the caption of the dialog<br/>
<b>Find: "Find"</b>, the text of the button when you click to search data default Find<br/>
<b>Reset: "Reset"</b>,the text of the button when you click to clear search string default Reset<br/>
<b>dirty: false</b>, applicable only in navigator see the last example<br/>
These parameters are passed to the url <br/>
<b>sField:'searchField'</b>, is the name that is passed to url the value is the name from colModel<br/>
<b>sValue:'searchString'</b>,is the name that is passed to url the value is the entered value<br/>
<b>sOper: 'searchOper'</b>, is the name that is passed to the url the value is the type of search - see sopt array<br/>
// translation string for the search options<br/>
<b>odata : ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','ends with','contains' ]</b>,<br/>
// if you want to change or remove the order change it in sopt<br/>
<b>sopt: null // ['bw','eq','ne','lt','le','gt','ge','ew','cn']</b> <br/>
by default all options are allowed. The codes are as follow:<br/>
bw - begins with ( LIKE val% )<br/>
eq - equal ( = )<br/>
ne - not equal ( <> )<br/>
lt - little ( < )<br/>
le - little or equal ( <= )<br/>
gt - greater ( > )<br/>
ge - greater or equal ( >= )<br/>
ew - ends with (LIKE %val )<br/>
cn - contain (LIKE %val% )<br/>
<b> HTML </b>
<XMP>
...
<table id="search" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pagersr" class="scroll" style="text-align:center;"></div>
<input type="BUTTON" id="bsdata" value="Search" />
</XMP>
<b>Java Scrpt code</b>
<XMP>
...
jQuery("#search").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('#pagersr'),
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"Search Example",
editurl:"someurl.php"
});
$("#bsdata").click(function(){
jQuery("#search").searchGrid(
{sopt:['cn','bw','eq','ne','lt','gt','ew']}
);
});
</XMP>
<b>PHP with MySQL</b>
<XMP>
...
$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("Couldnt 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>";
// 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
Drag mouse to navigate.
Navigation
- Left/Right Mouse drag: Changes camera heading.
- Up/Sown Mouse drag: Changes camera pitch.
- Scroll wheel: Changes camera field of view.
- I-Key: Displays Info panel with canvas size, image size and FPS.
17.Aug.2010, Martin Wengenmayer