Forum


22:28

01/05/2009

Im having trouble with searching data. Everytime I type the search string, the navigation wont function (next, previous, etc). Sometimes the search box wont close. Here's the javascript i wrote
$(document).ready(function(){
$("#list").jqGrid({
url:'/administrators/groups/data',
datatype: 'xml',
mtype: 'POST',
colNames:['ID','Name', 'Description'],
colModel :[
{name:'groupid', index:'groupid', width:20},
{name:'groupname', index:'groupname'},
{name:'groupdesc', index:'groupdesc'}],
pager: jQuery('#pager'),
autowidth: true,
rowNum:10,
rowList:[10,20,30],
sortname: 'groupid',
sortorder: "asc",
viewrecords: true,
ondblClickRow: function(rowid){
alert(rowid);
},
imgpath: '/themes/lightness/images',
caption: 'Group List'
}).navGrid('#pager',{edit:false,add:false,del:false});
jQuery("#list").searchGrid(modal:true);
});
For the server side I use Codeigniter
function xml()
{
$searchval = $_POST['searchString'];
$searchfld = $_POST['searchField'];
if($searchval <> '' && $searchfld <> ''):
$where = "WHERE $searchfield LIKE '%$searchval%' ";
endif;
$page = $_POST['page'];
$limit = $_POST['rows'];
$sidx = $_POST['sidx'];
$sord = $_POST['sord'];
if(!$sidx) $sidx = 1;
$sql = "SELECT COUNT(*) AS count FROM bigp_web_group $where";
$query = $this->db->query($sql);
$row = $query->row_array();
$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;
if($start < 0) $start = 0;
$SQL = "SELECT * FROM (SELECT r.*, ROWNUM as row_number FROM ( ";
$SQL.= "SELECT * FROM bigp_web_group $where ORDER BY $sidx $sord) r ";
$SQL.= "WHERE ROWNUM <= ".($limit*$page)." ) ";
$SQL.= "WHERE ".($start+1)." <= row_number";
$query = $this->db->query($SQL);
$post = print_r($_POST, true);
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");
}
echo "<?xml version='1.0' encoding='utf-8'?>";
echo "<rows>";
echo "<page>".$page."</page>";
echo "<total>".$total_pages."</total>";
echo "<records>".$count."</records>";
foreach ($query->result_array() as $row) {
echo "<row id='". $row['GROUPID']."'>";
echo "<cell>".$row['GROUPID']."</cell>";
echo "<cell>".$row['GROUPNAME']."</cell>";
echo "<cell><![CDATA[".$post."]]></cell>";
echo "</row>";
}
echo "</rows>";
}
Most Users Ever Online: 715
Currently Online:
57 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