0

我这里有个小问题...

我有一个像这样的jquery easyui ...

function doSearch(){
            $('#dg').datagrid('load',{
                idCustomer: $('#idCustomer').val(),
                namaCustomer: $('#namaCustomer').val()
            });
        }

然后像这样的html...

<table id="dg" title="Data Customer" class="easyui-datagrid" style="width:auto;height:500px;"  
        url="<?php echo $url;?>"  
        toolbar="#toolbar" 
        pageSize="20"
        rownumbers="true" fitColumns="true" singleSelect="true"
        pagination="true">  
    <thead>  
        <tr>  
            <th field="NoIDCust" width="50" sortable="true">ID Customer</th> 
            <th field="namaCustomer" width="50" sortable="true">Nama Customer</th>
            <th field="alamatCustomer" width="50" sortable="true">Alamat</th>
             <th field="telpCustomer" width="50" sortable="true">No Telepon</th>
             <th field="email" width="50" sortable="true">Email</th>
              <th field="area" width="50" sortable="true">Area</th>

        </tr>  
    </thead>  
</table>  
<div id="toolbar">  
    Nama : <input id="namaCustomer" style="line-height:16px;border:1px solid #ccc">  
    ID Customer :<input id="NoIDCust" style="line-height:16px;border:1px solid #ccc">  
    <a href="#" class="easyui-linkbutton" plain="true" onclick="doSearch()">Cari</a>  
    <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newCustomer()">Tambah Modul</a>  
    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editCustomer()">Edit Modul</a>  
    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeCustomer()">Hapus Modul</a>  
</div>

和一个 php 文件来处理这样的搜索功能......

$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
    $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
    $sort = isset($_POST['sort']) ? strval($_POST['sort']) : 'idCustomer';  
    $order = isset($_POST['order']) ? strval($_POST['order']) : 'asc'; 

    $idCustomer = isset($_POST['idCustomer']) ? mysql_real_escape_string($_POST['idCustomer']) : '';
    $namaCustomer = isset($_POST['namaCustomer']) ? mysql_real_escape_string($_POST['namaCustomer']) : '';



    $offset = ($page-1)*$rows;

    $result = array();

    $where = "namaCustomer like '$namaCustomer%' and idCustomer like '$idCustomer%'";

    $rs = $db->query("select count(*) from customer where ". $where);
    $row = $rs->fetch(PDO::FETCH_NUM);
    $result["total"] = $row[0];

    $rs = $db->query("select * from customer where " . $where ." order by $sort $order limit $offset,$rows");

    $rows = array();
    while($row = $rs->fetch(PDO::FETCH_OBJ)){
    array_push($rows, $row);
    }
    $result["rows"] = $rows;

    echo json_encode($result);

问题是……我的搜索功能不起作用……它返回的数据没有被搜索框功能过滤……所以这意味着就像第一次加载一样加载……

任何机构都可以帮助我??

非常感谢之前..

4

1 回答 1

2

您只需要重新加载网格。doSearch 函数应该是这样的:

    function doSearch(){
        $('#dg').datagrid('load',{
            idCustomer: $('#idCustomer').val(),
            namaCustomer: $('#namaCustomer').val()
        });
        $('#dg').datagrid('reload');
    }
于 2012-11-07T11:02:33.717 回答