javascript — фильтр строк таблицы без пагинации

Я хочу отфильтровать данные таблицы, но у меня есть более ста строк, поэтому я использовал нумерацию страниц. Если я применяю какой-либо фильтр, он фильтрует только текущую страницу, находящуюся внутри таблицы.

HTML и JavaScript-код приведены ниже

<select id='filterText' style='display:inline-block' onchange='filterText()'>
<option disabled selected>Select</option>
<option value='Active'>Active</option>
<option value='Obsolete'>Obsolete</option>
<option value='all'>All</option>
</select><table class="table table-striped table-bordered table-hover  table-list-search" id="dataTables-example"  >
<thead>
<tr style="background-color:#abdcd5;">
<th align="left" class="col-xs-2">Employee ID</th>
<th align="left" class="col-xs-1">Name</th>
<th align="left" class="col-xs-2">Location</th>
<th align="left" class="col-xs-2">Company </th>
<th align="left" class="col-xs-3">Job Description</th>
<th align="left" class="col-xs-1">Status</th>
<th align="left" class="col-xs-1">Action</th>
</tr>
</thead>
<tbody>

<?php employeedetails::employeelist();?>

</tbody>
</table>

Javascript

<script>
function filterText() {
var rex = new RegExp($('#filterText').val());
if(rex == "/all/") {
clearFilter();
} else {
$('.content').hide();
$('.content').filter(function() {
return rex.test($(this).text());
}).show();
}
}

function clearFilter() {
$('.filterText').val('');
$('.content').show();
}
</script>

Код php

  <?php

class employeedetails
{

//function for display details of employee

static function employeelist()
{
$tenanPortalId = $_SESSION['PortalID'];
$databaseConnectionObject = new DB_CONNECT();

$resultForGettingDetailsOfEmployees  =   mysqli_query($databaseConnectionObject->connect(),$Query);

if(!$resultForGettingDetailsOfEmployees){

die(mysqli_error($databaseConnectionObject->connect()));
}

else if($resultForGettingDetailsOfEmployees)
{while($row = mysqli_fetch_array($resultForGettingDetailsOfEmployees))
{$employee_ID=$row['employee_id'];
$employee_ID_trim = str_replace($tenanPortalId."~","",$row['employee_id']);
$employee_Name=$row['employee_name'];
$employee_Location=$row['employee_location'];
$employee_Status=$row['employee_Status'];
$expenseManager=$row['expenseManager'];
$SnactionManager=$row['SnactionManager'];
$EmployeeLocation=$row['countryName'];
$hireDate=$row['hireDate'];

if($row['company'] == "->")
{
$company = "";
}
else
{
$company=$row['company'];
}

if($row['reportingLineUnit'] == "->")
{
$reportingLineUnit="";
}
else
{
$reportingLineUnit=$row['reportingLineUnit'];
}

$employeeType = $row['employeeType'];
$jobdescription = $row['jobDescription'];

?>
<tr class="content">
<td>

<a data-toggle="modal" data-target='#<?php echo "$employee_ID_trim"; ?>' style="cursor: pointer;">
<?php echo "$employee_ID";?>
</a>

<?php

$msg = "";
if($SnactionManager == "" || $SnactionManager == "No")
{
$msg = "Do you want to make $employee_Name as Sanction Manager?" ;
}
else
{
$msg = "Do you want to remove $employee_Name as Sanction Manager?" ;
//echo " <span><img src='../assets/img/twouser.png' width='20px;' height='20px;'/></span>";
}

echo $imgPath = ($expenseManager == "Yes") ?
(($SnactionManager == "Yes") ? " <span><img src='../assets/img/twouser.png' width='20px;' height='20px;' title='Project & Sanction Manager'/></span>" : " <span><img src='../assets/img/project.png' width='20px;' height='20px;' title='Project Manager'/></span>" )
:
(($SnactionManager == "Yes") ? " <span><img src='../assets/img/sanction.png' width='20px;' height='20px;' title='Sanction Manager'/></span>" : "" ) ;
?><!-- Modal -->
<div id='<?php echo "$employee_ID_trim"; ?>' class="modal fade" role="dialog"  ">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">
<?php echo "$employee_Name";?>
</h4>
</div>
<div class="modal-body">
<div class="table-responsive">
<table class="table table-bordered table-hover">
<tr style="background-color:#abdcd5;">
<th align="left" class="col-xs-2">Project Manager</th>
<th align="left" class="col-xs-2">Sanction Manager</th>
<th align="left" class="col-xs-2">Type</th>
<th align="left" class="col-xs-2">Reporting Line Unit </th>
<th align="left" class="col-xs-2">Hire Date </th>

</tr>
<tr>
<td><?php echo "$expenseManager";?></td>

<td><?php echo "$SnactionManager";?></td>

<td><?php echo "$employeeType";?></td>

<td><?php echo "$reportingLineUnit";?></td>

<td><?php echo date("m/d/Y", strtotime($hireDate));?></td>

</tr>

</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>

</div>
</div>

</td>
<td>
<?php echo "$employee_Name"; ?>

</td>
<td><?php echo "$EmployeeLocation";?></td><td><?php echo "$company";?></td>

<td><?php echo "$jobdescription";?></td><?php $color =($employee_Status=="Obsolete" ? "red" : "green") ; ?><td style="color:<?php echo $color; ?> ;font-weight:bold;text-align:center;"><?php echo "$employee_Status";?></td>

<td align="center"><button type="button" style="background-color:#00a4a4;border-color:#00a4a4;" class="btn btn-primary btn-xs" data-toggle="modal" data-target='#<?php echo "$employee_ID_trim"."SMM"; ?>' style="cursor: pointer;">
<span  class="glyphicon glyphicon-pencil"></span>
</button><div id='<?php echo "$employee_ID_trim"."SMM"; ?>' class="modal fade" role="dialog"  ">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">
<?php echo "$employee_Name";?>
</h4>
</div>
<div class="modal-body">
<div class="row" style="padding-bottom:5%;">
<?php echo $msg; ?>
</div>
<div class="row" style="padding-bottom:3%;">

<form id="eventForm"  action="../index.php" method ="POST">

<input type="hidden" class="form-control" id=""  name="EmployeeId" value="<?php echo "$employee_ID"; ?>" />
<input type="hidden" class="form-control" id=""  name="EmployeeName" value="<?php echo "$employee_Name"; ?>" />
<?php
$buttonName = "Assign";
if($SnactionManager == "" || $SnactionManager == "No")
{
?>
<input type="hidden" name="SnManager"  value="Yes">
<?php
}
else
{
$buttonName = "Remove";
?>
<input type="hidden" name="SnManager"  value="No">
<?php
}
?>

<button type="submit" class="btn btn-primary" value="Assign Manger" name="operation">
<span class="glyphicon glyphicon-ok" ></span>
<?php echo $buttonName; ?>
</button>

<button type="button" class="btn btn-danger" data-dismiss="modal">
<span class="glyphicon glyphicon-remove" ></span>
Cancel
</button>

</form></div>
</div>

</div>
</div>
</div>
</td>
</tr><?php
} //while

} //else if

} //function
} //class
?>

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]