DataGrid (data table) component [4]

Source: Internet
Author: User
Tags sql error

This lesson focuses on how the DataGrid (data table) component is used in Easyui, which relies on
Panel, resizeable (resizing), LinkButton (button), pageination (pagination) components.

A Query function

Toolbar settings
<div id= "TB" style= "Padding:5px;height:auto" >
<div style= "margin-bottom:5px" >
<a href= "#" class= "Easyui-linkbutton" iconcls= "Icon-add"
Plain= "true" > Add </a>
<a href= "#" class= "Easyui-linkbutton" iconcls= "Icon-edit"
Plain= "true" > Modify </a>
<a href= "#" class= "Easyui-linkbutton" iconcls= "Icon-remove"
Plain= "true" > Delete </a>
</div>
<div style= "padding:0 0 0 7px; " >
Enquiry Account: <input class= "textbox" name= "User"
style= "width:110px" >

Creation time from: <input class= "Easyui-datebox" name= "Date_from"
style= "width:110px" >
To: <input class= "Easyui-datebox" name= "date_to"
style= "width:110px" >
<a href= "#" class= "Easyui-linkbutton" iconcls= "Icon-search"
Onclick= "Obj.search ();" > Enquiry </a>
</div>
</div>
. textbox{
height:20px;
margin:0;
padding:0 2px;
Box-sizing:content-box;
}
Pass the value of the form
obj = {
Search:function () {
$ (' #box '). DataGrid (' Load ', {
User: $.trim ($ (' input[name= "" user "). Val ()),
Date_from: $ (' input[name= ' Date_from "]). Val (),
Date_to: $ (' input[name= ' date_to "]). Val (),
});
},
};
Server-side SQL consolidation
$sql = ";
$user = ";
$date _from = ";
$date _to = ";
if (Isset ($_post[' user ") &&!empty ($_post[' user ')) {
$user = "User like '%{$_post[' user ']}% ' and";
$sql. = $user;
}
if (Isset ($_post[' Date_from ')) &&!empty ($_post[' Date_from ']) {
$date _from = "date>= ' {$_post[' date_from ']} ' and ';
$sql. = $date _from;

}

if (Isset ($_post[' date_to ')) &&!empty ($_post[' date_to ']) {
$date _to = "date<= ' {$_post[' date_to ']} ' and ';
$sql. = $date _to;
}
if (!empty ($sql)) {
$sql = ' WHERE '. substr ($sql, 0,-4);
}
$query = mysql_query ("Select User,email,date from Think_user $sql ORDER
by $sort er LIMIT $first, $pageSize ") or Die (' SQL Error! ‘);
$total = mysql_num_rows (mysql_query ("Select User,email,date from
Think_user $sql "));

DataGrid (data table) component [4]

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.