EasyUI Forum
May 21, 2024, 07:40:21 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: search in datagrid no action  (Read 3704 times)
nsengi
Newbie
*
Posts: 1


View Profile
« on: October 17, 2016, 03:12:26 AM »

Hi, I don't know what I miss but my search doesn't work, can you tell me what I make wrong please?

Here is all my scripts:

index.php

Code:
<?php
include '../header.php';
include 
'../conn.php';
?>

<!-- page content -->
<link rel="stylesheet" type="text/css" href="../crud_script/easyui.css">
<link rel="stylesheet" type="text/css" href="../crud_script/icon.css">
<link rel="stylesheet" type="text/css" href="../crud_script/color.css">
<link rel="stylesheet" type="text/css" href="../crud_script/demo.css">
<!--jQuery.noConflict(true);-->
<!--<script type="text/javascript" src="jquery-1.6.min.js"></script>-->
<script type="text/javascript" src="../crud_script/jquery.easyui.min.js"></script>

                            <table id="dg" class="easyui-datagrid" style="width:100%;height:auto"
                                   url="get_users.php"
                                   toolbar="#toolbar" pagination="true"
                                   rownumbers="true" fitColumns="true" singleSelect="true">
                                <thead>
                                    <tr>
                                        <th field="firstname" width="50" sortable="true">First Name</th>
                                        <th field="lastname" width="50">Last Name</th>
                                        <th field="phone" width="50">Phone</th>
                                        <th field="email" width="50">Email</th>
                                    </tr>
                                </thead>
                            </table>
                           
                        </center>
                        <div id="toolbar">
                           
                            &nbsp;&nbsp;&nbsp;&nbsp;
                           [b][color=red]<input id="search" style="line-height:18px;border:1px solid #ccc"/>
                            <a href="#" class="easyui-linkbutton" plain="true" onclick="doSearch()">Search</a>[/color][/b]
                        </div>
                       
                        <script type="text/javascript">
                            //...
                            function doSearch() {
                                var c = $('#search').val()
                                alert(c);
                                $('#dg').datagrid('load', {
                                    search: $('#search').val()
                                });
                            }
                        </script>
               
<?php
include '../footer.php';

And my get_users.php:

Code:
<?php

$page 
= isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$search = isset($_POST['search']) ? mysql_real_escape_string($_POST['search']) : '';
$sort = isset($_POST['sort']) ? strval($_POST['sort']) : 'firstname';
$order = isset($_POST['order']) ? strval($_POST['order']) : 'asc';
$offset = ($page 1) * $rows;
//$search ='nse';
$result = array();

$where "firstname like '%".$search."%'";

include 
'../conn.php';

$stmt1 $db->prepare("select count(*) AS count from tbl_staff where " $where);
$stmt1->execute(array());
$rowcount $stmt1->rowCount();
if (
$rowcount 0)// ...
    
{
    
$rows_ $stmt1->fetch(PDO::FETCH_ASSOC);
    
$result["total"] = $rows_['count'];
    }
//-------------
$stmt12 $db->prepare("select * from tbl_staff where " $where " order by $sort $order  limit " $offset "," $rows "");
$stmt12->execute(array());
$rowcount $stmt12->rowCount();
if (
$rowcount 0)// ...
    
{
    
$items = array();
    WHILE (
$rows $stmt12->fetch(PDO::FETCH_ASSOC)) {
        
array_push($items$rows);
    }
    
$result["rows"] = $items;
    }

echo 
json_encode($result);
?>


How to make the search by keyup and for data already loaded without requesting again the server (I followed the post: http://www.jeasyui.com/forum/index.php?topic=3420.0 and the documentation but no result).

Thanks
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: October 18, 2016, 03:24:11 PM »

Calling load or reload methods will make a new request to the server. Please open your browser's debug tool to see if the data can be loaded from your server.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!