gpt4 book ai didi

php - 如何在不生成任何 td 等的 HTML 表格中进行搜索?

转载 作者:行者123 更新时间:2023-11-28 02:51:14 25 4
gpt4 key购买 nike

我已经根据 http://www.jtable.org 创建了一个表模板、我的表和大部分功能都已启动并运行,但是当我想包含一个搜索栏以在我键入时过滤表结果时遇到问题。我认为问题在于我使用 php 创建的大多数表都在代码中创建了实际的 html 表,例如 td 和 tr,并且搜索功能将关闭匹配这些术语。

但是目前我的表是在前端生成的,后端没有实际的 HTML 内容,所以我无法搜索。是否有任何方法可以使用此代码搜索此表,可能使用服务器端处理,或者我不知道的其他方法?

这是我正在使用的代码:

<html>
<title> title </title>
<head>

<link href="themes/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
<link href="scripts/jtable/themes/metro/darkgray/jtable.css" rel="stylesheet" type="text/css" />

<script src="scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="scripts/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="scripts/jtable/jquery.jtable.js" type="text/javascript"></script>

</head>

<body>
<div class="filtering">

<body>


<input type="text" style="background-color: #e6ffff;" placeholder="Search Any Column" size="70" id="search";/>
</body>



<div id="PeopleTableContainer" style="width: relative;" ></div>
<img src="Sharks-2-Trans-30-150623-2.png" width="150" height="43" style="float:bottom-right; opacity: 10;">



<script type="text/javascript">

$(document).ready(function () {

//Prepare jTable
$('#PeopleTableContainer').jtable({
title: 'ICS Central',
paging: true, //Enable paging
pageSize: 10, //Set page size (default: 10)
sorting: true, //Enable sorting
defaultSorting: 'ISO_Name ASC', //Set default sorting
selecting: true, //Enable selecting
multiselect: true, //Allow multiple selecting
selectingCheckboxes: true, //Show checkboxes on first column
//selectOnRowClick: false, //Enable this to only select using checkboxes

actions: {
listAction: 'PersonActions2.php?action=list',
createAction: 'PersonActions2.php?action=create',

updateAction: 'PersonActions2.php?action=update',
deleteAction: 'PersonActions2.php?action=delete'
},

fields: {
PersonId: {
key: true,
create: false,
edit: false,
list: false
},
ISO_Name: {
title: 'ISO Name',
width: '5%'
},
ICS_Defect: {
title: 'Defect #',

width: '5%'
},
Abstract: {
title: 'Abstract',

width: '30%'
},
problem_description: {
title: 'Problem Description',

width: '30%'
},
fix_description: {
title: 'Fix Description',

width: '30%'

},

levels_approved: {
title: 'Levels Approved',

width: '30%'

},
reboot_required: {
title: 'Reboot Required?',

width: '30%'

},
reapplied_after_ccl: {
title: 'Reapplied After CCL?',

width: '30%'

},
reapplied_after_hmc_rebuild: {
title: 'Reapplied After HMC Rebuild?',

width: '30%'

},
bundle_fix_cmvc: {
title: 'Bundle Fix CMVC',

width: '30%'

}


},




//Register to selectionChanged event to hanlde events
selectionChanged: function () {
//Get all selected rows
var $selectedRows = $('#PeopleTableContainer').jtable('selectedRows');

$('#SelectedRowList').empty();
if ($selectedRows.length > 0) {
//Show selected rows
$selectedRows.each(function () {
var record = $(this).data('record');
$('#SelectedRowList').append(
'<b>ISO_Name</b>: ' + record.ISO_Name +
'<br /><b>Abstract</b>:' + record.Abstract + '<br /><br />'
);
});
} else {
//No rows selected
$('#SelectedRowList').append('No row selected! Select rows to see here...');
}
},
// rowInserted: function (event, data) {
// if (data.record.ISO_Name.indexOf('Add_Info_HB_v1.0.iso') >= 0) {
// $('#PeopleTableContainer').jtable('selectRows', data.row);
//}
//}
});

//Load student list from server
$('#PeopleTableContainer').jtable('load');

//Delete selected students
$('#DeleteAllButton').button().click(function () {
var $selectedRows = $('#PeopleTableContainer').jtable('selectedRows');
$('#PeopleTableContainer').jtable('deleteRows', $selectedRows);
});
});
</script>

</body>
</html>

最佳答案

我使用搜索文本字段并在 keyUp 上过滤结果,但这不是客户端过滤。它对列表操作进行 ajax 调用,并使用变量 searchname 进行过滤。我们使用 Hibernate 并有一行代码从数据库中进行过滤,例如:“obj.name like '%searchname%'”

<body>
<div class="filtering">
Name: <input type="text" id="search"/>
</div>
<body>

...
...

<script type="text/javascript">

$(document).ready(function () {
...
$('#search').keyup(function(){
$('#PeopleTableContainer').jtable('load', {searchname: $(this).val()});
});
}

关于php - 如何在不生成任何 td 等的 HTML 表格中进行搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39259433/

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