dearsh
|
|
« on: August 11, 2013, 12:39:28 AM » |
|
Hello all, I have concerns about the use of filters on combogrid remote mode. I have tried the tutorial you know about filters combogrid http://www.jeasyui.com/tutorial/form/form5.phpAfter I try to implement it turns out the use of the filter is not running. It looks like the query parameter q in sintact $ q = isset ($ _POST ['q']) ? strval ($ _POST ['q']) : '' ; does not run / not functioning properly. Please help to solve the problem. thank you. -dearsh -
|
|
|
Logged
|
|
|
|
varonica
|
|
« Reply #1 on: August 11, 2013, 07:53:26 PM » |
|
Writing some codes might be helpful to identify the problems.
|
|
|
Logged
|
|
|
|
dearsh
|
|
« Reply #2 on: August 13, 2013, 12:40:09 AM » |
|
This is my code 1. File Index.php <html> ....... <script> $(function(){ $('#cg').combogrid({ panelWidth:500, url:'get_data_tabel.php', idField:'id', textField:'uraian', mode:'remote', striped: true, editable:true, collapsible:false, rownumbers:true, fit:true, fitColumns:true, pagination:true, pageSize: 10, pageList: [10], columns:[[ {field:'id',title:'Id',width:5,hidden:true}, {field:'uraian',title:'Uraian',width:10}, {field:'keterangan',title:'Keterangan',widht:60}, {field:'active',title:'Status',width:10} ]] }); }); </script> <body> <h2> Filter in Combogrid </h1> <input id="cg" style="width:150px"></input> </body> </html>
2. File get_data_tabel.php <?php include 'config.php'; $q = isset($_POST['q']) ? strval($_POST['q']) : ''; $page = isset($_POST['page']) ? intval($_POST['page']) : 1; $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; $offset = ($page-1)*$rows; $result = array(); //$where = "uraian like '%a%' or keterangan like '%a%'"; //$rs = mysql_query("select count(*) from tb_referensi where ".$where); $rs = mysql_query("select count(*) from tb_referensi where uraian like '%$q%' or keterangan like '%$q%' "); $row = mysql_fetch_row($rs); $result["total"] = $row[0]; $rs = mysql_query("select * from tb_referensi where uraian like '%$q%' or keterangan like '%$q%' limit $offset,$rows "); $items = array(); while($row = mysql_fetch_object($rs)){ array_push($items, $row); } $result["rows"] = $items;
echo json_encode($result); ?>
3. File config.php <?php
$conn = @mysql_connect('127.0.0.1','root','','9090'); if (!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db('gammu', $conn);
?>
|
|
|
Logged
|
|
|
|
patana
|
|
« Reply #3 on: August 16, 2013, 09:34:03 AM » |
|
Your code works fine as i tested it. I'm not sure if it was a problems from typo or somethings else. 3. File config.php <?php
$conn = @mysql_connect('127.0.0.1','root','','9090'); <- 9090 should be named as "tb_referensi". if (!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db('gammu', $conn);
?>
|
|
|
Logged
|
|
|
|
dearsh
|
|
« Reply #4 on: August 16, 2013, 01:52:34 PM » |
|
9090 is mysql port that i used.
Btw when you tested mycode, filter combogrid work fine or not ? especially when we type a word in combogrid, whether the contents of combogrid adjust (filtered) based on the parameters that we just type that?
|
|
|
Logged
|
|
|
|
varonica
|
|
« Reply #5 on: August 16, 2013, 09:08:02 PM » |
|
It works fine. Can you describe in detail of what you want ?
|
|
|
Logged
|
|
|
|
dearsh
|
|
« Reply #6 on: August 16, 2013, 11:41:48 PM » |
|
This code is not worked when running (File get_data_tabel.php)
$q = isset($_POST['q']) ? strval($_POST['q']) : ''; -> Line 3
$rs = mysql_query("select count(*) from tb_referensi where uraian like '%$q%' or keterangan like '%$q%' "); -> Line 11
$rs = mysql_query("select * from tb_referensi where uraian like '%$q%' or keterangan like '%$q%' limit $offset,$rows "); -> Line 14
|
|
|
Logged
|
|
|
|
patana
|
|
« Reply #7 on: August 17, 2013, 03:35:01 AM » |
|
What's the error ?
|
|
|
Logged
|
|
|
|
dearsh
|
|
« Reply #8 on: August 17, 2013, 03:37:54 AM » |
|
Filtered is not work.whatever i type word in combogrid
|
|
|
Logged
|
|
|
|
patana
|
|
« Reply #9 on: August 17, 2013, 09:16:30 AM » |
|
Try the following: index.php <html> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css"> <link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/demo/demo.css"> <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script> <script> $(function(){ $('#cg').combogrid({ panelWidth:500, url:'get_data_tabel.php', idField:'id', textField:'uraian', mode:'remote', striped: true, editable:true, collapsible:false, rownumbers:true, fit:true, fitColumns:true, pagination:true, pageSize: 10, pageList: [10], columns:[[ {field:'id',title:'Id',width:5,hidden:true}, {field:'uraian',title:'Uraian',width:10}, {field:'keterangan',title:'Keterangan',widht:60}, {field:'active',title:'Status',width:10} ]] }); }); </script> <body> <h2> Filter in Combogrid </h1> <input id="cg" style="width:150px"></input> </body> </html>
get_data_tabel.php <?php include 'config.php'; $q = isset($_POST['q']) ? strval($_POST['q']) : ''; $page = isset($_POST['page']) ? intval($_POST['page']) : 1; $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; $offset = ($page-1)*$rows; $result = array(); //$where = "uraian like '%a%' or keterangan like '%a%'"; //$rs = mysql_query("select count(*) from tb_referensi where ".$where); $rs = mysql_query("select count(*) from tb_referensi where uraian like '%$q%' or keterangan like '%$q%' "); $row = mysql_fetch_row($rs); $result["total"] = $row[0]; $rs = mysql_query("select * from tb_referensi where uraian like '%$q%' or keterangan like '%$q%' limit $offset,$rows "); $items = array(); while($row = mysql_fetch_object($rs)){ array_push($items, $row); } $result["rows"] = $items;
echo json_encode($result); ?>
config.php <?php
$conn = @mysql_connect('127.0.0.1','root',''); if (!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db('mydb', $conn);
?>
|
|
« Last Edit: August 17, 2013, 10:16:05 PM by patana »
|
Logged
|
|
|
|
dearsh
|
|
« Reply #10 on: August 18, 2013, 02:33:16 AM » |
|
It's work.
Thx Very Much
- dearsh -
|
|
|
Logged
|
|
|
|
|