JQuery easyui DataGrid Dynamic Query data instance explanation _jquery

Source: Internet
Author: User
Tags mssql
The plug-in group is easy to use, the following is a query from the front to submit the conditions, from the MSSQL return JSON data a case
HTML Front-End Code
Copy Code code as follows:

<?php
Include_once ("auth.php");
?>
<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>
<body>
<table id= ' mytable ' class= ' easyui-datagrid ' style= ' width:600px;height=500px '
Url= "loadgriddata_get.php" title= "Please enter query criteria"
Rownumbers= "true" toolbar= "#searchtool loadmsg=" is querying ... ">
<thead>
<tr>
<th field= "Personcode" Width= "No." > Work </th>
<th field= "myname" width= "no" > Name </th>
<th field= "Kqdate" width= "M" > Attendance date </th>
<th field= "Myweek" width= "> Week </th>"
<th field= "Kqmemo" width= "> Clocking time </th>
</tr>
</thead>
</table>

<div id= "Searchtool" style= "padding:5px" >
<span> work Number: </span><input type= "text" id= "Personcode" value= "" size=10/>
<span> Attendance: </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>

The following is a dataset and assembles the data into a JSON object to return the PHP code to the foreground
Copy Code code as follows:

<?php
Include_once ("auth.php");
Include_once ("inc/ms_conn.php");
Include_once ("inc/comm_function.php");
$PersonCode =$_post["Personcode"]; The parameters that came from the front
$KQYM =$_post["Kqym"];
$sqlstr = "Exec dbo.hr_prg_getpersonymkq2 ' $KQYM ', ' $PersonCode '";
$rs =mssqlquery ($SQLSTR); Custom MSSQL method, class quasi Mssql_query method
$row = Mssql_num_rows ($RS); Number of rows taken
$result ["total"] = $row;
$items =array ();
while ($row = Mssql_fetch_array ($rs)) {
foreach ($row as $key => $value) {
It's important here that PHP's json_encode only supports UTF-8, otherwise the Chinese character field values are set to NULL
$row [$key]=iconv (' gb2312 ', ' UTF-8 ', $row [$key]); }
Array_push ($items, $row); }
$result ["Rows"] = $items;
echo Json_encode ($result);
?>

The following is an effect chart

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.