1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
| <!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="./script/jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="./script/scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxmenu.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxcheckbox.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxlistbox.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxdropdownlist.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxgrid.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxgrid.pager.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxgrid.edit.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxgrid.selection.js"></script>
<script type="text/javascript" src="./script/jqwidgets/jqxdata.js"></script>
<script type="text/javascript" src="./script/scripts/gettheme.js"></script>
<script type="text/javascript">
function lbox(){
$("input[type='checkbox']:checked").each(
function() {
console.log($(this).attr('id'));
// });
}
);
}
$(document).ready(function () {
// prepare the data
var theme = getDemoTheme();
var source =
{
datatype: "json",
datafields: [
{ name: 'Year', type: 'number' },
{ name: 'Country', type: 'string'},
{ name: 'Site', type: 'string'},
{ name: 'DataDomain', type: 'string'},
{ name: 'Project', type: 'string'},
{ name: 'available', type: 'bool' },
{ name: 'Title', type: 'string'}
],
url: 'all_data.php',
root: 'Rows',
cache: false,
beforeprocessing: function(data)
{
source.totalrecords = data[0].TotalRows;
},
updaterow: function (rowid, rowdata, commit) {
// synchronize with the server - send update command
commit(true);
}
};
var dataadapter = new $.jqx.dataAdapter(source);
var columnCheckBox = null;
var updatingCheckState = false;
// initialize jqxGrid
$("#jqxgrid").jqxGrid(
{
width: 780,
source: dataadapter,
theme: theme,
autoheight: true,
pageable: true,
virtualmode: true,
editable: false,
enablehover: false,
selectionmode: 'none',
rendergridrows: function()
{
return dataadapter.records;
},
columns: [
//{ text: '', datafield: 'available', width: 40},
{text: '', datafield: 'available', columntype: 'checkbox', width: 40,
renderer: function () {
return '<div style="margin-left: 10px; margin-top: 5px;"></div>';
},
rendered: function (element) {
$(element).jqxCheckBox({ theme: theme, width: 16, height: 16, animationShowDelay: 0, animationHideDelay: 0 });
columnCheckBox = $(element);
$(element).on('change', function (event) {
var checked = event.args.checked;
if (checked == null || updatingCheckState) return;
var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
$("#jqxgrid").jqxGrid('beginupdate');
if (checked) {
$("#jqxgrid").jqxGrid('selectallrows');
}
else if (checked == false) {
$("#jqxgrid").jqxGrid('clearselection');
}
for (var i = 0; i < rowscount; i++) {
$("#jqxgrid").jqxGrid('setcellvalue', i, 'available', event.args.checked);
}
$("#jqxgrid").jqxGrid('endupdate');
});
}
},
{ text: 'Year', datafield: 'Year', width: 60},
{ text: 'Country', datafield: 'Country', width: 100 },
{ text: 'Site', datafield: 'Site', width: 100 },
{ text: 'Data Domain', datafield: 'DataDomain', width: 130 },
{ text: 'Project', datafield: 'Project', width: 100 },
{ text: 'Title', datafield: 'Title'}
]
});
});
// select or unselect rows when the checkbox is checked or unchecked.
$("#jqxgrid").on('cellendedit', function (event) {
if (event.args.value) {
$("#jqxgrid").jqxGrid('selectrow', event.args.rowindex);
}
else {
$("#jqxgrid").jqxGrid('unselectrow', event.args.rowindex);
}
if (columnCheckBox) {
var selectedRowsCount = $("#jqxgrid").jqxGrid('getselectedrowindexes').length;
var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
updatingCheckState = true;
if (selectedRowsCount == rowscount) {
$(columnCheckBox).jqxCheckBox('check')
}
else if (selectedRowsCount > 0) {
$(columnCheckBox).jqxCheckBox('indeterminate');
}
else {
$(columnCheckBox).jqxCheckBox('uncheck');
}
updatingCheckState = false;
}
});
</script>
</head>
<body class='default'>
<div id='jqxWidget' align="center"><br />
<div id="jqxgrid"></div><br />
<form name="form1" method="post" action="exedownload.php">
<label>
<input type="checkbox" name="maincheck" id="maincheck" width="16" height="16" onClick="lbox()">
Select all files<br />
</label>
<input type="submit" name="downlobut" value="Download Selected Files">
</form>
</div>
</body>
</html>
<!--serverpaging_data.php
#Include the connect.php file
include('connect.php');
#Connect to the database
//connection String
$connect = mysql_connect($hostname, $username, $password)
or die('Could not connect: ' . mysql_error());
//Select The database
$bool = mysql_select_db($database, $connect);
if ($bool === False){
print "can't find $database";
}
// get data and store in a json array
$pagenum = $_GET['pagenum'];
$pagesize = $_GET['pagesize'];
$start = $pagenum * $pagesize;
$query = "SELECT SQL_CALC_FOUND_ROWS * FROM Customers LIMIT $start, $pagesize";
$result = mysql_query($query) or die("SQL Error 1: " . mysql_error());
$sql = "SELECT FOUND_ROWS() AS `found_rows`;";
$rows = mysql_query($sql);
$rows = mysql_fetch_assoc($rows);
$total_rows = $rows['found_rows'];
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$customers[] = array(
'CompanyName' => $row['CompanyName'],
'ContactName' => $row['ContactName'],
'ContactTitle' => $row['ContactTitle'],
'Address' => $row['Address'],
'City' => $row['City'],
'Country' => $row['Country']
);
}
$data[] = array(
'TotalRows' => $total_rows,
'Rows' => $customers
);
echo json_encode($data);
--> |
Partager