在另一个函数之后调用Javascript函数

时间:2016-06-24 07:47:11

标签: javascript jquery jquery-ui jquery-plugins

我需要在基于按键的功能完成后调用javascript函数。

-function自动过滤textbox按键上的gridview记录

 <script type="text/javascript">
          function filter2(phrase, _id) {

              var words = phrase.value.toLowerCase().split(" ");
              var table = document.getElementById(_id);

              var ele;

              for (var r = 1; r < table.rows.length; r++) {
                  ele = table.rows[r].innerHTML.replace(/<[^>]+>/g, "");
                  var displayStyle = 'none';
                  for (var i = 0; i < words.length; i++) {
                      if (ele.toLowerCase().indexOf(words[i]) >= 0) {
                          displayStyle = '';

                      }
                      else {
                          displayStyle = 'none';
                          break;
                      }

                  }  
                  table.rows[r].style.display = displayStyle;       
              }
          }

之后调用的函数

-function to fixate gridview header

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script src="jquery/JQueryUICalendar/js/gridviewScroll.min.js"  type="text/javascript"></script>


<script type="text/javascript">


        var $160 = jQuery.noConflict();
        $160(document).ready(function () {
            gridviewScroll();
        });

        function gridviewScroll() {
            $160('#<%=grdTenant.ClientID%>').gridviewScroll({
                width: 1080,
                height: 340,
                // freezesize: 2, //kung gusto mag free yung column enable this pls
                //IsInUpdatePanel: true
                arrowsize: 30,
                varrowtopimg: "images/arrowvt.png",
                varrowbottomimg: "images/arrowvb.png",
                harrowleftimg: "images/arrowhl.png",
                harrowrightimg: "images/arrowhr.png"
            });
        }

</script>

这就是我所做的,我把gridviewScroll()放在第一个函数的末尾,但预期的输出不起作用。

 <script type="text/javascript">
              function filter2(phrase, _id) {

                  var words = phrase.value.toLowerCase().split(" ");
                  var table = document.getElementById(_id);

                  var ele;

                  for (var r = 1; r < table.rows.length; r++) {
                      ele = table.rows[r].innerHTML.replace(/<[^>]+>/g, "");
                      var displayStyle = 'none';
                      for (var i = 0; i < words.length; i++) {
                          if (ele.toLowerCase().indexOf(words[i]) >= 0) {
                              displayStyle = '';

                          }
                          else {
                              displayStyle = 'none';
                              break;
                          }

                      }  
                      table.rows[r].style.display = displayStyle;       
                  }
                  gridviewScroll();
              }

调用filter2()函数的文本框

   <input id="txtTerm" name="txtTerm" type="text" onkeyup="filter2(this, '<%=grdTenant.ClientID %>')"  size="40"  />

预期输出应自动过滤gridview记录时,应正确保留格式(将gridview标题与gridview项对齐)。列在当前情况下是错误对齐的。

0 个答案:

没有答案