EasyUI Forum
May 06, 2024, 06:16:33 PM *
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 datagrid of remote data with Enter Key  (Read 3985 times)
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« on: April 04, 2018, 10:15:42 PM »

I used the following code to search datagrid. The search functionality works only when the user click the search button on the toolbar. it does not work with Enter Key. I want to use Enter key to submit the search term.

<style type="text/css">
.mystyle{
     line-height:16px; width:120px;
 }
</style>
Code:
<table id="itemdg" fit="true" url="data/get_data.php" style="padding:10px;" class="easyui-datagrid" pagination="true" toolbar="#toolbar" rownumbers="true" fitColumns="true">
       <thead>
<tr>
    <th field="description" width="auto" halign="center" sortable="true">Description</th>
                    <th field="code" width="auto" halign="center" align="center" sortable="true">Code No</th>
                    <th field="unit" width="auto" halign="center" sortable="true">Unit</th>
                    <th field="city" halign="center" width="auto" align="left" sortable="true">City</th>
                </tr>
        </thead>
</table>
<div id="toolbar">
     <span>Code No:</span>
     <input id="codeno" class="easyui-textbox mystyle">
     <span>CityName:</span>
     <select id="city" class="easyui-combobox mystyle">
            <option value="1">Kolkata</option>
            <option value="2">Delhi</option>
     </select>
     <a href="#" id="esearch" class="easyui-linkbutton" iconCls="icon-search" onclick="itemSearch()">Search</a>
</div>

Js
Code:
     function itemSearch(){
            $('#itemdg').datagrid('load',{
                code: $('#codeno').textbox('getValue'),
                city: $('#city').combobox('getValue')
            });
        }

Here is my attempt to use Enter Key Press:
   
Code:
$(function() {
        $(".mystyle").keypress(function (e) {
            if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
                $('#esearch').click();
                return false;
            } else {
                return true;
            }
        });
    });

My attempt code does not work. There is no error in the console. Please help.
Logged
battlezad
Newbie
*
Posts: 44


View Profile
« Reply #1 on: April 05, 2018, 01:39:17 AM »

Try using SearchBox?
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #2 on: April 05, 2018, 02:51:53 AM »

Searchbox is limited to one input field.
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!