Home >Web Front-end >JS Tutorial >jQuery easyui datagrid dynamic query data example explanation_jquery

jQuery easyui datagrid dynamic query data example explanation_jquery

WBOY
WBOYOriginal
2016-05-16 17:41:251276browse

The plug-in group is small and easy to use. The following is an example of submitting query conditions from the front desk and returning json data from MSSQL
HTML front-end code

Copy code The code is as follows:

include_once("auth.php");
?>
< ;html>






<script> <br>function FindData(){ <br>$('#mytable').datagrid('load',{ <br>PersonCode:$('#PersonCode').val(), <br>KQYM:$( '#KQYM').val()} <br>); <br>} <br></script>


url="loadgriddata_get.php" title="Please enter the query conditions"
rownumbers="true" toolbar=" #searchtool" loadMsg="Searching...">






Employment Number< /th>
Name Attendance Date
weekday Punch time



Employer number:
Attendance year and month:
Query




The following is the PHP code that takes the data set and assembles the data into a json object and returns it to the front desk
Copy the code The code is as follows:

include_once("auth.php");
include_once("inc/ms_conn.php");
include_once("inc/comm_function.php") ;
$PersonCode=$_POST["PersonCode"]; //Parameters passed from the front end
$KQYM=$_POST["KQYM"];
$sqlstr="Exec dbo.HR_Prg_GetPersonYMKQ2 '$KQYM ','$PersonCode'";
$rs =mssqlquery($sqlstr); //Customized mssql method, similar to mssql_query method
$row = mssql_num_rows($rs); //Get 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 field value 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 is the rendering
jQuery easyui datagrid dynamic query data example explanation_jquery
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn