jquery Easy UI Simple field selection search implementation

Source: Internet
Author: User

Code

<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>jquery Easyui Application Demo</title>
<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/themes/color.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.6.min.js" ></script>
<script type= "Text/javascript" src= "Http://www.jeasyui.com/easyui/jquery.easyui.min.js" ></script>
<body>
<div id= "Panelinfo" class= "Easyui-panel" title= "My Panel" style= "width:300px;height:250px;padding:10px;" >
<div class= "Ftitle" >user information</div>
<form id= "ff" action= "method=" post "enctype=" Multipart/form-data ">
<table>
<tr>
<td>Account:</td>
<td><input id= "Account" name= "account" class= "F1 easyui-textbox Easyui-searchbox" data-options= "Searcher: Dosearch "/></td>
</tr>
<tr>
<td>Name:</td>
<td><input id= "name" name= "name" class= "F1 Easyui-textbox"/></td>
</tr>
<tr>
<td>Email:</td>
<td><input id= "Email" name= "email" class= "F1 Easyui-textbox"/></td>
</tr>
<tr>
<td>Phone:</td>
<td><input id= "Phone" name= "phone" class= "F1 Easyui-textbox"/></td>
</tr>
</table>
</form>
</div>
<div id= "Dlg" class= "Easyui-dialog" style= "width:220px;height:450px", "data-options=" title: ' Select User Info ', Toolbar: ' #dlg-toolbar ', buttons: ' #dlg-buttons ', modal:true ' >
<table id= "DG" data-options= "Singleselect:true" ></table>
</div>
<div id= "Dlg-toolbar" style= "padding:2px 0" >
<input class= "Easyui-searchbox" data-options= "prompt: ' Please input somthing ', Searcher:dosearchuser" style= "width : 100% "/>
</div>
<div id= "Dlg-buttons" >
<a href= "javascript:void (0)" class= "Easyui-linkbutton" onclick= "Javascript:doselect ()" >Select</a>
<a href= "javascript:void (0)" class= "Easyui-linkbutton" onclick= "javascript:$ (' #dlg '). Dialog (' Close ')" >close </a>
</div>

<script type= "Text/javascript" >
var data = [
{' dlg_accoutn ': ' 100000 ', ' dlg_name ': ' 00000 '},
{' dlg_accoutn ': ' 100001 ', ' dlg_name ': ' 11111 '},
{' dlg_accoutn ': ' 100002 ', ' dlg_name ': ' 22222 '},
{' dlg_accoutn ': ' 100003 ', ' dlg_name ': ' 33333 '},
{' dlg_accoutn ': ' 100004 ', ' dlg_name ': ' 44444 '},
{' dlg_accoutn ': ' 100005 ', ' dlg_name ': ' 55555 '},
{' dlg_accoutn ': ' 100006 ', ' dlg_name ': ' 66666 '},
{' dlg_accoutn ': ' 100007 ', ' dlg_name ': ' 77777 '},
{' dlg_accoutn ': ' 100008 ', ' dlg_name ': ' 88888 '},
{' dlg_accoutn ': ' 100009 ', ' dlg_name ': ' 99999 '},
{' dlg_accoutn ': ' 100010 ', ' dlg_name ': ' 111000 '},
{' dlg_accoutn ': ' 100011 ', ' dlg_name ': ' 222111 '},
{' dlg_accoutn ': ' 100012 ', ' dlg_name ': ' 333222 '},
{' dlg_accoutn ': ' 100013 ', ' dlg_name ': ' 444333 '},
{' dlg_accoutn ': ' 100014 ', ' dlg_name ': ' 555444 '},
{' dlg_accoutn ': ' 100015 ', ' dlg_name ': ' 666555 '},
{' dlg_accoutn ': ' 100016 ', ' dlg_name ': ' 777666 '},
{' dlg_accoutn ': ' 100017 ', ' dlg_name ': ' 888777 '},
{' dlg_accoutn ': ' 100018 ', ' dlg_name ': ' 999888 '},
{' dlg_accoutn ': ' 100019 ', ' dlg_name ': ' 111222 '},
{' dlg_accoutn ': ' 100020 ', ' dlg_name ': ' 222333 '},
{' dlg_accoutn ': ' 100021 ', ' dlg_name ': ' 333444 '},
{' dlg_accoutn ': ' 100022 ', ' dlg_name ': ' 444555 '}
];

$ (function () {
$ (' #dlg '). Dialog (' Close ');
})

function Doselect () {
var row = $ (' #dg '). DataGrid (' getselected ');
Console.log (row);
if (row) {
$ (' #account '). TextBox (' SetValue ', row[' dlg_accoutn ']);
$ (' #account '). TextBox (' SetText ', row[' dlg_accoutn ']);
$ (' #name '). TextBox (' SetValue ', row[' dlg_name ']);
$ (' #name '). TextBox (' SetText ', row[' dlg_name ']);
};
$ (' #dlg '). Dialog (' Close ');
}

function Dosearch () {
$ (' #dlg '). Dialog (' Open ');
$ (' #dg '). DataGrid ({
Data:data,
columns:[[
{field: ' Dlg_accoutn ', title: ' Account ', width:100},
{field: ' Dlg_name ', title: ' Name ', width:100}
]]
});
}

function Dosearchuser () {
var tmp = [
{' dlg_accoutn ': ' 100017 ', ' dlg_name ': ' 888777 '},
{' dlg_accoutn ': ' 100018 ', ' dlg_name ': ' 999888 '},
{' dlg_accoutn ': ' 100019 ', ' dlg_name ': ' 111222 '},
{' dlg_accoutn ': ' 100020 ', ' dlg_name ': ' 222333 '},
{' dlg_accoutn ': ' 100021 ', ' dlg_name ': ' 333444 '},
{' dlg_accoutn ': ' 100022 ', ' dlg_name ': ' 444555 '}];
$ (' #dg '). DataGrid (' LoadData ', TMP);
$ (' #dg '). DataGrid (' reload ');
}
</script>
</body>

jquery Easy UI Simple field selection search implementation

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.