2017-04-11 11 views
0

をスクロール途中であるときのdivが下までスクロールされたとき、私はGridViewコントロールを読み込むためにAjaxの機能を呼び出していますし、私のコードは正常に動作しているが、私はdiv要素がで途中ので、スクロールされたときに関数を呼び出したいですユーザーがレコードを取得中に待つ必要がないことを確認します。私はの半分をスクロールするときGetRecords()を呼び出すためにjavascript関数の上で行う必要がありますどのような変更Retriveレコードのdiv要素が

.ASPX HTML

<table class="Grid" cellspacing="0" rules="all" border="1" id="Table1" style="width: 99%; border-collapse: collapse;"> 
      <tr> 
       <th scope="col" style="width: 10%">ID</th> 
       <th scope="col" style="width: 30%;">Title</th> 
       <th scope="col" style="width: 20%;">Theme</th> 
       <th scope="col" style="width: 14%;">Subject</th> 
       <th scope="col" style="width: 14%;">Grade</th> 
      </tr> 
     </table> 

     <div id="dvGrid" style="height: 800px; overflow: auto; width: 100%"> 
      <asp:GridView ID="gridSearchResult" runat="server" AutoGenerateColumns="false" CssClass="Grid" Width="99%" EmptyDataText="No records found!!!"> 
       <Columns> 
        <asp:BoundField DataField="tid" HeaderText="ID" ItemStyle-CssClass="tid" ItemStyle-Width="10%" HeaderStyle-Width="10%" /> 
        <asp:BoundField DataField="title" HeaderText="Title" ItemStyle-CssClass="title" ItemStyle-Width="30%" HeaderStyle-Width="30%" /> 
        <asp:BoundField DataField="theme" HeaderText="Theme" ItemStyle-CssClass="theme" ItemStyle-Width="20%" HeaderStyle-Width="20%" /> 
        <asp:BoundField DataField="subject" HeaderText="Subject" ItemStyle-CssClass="subject" ItemStyle-Width="14%" HeaderStyle-Width="14%" /> 
        <asp:BoundField DataField="grade" HeaderText="Grade" ItemStyle-CssClass="grade" ItemStyle-Width="14%" HeaderStyle-Width="14%" /> 
       </Columns> 
      </asp:GridView> 
     </div> 

Javascriptを

//Load GridView Rows when DIV is scrolled 
      $("#dvGrid").on("scroll", function (e) { 
       var $o = $(e.currentTarget); 
       if ($o[0].scrollHeight - $o.scrollTop() <= $o.outerHeight()) { 

        GetRecords(); 
       } 
      }); 

部門

答えて

0

乗算2の高さは、実質的に容器が二重の高さになりたいです。

$o[0].scrollHeight - $o.scrollTop() <= $o.outerHeight() * 2