使用列标题定位并搜索
公用js
common.js
function input_text_addSearchPre(modeId, targetId, selectId, valueId) { $("#" + valueId).attr("onkeydown", "if(event.keyCode==13){event.keyCode=0;event.returnValue=false;input_text_addSearchPost('" + modeId + "','" + targetId + "','" + selectId + "','" + valueId + "');}") } function input_text_addSearchPost(modeId, targetId, selectId, valueId) { var model = $("#" + modeId + " option:selected").val(); var colPo = $("#" + selectId + " option:selected").val(); var value = $("#" + valueId).val(); var tds = $("#" + targetId + " tr").find("td:eq(" + colPo + ")"); $.each(tds, function() { if (model == 0) { if ($(this).text().indexOf(value) >= 0) { $(this).parent("tr").show(); } else { $(this).parent("tr").hide(); } } else if (model == 1) { if ($(this).text().indexOf(value) < 0) { $(this).parent("tr").hide(); } } }); }
页面js
<script type="text/javascript" src="/ChargingSystem/js/common.js"></script> <script type="text/javascript"> $(document).ready(function() { input_text_addSearchPre("select_modeSelect", "tbody_userRepository", "select_selectColPo", "input_text_searchValue"); }) </script>
参考用例
<select id="select_modeSelect" style="width: 100px; height: 100%;" onmouseover="select_modeSelect_onmouseover()"> <option value="temp">模式</option> <option value="0">平行</option> <option value="1">递进</option> </select> <select id="select_selectColPo" style="width: 100px; height: 100%; margin-left: 0px;" onmouseover="select_selectColPo_onmouseover()"> <option value="temp">位置</option> </select> <input id="input_text_searchValue" type="text" style="width: 200px; height: 21px; margin-left: 0px;" />