如何在 gridview 中突出显示单词 [英] How can I highlight a word within gridview
本文介绍了如何在 gridview 中突出显示单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 gridview 控件中突出显示查询的文本?
How can I highlight the text of a query in the gridview control?
推荐答案
如果你想做这个客户端,请按照以下步骤操作:
if you want do this client side please follow this steps:
向您的页面添加 jQuery 引用.添加一个文本输入调用 txt_Search
.
add jQuery reference to your page.add a text input calles txt_Search
.
然后使用这个脚本:
$(document).ready(function () {
$('#txt_Search').keyup(function () {
searchTable($(this).val());
});
function searchTable(inputVal) {
var table = $('#GridView1');
table.find('tr').each(function (index, row) {
var allCells = $(row).find('td');
if (allCells.length > 0) {
var found = false;
allCells.each(
function (index, td) {
var regExp = new RegExp(inputVal, 'i');
if (regExp.test($(td).text())) {
found = true;
return false;
}});
if (found == true) $(row).show(); else $(row).hide();
}
});
}
});
这篇关于如何在 gridview 中突出显示单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文