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

Forums / General Discussions / Rebind Pager on NewsView Template?

Rebind Pager on NewsView Template?

8 posts, 0 answered
  1. LBrinley
    LBrinley avatar
    59 posts
    Registered:
    29 Dec 2005
    28 Jul 2010
    Link to this post
    I have a custom NewsView template in which I've implemented custom search.  The search results themselves are returned and displayed correctly, since upon search I rebind the repeater DataSource to my custom IList,

    Unfortunately, the pager1 control always maintains the information of the 'default' search, i.e. the search setup via the NewsView control.  For example, if the 'unsearched' original NewsView shows a pager having 3 pages of 10 items per page, any subsequent custom search also shows 3 pages even if only a single item is returned.  I assume this is because although I've rebound the repeater control, the pager1 remains bound to the original datasource of the repeater.

    How can I rebind the pager1 control so that its pages, etc. agree with the rebound repeater's new DataSource?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Jul 2010
    Link to this post
    Hi iVillageIdiot,

    You have to override CreateContentList where you have to set pager1.PageCount and pager datasource. Another option would be to override CreateDataSource method and there return only the items you are looking for, which will return correct paging.

    Sincerely yours,
    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. LBrinley
    LBrinley avatar
    59 posts
    Registered:
    29 Dec 2005
    29 Jul 2010
    Link to this post
    Ivan,

    I tried the CreateDataSource override first, but although the correct (and only the correct) items are returned, the pager still does not reflect the acutal number of items returned.

    I have also attempted the CreateContentLIst override, but see no properties/methods of Telerik.Cms.Web.UI.Pager that would allow me to declare the DataSource and bind it.  The pager1.SetDataSource() method does not get the job done--even in combination with the pager1.DataBind() method.  Please advise or possibly provide a sample?

    Thanks.
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    30 Jul 2010
    Link to this post
    Hi iVillageIdiot,

    Thank you for getting back to us.

    The problem is that the pager maintains the results after the search is performed. Coulf you try using Clear() method for the pager and then calling DataBind.

    However if you put your logic for performing the search in CreateDataSource method and return the result of the query as the return parameter of the method the pager should get reset as this method basically executes before the pager gets its page data.

    Regards,
    Radoslav Georgiev
    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. LBrinley
    LBrinley avatar
    59 posts
    Registered:
    29 Dec 2005
    30 Jul 2010
    Link to this post
    I'll try the Clear and DataBind methods.  As for the CreateDataSouce override, it is not resetting the pager although a custom IList is returned from it.
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    30 Jul 2010
    Link to this post
    Hi iVillageIdiot,

    I am looking forward to a response with the results of the use of above suggestions. It would be best if you clear the pager in CreateDataSource.

    Kind regards,
    Radoslav Georgiev
    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
  7. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    21 Dec 2010
    Link to this post
    Hi Radoslav/iVillageIdiot,

    Was a solution to this problem found? I am having exactly the same problem. The only difference is I am using a SimpleControl rather than a ContentView so there is no overrideable method for CreateDataSource.

    I have a custom data source i.e. a datatable and pageddatasource which I am binding from InitializeControls.

    How do i prevent the pager from maintaining its state?

    Thanks
    higgsy
  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    27 Dec 2010
    Link to this post
    Hello Alastair,

    Please check the following forum post: http://www.sitefinity.com/devnet/forums/sitefinity-3-x/developing-with-sitefinity/searching-and-paging-through-events.aspx

    Greetings,
    Georgi
    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
8 posts, 0 answered