+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Extending the ImageGallery Control

Extending the ImageGallery Control

6 posts, 0 answered
  1. Michael
    Michael avatar
    35 posts
    Registered:
    04 Nov 2010
    16 Dec 2010
    Link to this post
    How do I pass the repeater user control values such as the current page index, total items, etc?

    Currently, I have a class like this:

    namespace Telerik.Libraries.WebControls
    {
        public class GSNImageGallery : ImageGallery
        {
            protected override void CreateChildControls()
            {
                if (this.ItemsPerPage <= 10)
                    this.ItemsPerPage = 12;
                
                this.PageKey = "Page";
                this.ItemListTemplatePath = "~/Sitefinity/ControlTemplates/Libraries/GSNImageGallery.ascx";
                base.CreateChildControls();
            }
        }
    }

    How do I pass to the GSNImageGallery.ascx control the aforementioned values? I need those for paging.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Dec 2010
    Link to this post
    Hi Michael,

    You can add the control - ImageGallery dynamically or declaratively on a page.  ItemsPerPage , PageKey  are public properties of ImageGallery control. You can use session or QueryString keys in case you want to make some interaction between the controls.
     
    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Michael
    Michael avatar
    35 posts
    Registered:
    04 Nov 2010
    16 Dec 2010
    Link to this post
    OK, but how do I access the properties that tell me 1) how many items (total, not total per page) are available and 2) the current page index? I need to know these values for paging purposes.

    Actually, if I could just know the total items in the data source (not the total per page), I can figure out the rest.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Dec 2010
    Link to this post
    Hi Michael,

    In your custom class override CreateDataSource which will return you the items in your datasource. Then you can send them as a cookie, session or Query String and read the value by another control.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Michael
    Michael avatar
    35 posts
    Registered:
    04 Nov 2010
    17 Dec 2010
    Link to this post
    I'm afraid that did not work. CreateDataSource() returns the items per page, not all of the items. I need the total count in order to properly provide paging.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Dec 2010
    Link to this post
    Hi Michael,


    Override CreateChildControls as shown below and get a list of all items.

    protected override void CreateChildControls()
        {
            base.CreateChildControls();
            ContentFilterBuilder filterBuilder = new ContentFilterBuilder(this);
            if (filterBuilder.IsFilterValid)
            {
                var list = this.manager.GetContent(0, 0, this.SortExpression,
                                            filterBuilder.ParseTagFilter(), ContentStatus.Published, null,
                                            filterBuilder.ParseParentsFilter(), filterBuilder.ParseMetaFieldsFilter());
            }
        }


    By default the datasource is created depending on the pager due to performance optimizations, so if you have 50 pages we load only the items that are displayed by the current page - say 10 items.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
6 posts, 0 answered