Easyui DataGrid Table List Add multiple search criteria box

Source: Internet
Author: User

ADD Search functionality in DataGrid

In this tutorial we'll show you how to get the data from the database and display them to the DataGrid. And then demonstrate how to search through the results according the search terms the user enters. View Demo Create DataGrid

Create the DataGrid with paging feature and then add a toolbar to it. <table id= "tt"  class= "Easyui-datagrid"  style= "width:600px;height:250px"             url= "datagrid24_getdata.php"  toolbar= "#tb"             title= "Load data"  iconcls= "Icon-save"             rownumbers= "true"  pagination= "true" >        <thead>           <tr>               <th field= "Itemid"  width= ">Item ID</th>  "              <th field= "ProductID"  width= ">Product ID</th>                 <th field= "ListPrice"  width= " align=" "right" >List Price</th>               <th field= "UnitCost"   Width= " align=" "right" >Unit Cost</th>                <th field= "attr1"  width= ">Attribute</th> "               <th field= "status"   width=  align= "center" >Stauts</th>            </tr>       </thead>   </table>  

The toolbar is defined as: <div id= "TB"  style= "padding:3px" >        <span>Item ID:</span>       <input id= "Itemid"   style= "line-height:26px;border:1px solid  #ccc" >       <span> product id:</span>       <input id= "ProductID"  style= " line-height:26px;border:1px solid  #ccc ">       <a href=" # "  class= "Easyui-linkbutton"  plain= "true"  onclick= "Dosearch ()" >Search</a>   </div>  

When user enters search values and press search button, the ' Dosearch ' function would be called:function Dosearch () {   $ (' #tt '). DataGrid (' Load ', {itemid: $ (' #itemid '). Val (), ProductID: $ (' #productid '). Val ()}); }

The code above we call ' load ' method to load new DataGrid data. We need to pass ' itemid ' and ' ProductID ' parameters to server.The Server Code include  ' conn.php ';      $page  = isset ($_post[' page ')  ? intval ($_ post[' page '])  : 1;   $rows  = isset ($_post[' rows ')  ? intval ($_post[') Rows '])  : 10;   $itemid  = isset ($_post[' itemid ')  ? mysql_real_escape_ String ($_post[' itemid '))  :  ';   $productid  = isset ($_post[' ProductID '])  ?  mysql_real_escape_string ($_post[' ProductID ')  :  ';      $offset  =   ($page-1) * $rows;      $result  = array ();      $where   =  "itemid like  ' $itemid% '  and productid like  ' $productid% '";   $rs  = mysql_query ("Select count (*)  from item where "  .  $where);    $row  = mysql_fetch_row ($rs);   $result ["Total"] =  $row [0];   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.