问题描述
当用户在“帐户”或“发票”框中键入一些值以在表中进行搜索时,则一切正常。但是,当我添加代码行以通过下拉值进行其他过滤时,它行不通。表格中要过滤的数据在第6列中。没有返回任何行:
查看:
<th>
<p>
Nr account: @Html.TextBox("Account")
<input type="button" class="search" value="Search" />
</p>
<p>
Nr invoice: @Html.TextBox("Invoice")
<input type="button" class="search" value="Search" />
</p>
<p>
@Html.DropDownList("filterList",new List<SelectListItem>
{
new SelectListItem { Text="",Value= "",Selected=true},new SelectListItem { Text="Cancellation",Value="Cancellation"}
})
<input type="button" class="search" value="Filter data" />
</p>
</th>
jQuery:
$('.search').click(function () {
var value1 = $("#Account").val().toLowerCase();
var value2 = $("#Invoice").val().toLowerCase();
var value3 = $("#filterList:selected").val(); //value od seleted item (or not selected if I don't choose anything)
$("#myTable tr").filter(function () {
var text1 = $(this).children(":eq(" + "0" + ")").text().toLowerCase() //search values in 1st column
var text2 = $(this).children(":eq(" + "2" + ")").text().toLowerCase()
var text3 = $(this).children(":eq(" + "5" + ")").text()
$(this).toggle((text1.indexOf(value1) > -1) && (text2.indexOf(value2) > -1) && (text3.indexOf(value3) > -1))
});
});
似乎常规的TextBoxes在这里不与DropDownList合作。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)