gpt4 book ai didi

php - jquery easyui 分页

转载 作者:行者123 更新时间:2023-11-29 23:54:30 28 4
gpt4 key购买 nike

我正在尝试为数据网格进行分页。我可以根据查询从 Oracle 数据库导入数据。所有数据都显示在浏览器中。问题是所有数据都在一页上。我必须向下滚动才能看到所有数据。当我按下“下一步”按钮时,没有任何反应,只需刷新页面,数据是相同的。我无法继续下一页或上一页。这是我的代码:

<html>  
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="jquery,ui,easy,easyui,web">
<meta name="description" content="easyui help you build your web page easily!">
<title>jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/gray/easyui.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<script>
$(function(){
var pager = $('#tt').datagrid('getPager'); // get the pager of datagrid
pager.pagination({
showPageList:false,
buttons:[{
iconCls:'icon-search',
handler:function(){
alert('search');
}
},{
iconCls:'icon-add',
handler:function(){
alert('add');
}
},{
iconCls:'icon-edit',
handler:function(){
alert('edit');
}
}],
onBeforeRefresh:function(){
alert('before refresh');
return true;
}
});
});
</script>
</head>
<body

<?PHP
header('Refresh: 900');

require_once 'connect.php';

$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$sort = isset($_POST['sort']) ? strval($_POST['sort']) : 'NGM_CREATION_TIME';
$order = isset($_POST['order']) ? strval($_POST['order']) : 'desc';
$offset = ($page-1)*$rows;

$sql = "select c.case_id as NGM_ID,
s.NE_PRIORITAET as NE_PRIO,
case substr(s.NE_ID, 2,1)
when '0' then 'Zentrale'
when '1' then 'Nord'
when '2' then 'Nord'
when '3' then 'Ost'
when '4' then 'Ost'
when '5' then 'Mitte'
when '6' then 'West'
when '7' then 'Süd'
when '8' then 'Mitte'
when '9' then 'Süd'
else 'Error'
end as REGION,
c.STATUS_NGM as NGM_STATUS,
s.AUFTRAG as AUFTRAG,
s.NE_ID as NE_ID,
s.STATUS as SAP_STATUS,
substr(to_timestamp(to_char(Sysdate, 'YY/MM/DD HH24:MI:SS'), 'YY/MM/DD HH24:MI:SS') - to_timestamp(to_char(s.CREATION_TIME, 'YY/MM/DD HH24:MI:SS'), 'YY/MM/DD HH24:MI:SS'), 8,12) as DIFF_BEGINN_SAP_ENDE,
case trim(s.KATEGORIE)
when '1' then 'INSLA'
when '2' then 'OUTSLA'
else s.KATEGORIE
end as SLA,
to_char(c.CREATION_TIME, 'YY/MM/DD HH24:MI:SS')
as NGM_CREATION_TIME,
case s.NE_PRIORITAET
when 'A' then substr(to_char((to_timestamp(to_char((Sysdate + 6/24), 'YY/MM/DD HH24:MI:SS'), 'yyyy.mm.dd hh24:mi:ss') - to_timestamp(to_char(s.CREATION_TIME, 'yyyy.mm.dd hh24:mi:ss'), 'YY/MM/DD HH24:MI:SS')), 'dd hh24:mi:ss'),8,12)
when 'B' then substr(to_char((to_timestamp(to_char((Sysdate + 1), 'YY/MM/DD HH24:MI:SS'), 'yyyy.mm.dd hh24:mi:ss') - to_timestamp(to_char(s.CREATION_TIME, 'YY/MM/DD HH24:MI:SS'), 'yyyy.mm.dd hh24:mi:ss')), 'dd hh24:mi:ss'), 8,12)
when 'C' then substr(to_char((to_timestamp(to_char((Sysdate + 1), 'YY/MM/DD HH24:MI:SS'), 'yyyy.mm.dd hh24:mi:ss') - to_timestamp(to_char(s.CREATION_TIME, 'YY/MM/DD HH24:MI:SS'), 'yyyy.mm.dd hh24:mi:ss')), 'dd hh24:mi:ss'),8,12)
else substr(to_char((to_timestamp(to_char((Sysdate + 1), 'YY/MM/DD HH24:MI:SS'), 'yyyy.mm.dd hh24:mi:ss') - to_timestamp(to_char(s.CREATION_TIME, 'YY/MM/DD HH24:MI:SS'), 'yyyy.mm.dd hh24:mi:ss')), 'dd hh24:mi:ss'), 8,12)
end as TIME_LEFT_OVERRUN,

