2010-01-29 4 views
0

quelques problèmes avec une solution qui fonctionne apparemment:Scrolling Pagination sur Gridview via JQuery - Aide

<script type="text/javascript" > 
     //following code utilizes jQuery 1.2.6 
     var prev = 0; 
     $(document).ready(

     //DIV showing the message "Loading..." is hidden initially 
     //The message will be shown when records are fetched with AJAX 
     //when user has scrolled to the bottom of the DIV scrollbar 
     function() { 
      $(".divProgress").hide(); 

      $(".divLeft").scroll(

     function() { 
     //triggering point is when the difference of the heights of the TABLE 
     //and DIV match the DIV's scrollTop value 
     if ($('<%=grdPersonResults.ClientID %>').height() - this.scrollTop == $(this).height()) { 
     //progress bar   
     $(".divProgress").ajaxStart(function() { 
      $(this).show(); 
     }); 
     $(".divProgress").ajaxStop(function() { 
      $(this).hide(); 
     }); 

     //get last Order Id to track next fetch 
     var OrderIdLast = $('<%=grdPersonResults.ClientID %> tr:last').children("td:first").html(); 

     //get last table row in order to append the new result set increment 
     var trLast = $('<%=grdPersonResults.ClientID %> tr:last'); 
     if (parseInt(OrderIdLast, 10) > parseInt(prev, 10)) { 
      prev = OrderIdLast; 
      //make a async call to fetch the incremental results  
      $.post("AsyncHandler.ashx?lastOrderId=" + OrderIdLast, function(data) { 
       if (data != null) { 
        //append new result set to last row 
        trLast.after(data); 
       } 
      }); 
     } 
    } 
}); 
}); 
    </script> 

Mon Gridview est assez simple:

<div class="divLeft"> 
        <asp:GridView ID="grdPersonResults" AutoGenerateColumns="False" runat="server" 
         CellPadding="2" Width="100%" ForeColor="#333333" GridLines="None" BorderWidth="1px" BorderStyle="Solid" 
         BorderColor="Black" AllowSorting="True" CssClass="box-table-a"> 
         <Columns> 
          <asp:HyperLinkField HeaderText="Name" SortExpression="NAME" DataNavigateUrlFields="EMPLOYEE_ID, COMPANY_ID, RNUM" 
           DataNavigateUrlFormatString="~/Admin/FinalizeEdit.aspx?id={0}&cid={1}&rnum={2}&action=EDIT" DataTextField="NAME" /> 
          <asp:BoundField DataField="DESCRIPTION" HeaderText="Company" SortExpression="DESCRIPTION" /> 
          <asp:BoundField DataField="SOURCE_ID" HeaderText="Source" SortExpression="SOURCE_ID" /> 
         </Columns> 
         <FooterStyle CssClass="box-table-a" /> 
         <RowStyle CssClass="box-table-a" /> 
         <EditRowStyle CssClass="box-table-a" /> 
         <SelectedRowStyle CssClass="box-table-a" /> 
         <PagerStyle CssClass="box-table-a" /> 
         <HeaderStyle CssClass="box-table-a" /> 
         <AlternatingRowStyle CssClass="box-table-a" /> 
        </asp:GridView> 
       </div> 
       <div class="divProgress"> 
        Loading.... 
       </div> 

Il ne semble pas avoir jamais frappé ma AsyncHandler, je ne sais pas si mes sélecteurs sont erronés puisque j'utilise une page Master dans ASP.net, mais il semble que je ramasse les éléments.

+0

Je commenté le: si (parseInt (OrderIdLast, 10)> parseInt (prev, 10)) { } car il ne concerne pas encore. Ne fonctionne toujours pas. – jlrolin

+0

Je l'ai réduit à: if ($ ('<% = grdPersonResults.ClientID%>'). Height() - this.scrollTop == $ (this) .height()) { – jlrolin

Répondre

0

changement

if ($ ('<% = grdPersonResults.ClientID%>') Hauteur() -. This.scrollTop == $ (this) .height()) {

à

si (. $ ("#") grdPersonResults hauteur() - this.scrollTop < = $ (this) .height() - 2) {