ASP.Net ASPXGridView中的无限滚动(无限滚动)使用jQuery AJAX

时间:2014-01-14 10:27:21

标签: c# javascript jquery asp.net ajax

我想知道有没有办法在ASPXGridview上实现无休止的滚动。我见过这样的事情(http://demos.devexpress.com/aspxgridviewdemos/PagingAndScrolling/EndlessPaging.aspx),但这不起作用,因为我有一个旧版本的DevExpress。

我的网格包含大量数据,因此我不希望它一次性加载。

这可以使用JQuery完成吗?

这是我填充结果网格的代码:

    public List<main_screenHelper> GetDedicatedRouteList(string SwitchCd, int AccId, int BndId, int CarrId, int SttId, int StatusId, int Req_id)
    {
        SqlConnection con = ConnectionFactory.GetDedicatedRoutesConnection();
        SqlCommand cmd = new SqlCommand("GetDedicatedRoutesList", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@SwitchCd", SwitchCd);
        cmd.Parameters.AddWithValue("@AccId", AccId);
        cmd.Parameters.AddWithValue("@BndId", BndId);
        cmd.Parameters.AddWithValue("@CarrId", CarrId);
        cmd.Parameters.AddWithValue("@SttId", SttId);
        cmd.Parameters.AddWithValue("@StatusId", StatusId);
        cmd.Parameters.AddWithValue("@Req_id", Req_id);
        List<main_screenHelper> dedicatedRoutList = new List<main_screenHelper>();
        try
        {
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                main_screenHelper drList = new main_screenHelper();
                drList.dr_id = Int32.Parse(dr["dr_id"].ToString());
                drList.switch_code = (dr["switch_code"].ToString());
                drList.cus_company_name = (dr["cus_company_name"].ToString());
                drList.carrier = (dr["Carrier"].ToString());
                drList.dr_percentage = Int32.Parse(dr["dr_percentage"].ToString());
                drList.dr_overflow = (dr["dr_overflow"].ToString());
                drList.bnd_name = (dr["bnd_name"].ToString());
                drList.RoutingCase = (dr["RoutingCase"].ToString());
                drList.peak = Convert.ToBoolean(dr["peak"]);
                drList.off_peak = Convert.ToBoolean(dr["off_peak"]);
                drList.weekend = Convert.ToBoolean(dr["weekend"]);
                drList.active_date = Convert.ToDateTime(dr["active_date"]);
                drList.stt_name = (dr["stt_name"].ToString());
                drList.stt_display_order = Int32.Parse(dr["stt_display_order"].ToString());
                drList.opportunity = Convert.ToBoolean(dr["opportunity"]);
                drList.Lock = Convert.ToBoolean(dr["lock"]);
                drList.comments = (dr["comments"].ToString());
                drList.lcr_name = (dr["lcr_name"].ToString());
                dedicatedRoutList.Add(drList);
            }
        }
        finally
        {
            con.Close();
            con = null;
            cmd = null;
        }
        return dedicatedRoutList;
    }
}

这是我的网格ASP代码:

<dxwgv:ASPxGridView ID="dgrdResults" runat="server" AutoGenerateColumns="False" 
                DataSourceID="DedicatedRouteDataSource" Width="100%" 
                onhtmlrowcreated="dgrdResults_HtmlRowCreated">
                <Columns>
                    <dxwgv:GridViewDataTextColumn Caption="Switch" FieldName="switch_code" 
                        VisibleIndex="0" Width="30px">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="LCR" FieldName="lcr_name" 
                        VisibleIndex="1">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Customer" FieldName="cus_company_name" 
                        VisibleIndex="2" Width="150px">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Vendor" FieldName="carrier" 
                        VisibleIndex="3">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Ratio" 
                        VisibleIndex="4">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Overflow" 
                        VisibleIndex="5">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Destination" FieldName="bnd_name" 
                        VisibleIndex="6">                                                  
                    <DataItemTemplate>
                        <dxe:ASPxHyperLink ID="DestinationLink" runat="server" Text='<%#Eval("bnd_name") %>' ClientInstanceName="DestinationLink" Font-Size="11px">
                        </dxe:ASPxHyperLink>                                         
                    </DataItemTemplate>                      
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Peak" FieldName="peak" 
                        VisibleIndex="7">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="O/Peak" FieldName="off_peak" 
                        VisibleIndex="8">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="W/End" FieldName="weekend" 
                        VisibleIndex="9">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Created" FieldName="active_date" 
                        VisibleIndex="10">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Status" FieldName="stt_display_order" 
                        VisibleIndex="11">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Special" VisibleIndex="12">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Comments" FieldName="comments" 
                        VisibleIndex="13">
                    </dxwgv:GridViewDataTextColumn>
                    <dxwgv:GridViewDataTextColumn Caption="Edit" VisibleIndex="14">
                    </dxwgv:GridViewDataTextColumn>
                </Columns>                                             
            </dxwgv:ASPxGridView>

1 个答案:

答案 0 :(得分:1)

我没有完整的答案,但希望能把你带到正确的方向。

我认为您可以通过将DevExpress GridView与jQuery结合使用来模仿无限滚动的行为,但这需要一些努力。 您可以使用GridView定义一个可滚动的div,让jQuery检测您是否在底部附近滚动。 看到: Check if a user has scrolled to the bottom

如果jQuery事件触发,您可以在ASPxGridView上执行自定义回调,请选择几个额外的行并将它们绑定到您的网格。

升级DevExpress许可证或使用默认分页可能更容易:)