JQuery easyui datagrid

Source: Internet
Author: User

This plug-in group is small and easy to use. The following is an example of submitting query conditions from the foreground and returning json data from MSSQL.
HTML front-end code
Copy codeThe Code is as follows:
<? Php
Include_once ("auth. php ");
?>
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Link rel = "stylesheet" type = "text/css" href = "/inc/js/EasyUI/themes/default/easyui.css">
<Link rel = "stylesheet" type = "text/css" href = "/inc/js/EasyUI/themes/icon.css">
<Script type = "text/javascript" src = "/inc/js/EasyUI/jquery-1.8.0.min.js"> </script>
<Script type = "text/javascript" src = "/inc/js/EasyUI/jquery. easyui. min. js"> </script>
<Script>
Function FindData (){
$ ('# Mytable'). datagrid ('load ',{
PersonCode: $ ('# personcode'). val (),
KQYM: $ ('# kqym'). val ()}
);
}
</Script>
</Head>
<Body>
<Table id = 'mytable' class = "easyui-datagrid" style = "width: 600px; height = 500px"
Url = "loadgriddata_get.php" title = "Enter the query conditions"
Rownumbers = "true" toolbar = "# searchtool" loadMsg = "querying...">
<Thead>
<Tr>
<Th field = "PersonCode" Width = "80"> employee ID </th>
<Th field = "MyName" width = "80"> name </th>
<Th field = "KQDate" width = "100"> attendance date </th>
<Th field = "MyWeek" width = "80"> week </th>
<Th field = "KQMemo" width = "200"> punch-in time </th>
</Tr>
</Thead>
</Table>

<Div id = "searchtool" style = "padding: 5px">
<Span> employee id: </span> <input type = "text" id = "PersonCode" value = "" size = 10/>
<Span> attendance month/year: </span> <input type = "text" id = "KQYM" value = "" size = 10/>
<A href = "javascript: FindData ()" class = "easyui-linkbutton" data-options = "iconCls: 'icon-search'"> query </a>
<Div>
</Body>
</Html>

The following is the php code that retrieves a dataset and assembles the data into a json object and returns it to the foreground.
Copy codeThe Code is as follows:
<? Php
Include_once ("auth. php ");
Include_once ("inc/ms_conn.php ");
Include_once ("inc/comm_function.php ");
$ PersonCode = $ _ POST ["PersonCode"]; // parameters sent from the front end
$ KQYM = $ _ POST ["KQYM"];
$ Sqlstr = "Exec dbo. HR_Prg_GetPersonYMKQ2 '$ kqym',' $ personcode '";
$ Rs = mssqlquery ($ sqlstr); // custom mssql method, similar to the mssql_query Method
$ Row = mssql_num_rows ($ rs); // you can specify the total number of rows.
$ Result ["total"] = $ row;
$ Items = array ();
While ($ row = mssql_fetch_array ($ rs )){
Foreach ($ row as $ key => $ value ){
// This is very important. php's json_encode only supports UTF-8. Otherwise, the value of the field containing Chinese characters will be set to null.
$ Row [$ key] = iconv ('gb2312', 'utf-8', $ row [$ key]);}
Array_push ($ items, $ row );}
$ Result ["rows"] = $ items;
Echo json_encode ($ result );
?>

The following are

Related Article

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.