c.URSACHE_KURZ as URSACHE_KURZ,
s.BEARBEITER as BEARBEITER
from dash_omc_cases c,
dash_omc_sap s";


$stid = oci_parse($db_con, $sql);

oci_define_by_name($stid, 'NGM ID', $NGM_ID);
oci_define_by_name($stid, 'NE Prio', $NE_Prio);
oci_define_by_name($stid, 'Region', $Region);
oci_define_by_name($stid, 'NGM Status', $NGM_Status);
oci_define_by_name($stid, 'Auftrag', $Auftrag);
oci_define_by_name($stid, 'NE ID', $NE_ID);
oci_define_by_name($stid, 'SAP Status', $SAP_Status);
oci_define_by_name($stid, 'Diff Beginn Sap Ende', $Diff_Beginn_Sap_Ende);
oci_define_by_name($stid, 'NGM Creation Time', $NGM_Creation_Time);
oci_define_by_name($stid, 'Time Left/Overrun', $Time_Left_Overrun);
oci_define_by_name($stid, 'Ursache Kurz', $Ursache_Kurz);
oci_define_by_name($stid, 'Bearbeiter', $Bearbeiter);


oci_execute($stid);
?>

数据网格

<table id="tt" title="Load Data" class="easyui-datagrid" style="width:1300px;height:400px"
url="connect.php"
iconCls="icon-save" rownumbers="true" pagination="true">
<thead>
<tr>
<th field="NGM_ID" width="80px">NGM ID</th>
<th field="NE Prio" width="80px">NE Prio</th>
<th field="Region" width="80px" align="right">Region</th>
<th field="NGM Status" width="80px" align="right">NGM Status</th>
<th field="Auftrag" width="80px">Auftrag</th>
<th field="NE ID" width="80px" align="center">NE ID</th>
<th field="SAP Status" width="80px" align="center">SAP Status</th>
<th field="Diff Beginn Sap End" width="120px" align="center">Diff Beginn Sap End</th>
<th field="SLA" width="120px" align="center">SLA</th>
<th field="NGM Creation Time" width="120px" align="center">NGM Creation Time</th>
<th field="Time Left Overrun" width="120px" align="center">Time Left/Overrun</th>
<th field="Ursache Kurz" width="120px" align="center">Ursache Kurz</th>
<th field="Bearbeiter" width="120px" align="center">Bearbeiter</th>
</tr>

</thead>


<?php

while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {

?>
<tr>
<td style="border: 7px solid; width: 80px; "> <?php echo $row['NGM_ID']; ?></td>
<td style="border: 7px solid; width: 80px; "> <?php echo $row['NE_PRIO']; ?></td>
<td style="border: 7px solid; width: 80px; "> <?php echo $row['REGION']; ?></td>
<td style="border: 7px solid; width: 80px; "> <?php echo $row['NGM_STATUS']; ?></td>
<td style="border: 7px solid; width: 80px; "> <?php echo $row['AUFTRAG']; ?></td>
<td style="border: 7px solid; width: 80px; "> <?php echo $row['NE_ID']; ?></td>
<td style="border: 7px solid; width: 80px; "> <?php echo $row['SAP_STATUS']; ?></td>
<td style="border: 7px solid; width: 120px; "> <?php echo $row['DIFF_BEGINN_SAP_ENDE']; ?></td>
<td style="border: 7px solid; width: 120px; "> <?php echo $row['SLA']; ?></td>
<td style="border: 7px solid; width: 120px; "> <?php echo $row['NGM_CREATION_TIME']; ?></td>
<td style="border: 7px solid; width: 120px; "> <?php echo $row['TIME_LEFT_OVERRUN']; ?></td>
<td style="border: 7px solid; width: 120px; "> <?php echo $row['URSACHE_KURZ']; ?></td>
<td style="border: 7px solid; width: 120px; "> <?php echo $row['BEARBEITER']; ?></td>
</tr>

<?php
}
?>

