Updated Pager Controls with VIEW ALL option.

Post feature requests to this forum and a pre-configured poll will automatically be created for you.
Post Reply
crazyjoe
Commander (CMDR)
Commander (CMDR)
Posts: 172
Joined: Mon Apr 26, 2010 2:20 pm

Updated Pager Controls with VIEW ALL option.

Post by crazyjoe » Mon Oct 24, 2011 10:00 am

I am looking for my paging to have an option that says "View All" after the list of page numbers so a customer could click that and it would show all products in the category. Any ideas?
Crazy Joe Sadloski
Webmaster
Hot Leathers Inc.
http://www.hotleathers.com

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Updated Pager Controls with VIEW ALL option.

Post by david-ebt » Mon Oct 24, 2011 11:34 am

Take a look at how the Orders page in Admin works (\Admin\Orders\Default.aspx). It has a Show All option. You can see in the .cs that it checks to the Show All option is set (a value of 0), then it turns off paging for the grid.

Code: Select all

        int pageSize = AlwaysConvert.ToInt(PageSize.SelectedValue);
        if (pageSize == 0) OrderGrid.AllowPaging = false;
        else
        {
            OrderGrid.AllowPaging = true;
            OrderGrid.PageSize = pageSize;
        }
I hope that points you in the right direction.
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

crazyjoe
Commander (CMDR)
Commander (CMDR)
Posts: 172
Joined: Mon Apr 26, 2010 2:20 pm

Re: Updated Pager Controls with VIEW ALL option.

Post by crazyjoe » Mon Oct 24, 2011 3:16 pm

Thanks for the tip David. Unfortunately there are few similarities that I can see with the coding regarding paging on a my CategoryGridPage2.ascx.cs and the admin/orders/defaul.aspx.cs I am an excellent copy and paste'er but this doesn't look like its as easy as that.
Crazy Joe Sadloski
Webmaster
Hot Leathers Inc.
http://www.hotleathers.com

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Updated Pager Controls with VIEW ALL option.

Post by david-ebt » Mon Oct 24, 2011 5:47 pm

Ah, I misunderstood. Here's a link to another post where someone had the same request but it sounds like they weren't able to get the proposed solution to work.
viewtopic.php?f=44&t=6475&p=67327&hilit=view+all#p67327

So, assuming the above solution doesn't work, I've put together a little hack that seems to work. It is a bit messy, but it seems to work.

First, add this FooterTemplate to the PagerControlsTop and PagerControl (just above the </asp:Repeater> line) in the .ascx page. This add the View All button.

Code: Select all

<FooterTemplate>
    <a class='<%#Eval("TagClass")%>'  href='<%=GetBaseUrl()%>&v=all'>View All</a>
</FooterTemplate>
then add this to the private declarations at the top of the .cs code page. This returns the page URL discovered by the paging controls to be used in the View All footer template.

Code: Select all

private string _BaseUrl = string.Empty;

protected string GetBaseUrl()
{
	return _BaseUrl;
}
Then change the Page_Init function. This looks to see if the user clicked the View All button and sets the current page index to 0 and sets the page size to 10,000 products (just a big number). Change it from:

Code: Select all

string tempSort = Request.QueryString["s"];
to

Code: Select all

string viewAll = Request.QueryString["v"];
if (viewAll == "all")
{
	PagerPanel.Visible = false;
	PagerPanelTop.Visible = false;
	_PageSize = 10000;
	_HiddenPageIndex = 0;
	HiddenPageIndex.Value = "0";
}
string tempSort = Request.QueryString["s"];
Finally, look for this code inside the BindPagingControls function. This change saves the baseUrl determined by the paging control.

Code: Select all

if (PagerPanel.Visible)
{
      PagerControls.DataSource = NavigationHelper.GetPaginationLinks(currentPagerIndex, totalPages, baseUrl);
       PagerControls.DataBind();
}
and change it to:

Code: Select all

_BaseUrl = baseUrl;

if (PagerPanel.Visible)
{
      PagerControls.DataSource = NavigationHelper.GetPaginationLinks(currentPagerIndex, totalPages, baseUrl);
       PagerControls.DataBind();
}
Again, not pretty, but it seems to work. These changes worked in both the CategoryGridPage.ascx and CategoryGridPage2.aspx controls.
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

crazyjoe
Commander (CMDR)
Commander (CMDR)
Posts: 172
Joined: Mon Apr 26, 2010 2:20 pm

Re: Updated Pager Controls with VIEW ALL option.

Post by crazyjoe » Tue Oct 25, 2011 7:35 am

GREAT JOB! Thank you very much David, this is exactly what I needed. THIS IS AWESOME! WORKS PERFECTLY!
Crazy Joe Sadloski
Webmaster
Hot Leathers Inc.
http://www.hotleathers.com

jowanna
Ensign (ENS)
Ensign (ENS)
Posts: 2
Joined: Sun Oct 30, 2011 9:35 am

Re: Updated Pager Controls with VIEW ALL option.

Post by jowanna » Sun Oct 30, 2011 9:53 am

crazyjoe wrote:GREAT JOB! Thank you very much David, this is exactly what I needed. THIS IS AWESOME! WORKS PERFECTLY!
Awesome, I second that! I was wondering about this. Thanks for providing the info :)

ChipWV
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 88
Joined: Tue Feb 03, 2009 12:51 pm

Re: Updated Pager Controls with VIEW ALL option.

Post by ChipWV » Thu Nov 01, 2012 9:31 pm

The only problem with having a "view all" is the load on the database.

crazyjoe
Commander (CMDR)
Commander (CMDR)
Posts: 172
Joined: Mon Apr 26, 2010 2:20 pm

Re: Updated Pager Controls with VIEW ALL option.

Post by crazyjoe » Fri Nov 02, 2012 2:36 pm

Has anybody added this to their SearchPage? I'd like to give my users the option to View All on the their search results page but the code above does not work. It has a problem with the code

Code: Select all

_BaseUrl = baseUrl;
since the bindpaging controls are different on searchpage.ascx.cs compared to Catgrid 2 and 4. Let me know if anyone has any ideas on how to get that to work in the SearchPage.ascx.cs

Thanks!
Crazy Joe Sadloski
Webmaster
Hot Leathers Inc.
http://www.hotleathers.com

Post Reply