Page 1 of 1

Updated Pager Controls with VIEW ALL option.

Posted: Mon Oct 24, 2011 10:00 am
by crazyjoe
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?

Re: Updated Pager Controls with VIEW ALL option.

Posted: Mon Oct 24, 2011 11:34 am
by david-ebt
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.

Re: Updated Pager Controls with VIEW ALL option.

Posted: Mon Oct 24, 2011 3:16 pm
by crazyjoe
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.

Re: Updated Pager Controls with VIEW ALL option.

Posted: Mon Oct 24, 2011 5:47 pm
by david-ebt
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.

Re: Updated Pager Controls with VIEW ALL option.

Posted: Tue Oct 25, 2011 7:35 am
by crazyjoe
GREAT JOB! Thank you very much David, this is exactly what I needed. THIS IS AWESOME! WORKS PERFECTLY!

Re: Updated Pager Controls with VIEW ALL option.

Posted: Sun Oct 30, 2011 9:53 am
by jowanna
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 :)

Re: Updated Pager Controls with VIEW ALL option.

Posted: Thu Nov 01, 2012 9:31 pm
by ChipWV
The only problem with having a "view all" is the load on the database.

Re: Updated Pager Controls with VIEW ALL option.

Posted: Fri Nov 02, 2012 2:36 pm
by crazyjoe
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!