最佳答案

我做什么:

我在第 2 点的第二个函数中格式化了数据,负责分页和排序列。

1|获取带有计数的数据,以了解您有多少结果:

public static function searchByDepAsArrayBis($dep)
{
$command = Yii::app()->db->createCommand()
->select('*')
->from('Objectif')
->leftJoin('OSDep','Objectif.Id_OSDep = OSDep.Id_OSDep')
->where('OSDep.DivisionAbr like :dep', array(':dep'=>$dep.'%'));

if($command)
{
$data = $command->queryAll();

return array($data,count($data));
}
}

2|将数据放置到位:查找分页。

public function actionDataDep($dep)
{
$objectif = new Objectif;
$this->amILog();
// get data + countData
//$lTemp=Parametre::searchByUserAsArray($idUser,$role);
$lTemp=$objectif->searchByDepAsArrayBis($dep);


// Define output to encode
$lOutput = array(
"sEcho" => intval($_GET['sEcho']),
"iTotalRecords" => count($lTemp),
"iTotalDisplayRecords" => $lTemp[1],
"aaData" => $this->dataDesktopDep($lTemp[0])
);


// encode and show result
echo json_encode($lOutput);
}

private function dataDesktopDep($aResults)
{
$lData = array();
// column definition
$lColumns = array('Id_Objectif','Libelle', 'AbrProprio', 'LibProprio','Statut', 'Alerte', 'Sante');


// loop each result
foreach($aResults as $result)
{

$row = array();

// format data in right form
foreach($lColumns as $column)
{
if( $column == 'Id_Objectif' )
$row[] = $result['Id_Objectif'];
else if ( $column == 'Libelle' )
{
$p = Objectif::model()->findByPk($result['Id_Objectif']);
$row[] = $p->Libelle;//$result['Libelle'];
}
else if( $column == 'Alerte' )
{

$p = Objectif::model()->findByPk($result['Id_Objectif']);
if($p->Alerte == 'green')
$row[] = CHtml::image(Yii::app()->baseUrl."/images/icones/green.png","",array("style"=>"margin:auto;width:50px;height:25px;margin-top:2px;"));
else if($p->Alerte == 'red')
$row[] = CHtml::image(Yii::app()->baseUrl."/images/icones/red.png","",array("style"=>"margin:auto;width:50px;height:25px;margin-top:2px;"));
else if($p->Alerte == 'orange')
$row[] = CHtml::image(Yii::app()->baseUrl."/images/icones/orange.png","",array("style"=>"margin:auto;width:50px;height:25px;margin-top:2px;"));

}
else if($column == 'AbrProprio')
{
$row[] = $result['ProprioAbr'];
}
else if($column == 'LibProprio')
{
$row[] = $result['ProprioLib'];
}
else if( $column == 'Statut' )
{
$p = Objectif::model()->findByPk($result['Id_Objectif']);

$row[] = $p->Statut;
}
else if( $column == 'Sante' )
{
$p = Objectif::model()->findByPk($result['Id_Objectif']);

$row[] = $row[] = $p->MoyennePerso;
}



}

$lData[] = $row;
}


if($aResults!=null)
{


// SORT
if ( isset( $_GET['iSortCol_0'] ) )
{

/*if($_GET['iSortCol_0']==0)
$lCommand->order('i.CodeInt '.($_GET['sSortDir_0']==='asc' ? 'ASC' : 'DESC'));
else if($_GET['iSortCol_0']==1)
$lCommand->order('i.Libelle '.($_GET['sSortDir_0']==='asc' ? 'ASC' : 'DESC'));
else if($_GET['iSortCol_0']==2)
$lCommand->order('isp.SousCom1 '.($_GET['sSortDir_0']==='asc' ? 'ASC' : 'DESC'));*/

//if($_GET['iSortCol_0']==0)
//{
if($_GET['sSortDir_0']==='asc')
{
// Obtient une liste de colonnes
foreach ($lData as $key => $row) {
$rang[$key] = $row[$_GET['iSortCol_0']];
}
array_multisort($rang, SORT_ASC, $lData);

}
else
{
foreach ($lData as $key => $row) {
$rang[$key] = $row[$_GET['iSortCol_0']];
}
array_multisort($rang, SORT_DESC, $lData);
}
//}
}



//PAGINATION

if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$tabPagin = array();

for($i = $_GET['iDisplayStart']; $i<($_GET['iDisplayLength']+$_GET['iDisplayStart'])&& $i<count($lData) ;$i++)
{
$tabPagin[] = $lData[$i];
}
}

// Set the formated result in the Tab


return $tabPagin;
}
else
{
return $lData;
}

}

