我正在尝试在Mysql查询之后实现ParamQuery。查询结果显示在网格上,但我有一些列未显示数据。
查询:
SELECT * FROM (
SELECT id, city, branch, order_number, user,
taken_at,
ready_at,
SEC_TO_TIME(UNIX_TIMESTAMP(oxxo.ready_at) - UNIX_TIMESTAMP(oxxo.taken_at)) AS haht,
on_route_at,
SEC_TO_TIME(UNIX_TIMESTAMP(oxxo.on_route_at) - UNIX_TIMESTAMP(oxxo.ready_at)) AS hrha,
delivered_at,
SEC_TO_TIME(UNIX_TIMESTAMP(oxxo.delivered_at) - UNIX_TIMESTAMP(oxxo.on_route_at)) AS hdhr,
SEC_TO_TIME(UNIX_TIMESTAMP(oxxo.delivered_at) - UNIX_TIMESTAMP(oxxo.taken_at)) AS total,
distance
FROM oxxo ) AS temptable1
查询结果:
[
["1", "Medellin", "Oxxo Candelaria", "20000", "Mario Z", "2019-05-01 09:13:43", "2019-05-01 09:22:13", "00:08:30", "2019-05-01 09:23:40", "00:01:27", "2019-05-01 09:32:56", "00:09:16", "00:19:13", "0.9"],
["2", "Bogota", "Oxxo Palermo", "20001", "Pablo M", "2019-05-29 19:22:40", "2019-05-29 19:29:27", "00:06:47", "2019-05-29 19:30:42", "00:01:15", "2019-05-29 19:47:02", "00:16:20", "00:24:22", "11.7"],
["3", "Medellin", "Oxxo Candelaria", "20002", "Mario Z", "2019-05-13 09:45:05", "2019-05-13 09:54:27", "00:09:22", "2019-05-13 09:56:16", "00:01:49", "2019-05-13 10:15:40", "00:19:24", "00:30:35", "1.2"],
["4", "Medellin", "Oxxo Calle 20", "20003", "Mario Z", "2019-05-10 05:10:08", "2019-05-10 05:18:49", "00:08:41", "2019-05-10 05:21:41", "00:02:52", "2019-05-10 05:34:50", "00:13:09", "00:24:42", "10.8"],
["5", "Medellin", "Oxxo Candelaria", "20004", "Mario Z", "2019-05-25 14:29:54", "2019-05-25 14:34:00", "00:04:06", "2019-05-25 14:36:30", "00:02:30", "2019-05-25 14:50:34", "00:14:04", "00:20:40", "3.0"],
["6", "Medellin", "Oxxo Calle 20", "20005", "Mario Z", "2019-05-13 20:24:10", "2019-05-13 20:30:34", "00:06:24", "2019-05-13 20:31:52", "00:01:18", "2019-05-13 20:50:21", "00:18:29", "00:26:11", "4.3"],
["7", "Bogota", "Oxxo Palermo", "20006", "Pablo M", "2019-06-03 04:06:23", "2019-06-03 04:09:00", "00:02:37", "2019-06-03 04:10:01", "00:01:01", "2019-06-03 04:23:33", "00:13:32", "00:17:10", "5.7"]
]
未显示列的列模型:(具有时间格式的列(例如:“ 00:08:30”)
{
title: "Alist-Conf",
width: 190,
dataType: "string",
dataIndx: "haht",
align: "center" ,
}
PHP查询:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
// Create connection
try {
// Try Connect to the DB with new MySqli object - Params {hostname, userid, password, dbname}
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, city, branch, order_number, user, taken_at, ready_at, haht, on_route_at, hrha, delivered_at, hdhr, toal, distance FROM oxxo";
$sql = <<<EOT
SELECT * FROM (
SELECT id, city, branch, order_number, user,
taken_at,
ready_at,
SEC_TO_TIME(UNIX_TIMESTAMP(oxxo.ready_at) - UNIX_TIMESTAMP(oxxo.taken_at)) AS haht,
on_route_at,
SEC_TO_TIME(UNIX_TIMESTAMP(oxxo.on_route_at) - UNIX_TIMESTAMP(oxxo.ready_at)) AS hrha,
delivered_at,
SEC_TO_TIME(UNIX_TIMESTAMP(oxxo.delivered_at) - UNIX_TIMESTAMP(oxxo.on_route_at)) AS hdhr,
SEC_TO_TIME(UNIX_TIMESTAMP(oxxo.delivered_at) - UNIX_TIMESTAMP(oxxo.taken_at)) AS total,
distance
FROM oxxo ) AS temptable1
EOT;
$result = mysqli_query($conn, $sql);
$json_array = array();
//while ($row = mysqli_fetch_assoc($result)){
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)){
$json_array[]=$row;
/*echo "<pre>";
echo json_encode($row);
echo "</pre>";
die();*/
}
//print_r($json_array);
echo json_encode($json_array);
/*
echo "<pre>";
print_r($json_array);
echo "</pre>";
*/
//echo json_encode($json_array);
} catch (mysqli_sql_exception $e) { // Failed to connect? Lets see the exception details..
echo "MySQLi Error Code: " . $e->getCode() . "<br />";
echo "Exception Msg: " . $e->getMessage();
exit(); // exit and close connection.
}
$conn->close(); // finally, close the connection
?>
HTML代码:
<!DOCTYPE html>
<head>
<!--jQuery dependency-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!--jQueryUI version >= 1.11.4 only -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
<script src="js/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="js/pq/pqgrid.min.css">
<!--ParamQuery Grid css files-->
<!--add pqgrid.ui.css for jQueryUI theme support-->
<link rel="stylesheet" href="js/pq/pqgrid.ui.min.css">
<!--ParamQuery Grid custom theme e.g., office, bootstrap, rosy, chocolate, etc (optional)-->
<link rel="stylesheet" href="js/pq/themes/gray/pqgrid.css">
<!--ParamQuery Grid js files-->
<script src="js/pq/pqgrid.min.js"></script>
<!--ParamQuery Grid localization file (necessary since v5.2.0)-->
<script src="js/pq/localize/pq-localize-es.js"></script>
<!--Include pqTouch file to provide support for touch devices (optional)-->
<!-- <script type="text/javascript" src="path to pqtouch.min.js" ></script> -->
<!--Include jsZip file to support xlsx and zip export (optional)-->
<!-- <script type="text/javascript" src="path to jsZip.js" ></script> -->
<!--Include jquery.resize to support auto height of detail views in hierarchy (optional)-->
<script type="text/javascript" src="js/jquery.resize.js" ></script>
<title>Reporte de Tiempos</title>
<style>
div.pq-grid *{
font-size: 16px;
font-family: Tahoma,Verdana,Segoe,sans-serif;
}
.image-container {
display: block;
margin-left: auto;
margin-right: auto;
width:256px;
height:161px;
}
</style>
</head>
<body>
<img alt="logo" src="logo.png" class="image-container" >
<div><div id="grid" style="margin:5px auto;" ></div>
<script type="text/javascript" >
$(function () {
var colM = [
{
title: "Ciudad", //title of column.
width: 150, //initial width of column
dataType: "string", //data type of column
dataIndx: "city", //should match one of the keys in row data.
filter: {
type: 'select',
prepend: { '': 'Todos ...' },
valueIndx: 'city',
labelIndx: 'city',
condition: 'equal',
listeners: ['change']
}
},{
title: "Tienda", //title of column.
width: 180, //initial width of column
dataType: "string", //data type of column
dataIndx: "branch",
filter: {
type: 'select',
prepend: { '': 'Todos ...' },
valueIndx: 'branch',
labelIndx: 'branch',
condition: 'equal',
listeners: ['change']
}
},
{
title: "Motorizado",
width: 150,
dataType: "string",
dataIndx: "user",
align: "left",
filter: {
type: 'select',
prepend: { '': 'Todos ...' },
valueIndx: 'user',
labelIndx: 'user',
condition: 'equal',
listeners: ['change']
}
},
{
title: "H. Conf",
width: 190,
dataType: "date",
dataIndx: "taken_at",
align: "center",
filter: { type: 'textbox', condition: "range", listeners: ['keyup'] }
},
{
title: "H Alist",
width: 190,
dataType: "date",
dataIndx: "ready_at",
align: "center" ,
filter: { type: 'textbox', condition: "range", listeners: ['keyup'] }
},
{
title: "Alist-Conf",
width: 190,
dataType: "string",
dataIndx: "haht",
align: "center" ,
},
{
title: "H Ruta",
width: 190,
dataType: "date",
dataIndx: "on_route_at",
align: "center" ,
filter: { type: 'textbox', condition: "range", listeners: ['keyup'] }
},
{
title: "Ruta-Alist",
width: 190,
dataType: "string",
dataIndx: "hrha",
align: "center" ,
},
{
title: "H Entrega",
width: 190,
dataType: "date",
dataIndx: "delivered_at",
align: "center" ,
filter: { type: 'textbox', condition: "range", listeners: ['keyup'] }
},
{
title: "Entregado-Ruta",
width: 190,
dataType: "string",
dataIndx: "hdhr",
align: "center" ,
},
{
title: "Total",
width: 190,
dataType: "string",
dataIndx: "total",
align: "center" ,
},
{
title: "Dist",
width: 130,
dataType: "float",
dataIndx: "distance",
align: "center" ,
format: '##,###.00',
filter: { type: 'textbox', condition: "between", listeners: ['keyup'] },
},
{
title: "#Orden",
width: 130,
dataType: "integer",
dataIndx: "order_number",
align: "center",
filter: { type: 'textbox', condition: 'between', listeners: ['keyup'] }
},
];
var dataModel = {
location: "remote",
dataType: "JSON",
method: "GET",
url: "getOxxoRecords.php", getData: function (dataJSON) {
var mySQLResult = dataJSON.data;
return { data: dataJSON.mySQLResult };
}
};
var groupModel = {
on: true,
summaryInTitleRow: 'all', //to display summary in the title row.
dataIndx: ['city'],
showSummary: [true],
title: [
"{0} ({1})",
]
};
var obj = {
width: "90%",
height: 700,
resizable: true,
rowBorders: true,
filterModel: { on: true, mode: "OR", header: true},
title: "<b>Planilla de Entregas</b>",
showBottom: false,
scrollModel: { autoFit: true },
colModel: colM,
dataModel: { data: data },
//dataModel:dataModel,
autoRowSum: true,
pageModel: { type: "local", rPP: 20, rPPOptions: [10, 20, 30, 40, 50, 100, 200] },
numberCell: { show: false },
stripeRows: true,
groupModel: groupModel,
selectionModel: { type: 'row' },
menuIcon: true,
hwrap: false,
wrap: false
};
pq.grid("#grid", obj);
});
</script>
</body>
</html>
数据:
[["1","Medellin","Oxxo Candelaria","20000","Mario Z","2019-05-01 09:13:43","2019-05-01 09:22:13","00:08:30","2019-05-01 09:23:40","00:01:27","2019-05-01 09:32:56","00:09:16","00:19:13","0.9"],["2","Bogota","Oxxo Palermo","20001","Pablo M","2019-05-29 19:22:40","2019-05-29 19:29:27","00:06:47","2019-05-29 19:30:42","00:01:15","2019-05-29 19:47:02","00:16:20","00:24:22","11.7"],["3","Medellin","Oxxo Candelaria","20002","Mario Z","2019-05-13 09:45:05","2019-05-13 09:54:27","00:09:22","2019-05-13 09:56:16","00:01:49","2019-05-13 10:15:40","00:19:24","00:30:35","1.2"],["4","Medellin","Oxxo Calle 20","20003","Mario Z","2019-05-10 05:10:08","2019-05-10 05:18:49","00:08:41","2019-05-10 05:21:41","00:02:52","2019-05-10 05:34:50","00:13:09","00:24:42","10.8"],["5","Medellin","Oxxo Candelaria","20004","Mario Z","2019-05-25 14:29:54","2019-05-25 14:34:00","00:04:06","2019-05-25 14:36:30","00:02:30","2019-05-25 14:50:34","00:14:04","00:20:40","3.0"],["6","Medellin","Oxxo Calle 20","20005","Mario Z","2019-05-13 20:24:10","2019-05-13 20:30:34","00:06:24","2019-05-13 20:31:52","00:01:18","2019-05-13 20:50:21","00:18:29","00:26:11","4.3"],["7","Bogota","Oxxo Palermo","20006","Pablo M","2019-06-03 04:06:23","2019-06-03 04:09:00","00:02:37","2019-06-03 04:10:01","00:01:01","2019-06-03 04:23:33","00:13:32","00:17:10","5.7"],["8","Bogota","Oxxo Calle 57","20007","Gustavo A","2019-05-25 02:27:15","2019-05-25 02:38:39","00:11:24","2019-05-25 02:39:59","00:01:20","2019-05-25 02:49:04","00:09:05","00:21:49","11.2"],["9","Medellin","Oxxo Calle 20","20008","Pablo M","2019-05-18 13:30:10","2019-05-18 13:40:41","00:10:31","2019-05-18 13:43:23","00:02:42","2019-05-18 13:52:57","00:09:34","00:22:47","6.6"],["10","Bogota","Oxxo Calle 57","20009","Gustavo A","2019-05-25 09:54:26","2019-05-25 10:04:44","00:10:18","2019-05-25 10:07:13","00:02:29","2019-05-25 10:24:03","00:16:50","00:29:37","7.5"],["11","Bogota","Oxxo Palermo","20010","Pablo M","2019-05-30 05:33:50","2019-05-30 05:37:46","00:03:56","2019-05-30 05:40:28","00:02:42","2019-05-30 05:52:53","00:12:25","00:19:03","0.9"],["12","Bogota","Oxxo Calle 16","20011","Gustavo A","2019-05-12 00:12:36","2019-05-12 00:15:31","00:02:55","2019-05-12 00:17:21","00:01:50","2019-05-12 00:35:35","00:18:14","00:22:59","12.0"],["13","Medellin","Oxxo Calle 20","20012","Pablo M","2019-05-15 09:52:58","2019-05-15 10:00:04","00:07:06","2019-05-15 10:02:57","00:02:53","2019-05-15 10:08:06","00:05:09","00:15:08","6.0"],["14","Bogota","Oxxo Palermo","20013","Pablo M","2019-05-01 07:15:23","2019-05-01 07:17:46","00:02:23","2019-05-01 07:19:47","00:02:01","2019-05-01 07:39:12","00:19:25","00:23:49","9.1"],["15","Bogota","Oxxo Calle 16","20014","Gustavo A","2019-05-27 03:13:49","2019-05-27 03:18:34","00:04:45","2019-05-27 03:20:00","00:01:26","2019-05-27 03:34:37","00:14:37","00:20:48","4.8"],["16","Medellin","Oxxo Calle 20","20015","Pablo M","2019-05-30 06:53:26","2019-05-30 07:04:25","00:10:59","2019-05-30 07:05:56","00:01:31","2019-05-30 07:24:25","00:18:29","00:30:59","4.5"],["17","Bogota","Oxxo Calle 57","20016","Gustavo A","2019-06-04 04:03:27","2019-06-04 04:10:19","00:06:52","2019-06-04 04:12:31","00:02:12","2019-06-04 04:28:08","00:15:37","00:24:41","9.6"],["18","Medellin","Oxxo Calle 20","20017","Pablo M","2019-06-04 04:17:28","2019-06-04 04:21:41","00:04:13","2019-06-04 04:22:49","00:01:08","2019-06-04 04:32:07","00:09:18","00:14:39","5.8"],["19","Medellin","Oxxo Calle 20","20018","Mario Z","2019-05-06 20:31:33","2019-05-06 20:36:35","00:05:02","2019-05-06 20:37:43","00:01:08","2019-05-06 20:56:49","00:19:06","00:25:16","0.7"],["20","Bogota","Oxxo Palermo","20019","Pablo M","2019-05-15 17:55:17","2019-05-15 18:06:35","00:11:18","2019-05-15 18:08:32","00:01:57","2019-05-15 18:22:13","00:13:41","00:26:56","6.1"],["21","Bogota","Oxxo Palermo","20020","Pablo M","2019-05-15 13:51:12","2019-05-15 13:55:10","00:03:58","2019-05-15 13:57:56","00:02:46","2019-05-15 14:09:02","00:11:06","00:17:50","6.5"],["22","Bogota","Oxxo Calle 16","20021","Gustavo A","2019-06-02 11:28:19","2019-06-02 11:30:32","00:02:13","2019-06-02 11:31:34","00:01:02","2019-06-02 11:48:15","00:16:41","00:19:56","12.0"],["23","Bogota","Oxxo Calle 16","20022","Gustavo A","2019-05-30 19:46:00","2019-05-30 19:49:14","00:03:14","2019-05-30 19:51:57","00:02:43","2019-05-30 20:09:20","00:17:23","00:23:20","7.5"],["24","Bogota","Oxxo Calle 16","20023","Gustavo A","2019-05-14 08:49:02","2019-05-14 08:56:00","00:06:58","2019-05-14 08:57:24","00:01:24","2019-05-14 09:06:24","00:09:00","00:17:22","8.9"],["25","Bogota","Oxxo Calle 16","20024","Gustavo A","2019-05-26 19:26:53","2019-05-26 19:30:09","00:03:16","2019-05-26 19:31:20","00:01:11","2019-05-26 19:49:14","00:17:54","00:22:21","9.5"],["26","Bogota","Oxxo Calle 57","20025","Gustavo A","2019-05-02 11:04:45","2019-05-02 11:14:47","00:10:02","2019-05-02 11:16:26","00:01:39","2019-05-02 11:25:47","00:09:21","00:21:02","0.4"],["27","Bogota","Oxxo Calle 16","20026","Gustavo A","2019-05-03 11:35:54","2019-05-03 11:42:43","00:06:49","2019-05-03 11:43:53","00:01:10","2019-05-03 11:57:00","00:13:07","00:21:06","12.0"],["28","Bogota","Oxxo Calle 57","20027","Gustavo A","2019-05-20 10:02:28","2019-05-20 10:05:07","00:02:39","2019-05-20 10:07:49","00:02:42","2019-05-20 10:25:43","00:17:54","00:23:15","12.0"],["29","Bogota","Oxxo Calle 16","20028","Gustavo A","2019-05-05 05:53:34","2019-05-05 06:02:12","00:08:38","2019-05-05 06:04:47","00:02:35","2019-05-05 06:14:26","00:09:39","00:20:52","3.9"],["30","Medellin","Oxxo Candelaria","20029","Mario Z","2019-05-15 06:36:34","2019-05-15 06:45:14","00:08:40","2019-05-15 06:47:50","00:02:36","2019-05-15 07:06:45","00:18:55","00:30:11","12.0"],["31","Bogota","Oxxo Calle 57","20030","Gustavo A","2019-05-24 21:42:13","2019-05-24 21:49:08","00:06:55","2019-05-24 21:51:54","00:02:46","2019-05-24 22:00:12","00:08:18","00:17:59","5.0"],["32","Bogota","Oxxo Calle 16","20031","Gustavo A","2019-05-10 18:05:44","2019-05-10 18:11:17","00:05:33","2019-05-10 18:12:26","00:01:09","2019-05-10 18:30:50","00:18:24","00:25:06","12.0"],["33","Bogota","Oxxo Palermo","20032","Pablo M","2019-05-21 10:14:39","2019-05-21 10:25:22","00:10:43","2019-05-21 10:28:15","00:02:53","2019-05-21 10:48:13","00:19:58","00:33:34","9.8"],["34","Bogota","Oxxo Calle 16","20033","Gustavo A","2019-05-01 07:02:56","2019-05-01 07:09:12","00:06:16","2019-05-01 07:11:41","00:02:29","2019-05-01 07:20:03","00:08:22","00:17:07","4.5"],["35","Medellin","Oxxo Calle 20","20034","Pablo M","2019-05-06 14:01:12","2019-05-06 14:12:07","00:10:55","2019-05-06 14:13:33","00:01:26","2019-05-06 14:23:57","00:10:24","00:22:45","11.4"],["36","Bogota","Oxxo Calle 16","20035","Gustavo A","2019-05-01 07:23:34","2019-05-01 07:26:28","00:02:54","2019-05-01 07:28:06","00:01:38","2019-05-01 07:45:21","00:17:15","00:21:47","4.0"],["37","Bogota","Oxxo Calle 16","20036","Gustavo A","2019-05-31 01:49:02","2019-05-31 01:57:31","00:08:29","2019-05-31 01:59:23","00:01:52","2019-05-31 02:09:39","00:10:16","00:20:37","11.2"],["38","Bogota","Oxxo Calle 57","20037","Gustavo A","2019-05-13 07:38:54","2019-05-13 07:47:15","00:08:21","2019-05-13 07:48:39","00:01:24","2019-05-13 08:07:08","00:18:29","00:28:14","3.9"],["39","Bogota","Oxxo Calle 57","20038","Gustavo A","2019-05-25 15:15:57","2019-05-25 15:19:52","00:03:55","2019-05-25 15:22:32","00:02:40","2019-05-25 15:38:20","00:15:48","00:22:23","10.1"],["40","Bogota","Oxxo Calle 57","20039","Gustavo A","2019-05-11 19:59:42","2019-05-11 20:03:32","00:03:50","2019-05-11 20:05:27","00:01:55","2019-05-11 20:09:50","00:04:23","00:10:08","6.2"],["41","Bogota","Oxxo Calle 16","20040","Gustavo A","2019-05-17 12:04:10","2019-05-17 12:08:28","00:04:18","2019-05-17 12:09:43","00:01:15","2019-05-17 12:14:11","00:04:28","00:10:01","6.9"],["42","Bogota","Oxxo Calle 57","20041","Gustavo A","2019-05-27 21:39:21","2019-05-27 21:45:36","00:06:15","2019-05-27 21:47:40","00:02:04","2019-05-27 22:02:15","00:14:35","00:22:54","2.9"],["43","Bogota","Oxxo Calle 57","20042","Pablo M","2019-05-09 07:09:24","2019-05-09 07:19:33","00:10:09","2019-05-09 07:21:58","00:02:25","2019-05-09 07:35:44","00:13:46","00:26:20","6.4"],["44","Medellin","Oxxo Candelaria","20043","Mario Z","2019-05-01 07:03:47","2019-05-01 07:11:23","00:07:36","2019-05-01 07:13:42","00:02:19","2019-05-01 07:18:09","00:04:27","00:14:22","0.0"],["45","Bogota","Oxxo Calle 16","20044","Gustavo A","2019-05-25 11:37:05","2019-05-25 11:39:36","00:02:31","2019-05-25 11:41:42","00:02:06","2019-05-25 11:50:29","00:08:47","00:13:24","6.0"],["46","Bogota","Oxxo Calle 16","20045","Gustavo A","2019-05-01 07:00:08","2019-05-01 07:09:19","00:09:11","2019-05-01 07:11:36","00:02:17","2019-05-01 07:22:30","00:10:54","00:22:22","8.1"],["47","Bogota","Oxxo Calle 57","20046","Gustavo A","2019-05-01 07:07:49","2019-05-01 07:14:03","00:06:14","2019-05-01 07:15:06","00:01:03","2019-05-01 07:19:46","00:04:40","00:11:57","12.0"],["48","Bogota","Oxxo Calle 57","20047","Pablo M","2019-05-01 07:00:07","2019-05-01 07:07:46","00:07:39","2019-05-01 07:10:09","00:02:23","2019-05-01 07:16:09","00:06:00","00:16:02","3.2"],["49","Medellin","Oxxo Calle 20","20048","Pablo M","2019-05-01 07:01:36","2019-05-01 07:10:05","00:08:29","2019-05-01 07:12:33","00:02:28","2019-05-01 07:25:59","00:13:26","00:24:23","12.0"],["50","Bogota","Oxxo Calle 16","20049","Gustavo A","2019-05-11 10:44:52","2019-05-11 10:55:04","00:10:12","2019-05-11 10:56:54","00:01:50","2019-05-11 11:02:49","00:05:55","00:17:57","6.4"]]
网格:
该想法是显示缺失值(图片上的红色箭头),以及每当用户对一列进行分组并按组获取总计(蓝色箭头)和时间平均值时,显示时间列总和的方式。 “ Dist”列(绿色箭头)
我已经在paramquery论坛上阅读过类似的帖子,但是我没有找到如何做的。
预先感谢