3|最后是我的观点

<div>
<script>
var oTable;
var oSettings;

$(document).ready(function ()
{
bTable=$('#tableDGO4').dataTable({


"aoColumnDefs": [


{"bVisible":false, "aTargets":[0]},
{"sWidth":"30px", "aTargets":[2,3,4,5,6]},
{"sWidth":"300px", "aTargets":[1]},
{"bAutoWidth":true, "aTargets":[0,1,3,2,4,5,6]},
{"bSortable":true, "aTargets":[0,1,2,3,4,5,6]}

],
"oLanguage": {
"oPaginate": {
"sNext": "<img class='middle' src= '<?php echo Yii::app()->baseUrl.'/images/page_next.png';?>' />",
"sPrevious": "<img class='middle' src= '<?php echo Yii::app()->baseUrl.'/images/page_previous.png';?>' />",
"sFirst": "<img class='middle' src= '<?php echo Yii::app()->baseUrl.'/images/page_first.png';?>' />",
"sLast": "<img class='middle' src= '<?php echo Yii::app()->baseUrl.'/images/page_last.png';?>' />"
},
"sInfo": "Résultats _START_ à _END_ - _TOTAL_ objectifs",
"sInfoFiltered": "",
"sSearch": "Filtrer les résultats : ",
"sEmptyTable": "Votre recherche n'a ramené aucun résultat.",
"sInfoEmpty": "Votre recherche n'a ramené aucun résultat.",
"sProcessing" : "Chargement...",
"sLengthMenu" : "Montrer _MENU_ résultats par page"
},
"sDom": '<"H"li>tr<"F"p>',
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "<?php echo $this->createUrl('site/dataDep', array('dep'=>'DGO4')); ?>",
"aLengthMenu":[10,25,50,75,100],
"iDisplayLength":10,

"createdRow": function( row, data ) {
if ( data[5] == 'red' ) {
$(row).addClass( 'red' );
}
else if ( data[5] == 'green' ) {
$(row).addClass( 'green' );
}
else if ( data[5] == 'orange' ) {
$(row).addClass( 'orange' );
}
},
"fnDrawCallback":function(nRow, aData, iDisplayIndex){
// Fonction appelée quand clic sur une ligne du corps du tableau
$('#tableDGO4 tbody tr').click( function(id){
var col = bTable.fnGetData( this );
var idParam = col[0];
document.location.href = "<?php echo $this->createUrl('Objectif/view').'/id/'; ?>"+idParam;
});




}

});
}
);

</script>

<table id="tableDGO4">
<thead>
<tr>
<th>Id Obj</th>
<th>Libellé</th>
<th>Abréviation propriétaire</th>
<th>Libellé propriétaire</th>
<th>Statut</th>
<th>Alerte</th>
<th>Santé</th>
</tr>
</thead>
<tbody class="CurseurMain" >
</tbody>
</table>

</div>

希望他能帮助您解决问题。

关于php - jquery easyui 分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25442413/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com