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

Forums / Developing with Sitefinity / Searching and Paging through events

Searching and Paging through events

2 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    17 Dec 2010
    Link to this post
    Hi,

    I'm using the EventsView control. I have added a dropdownlist with a list of states/counties, and a submit button to the control so that the results can be filtered on state.

    The search itself works using the ContentFilterBuilder method, see below:

        protected override ContentFilterBuilder GetFilterBuilder() {
     
            ContentFilterBuilder filterBuilder = base.GetFilterBuilder();
            MetaSearchInfo filter = new MetaSearchInfo();
     
    //filter results if the dropdown list of states has changed
           if (!string.IsNullOrEmpty(this.oCountyDropDownList.SelectedValue)) {
     
                filter = new MetaSearchInfo(MetaValueTypes.ShortText, "State", this.oCountyDropDownList.SelectedValue, SearchCondition.Like, JoinType.And);
                filterBuilder.ClearFilter();
                filterBuilder.AddFilter(filter);
     
    }
     
            return filterBuilder;
     
        }
     
        protected override IList CreateDataSource() {
     
            //re-create the search results based on the category and town
            ContentFilterBuilder filterBuilder = this.GetFilterBuilder();
            if (filterBuilder.IsFilterValid) {
     
                return this.Manager.GetContent(base.GetContentStartIndex(), base.GetPageSize(), base.SortExpression,
                                          filterBuilder.ParseTagFilter(), ContentStatus.Published, null,
                                          filterBuilder.ParseParentsFilter(), filterBuilder.ParseMetaFieldsFilter());
     
                base.RecreateChildControls();
     
            }
     
            return base.CreateDataSource();
        }

    There are three problems:

    1) this.oCountyDropDownList.SelectedValue is always empty. The dropdownlist is bound using an XML Data source. It is bound in the onprerender, which according to trace is executed AFTER the getfilterbuilder method.

    2) The viewstate of the dropdownlist is never maintained. 

    3) I believe the base.GetContentStartIndex() is stored in the viewstate somewhere. If I get the pager to work using a little hack, lets say I am on page 3 of the results. If I then re-submit the form by selecting a different state from the dropdown list, the pager remains on page 3.

    Basically, the control is not functioning like a normal usercontrol functions whatsoever - three days I've been trying to get this to work and am somewhat frustrated with trying to get what should be the most simple of functions to work.

    Please help.

    Regards,
    higgsy
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    27 Dec 2010
    Link to this post
    Hi higgsy,

    1) this.oCountyDropDownList.SelectedValue is always empty. The dropdownlist is bound using an XML Data source. It is bound in the onprerender, which according to trace is executed AFTER the getfilterbuilder method.

    2) The viewstate of the dropdownlist is never maintained. 


    How do you store the controls properties in the viewstate exactly? The dropdown list control is a composite control, which has other controls (list items), that said it cannot be stored in a viewstate automatically. You should for example store all items in a string, separated with a comma, and finally put that string into the viewstate. When you read the view state, you should bind the dropdown again from the list of saved values. 

    3) I believe the base.GetContentStartIndex() is stored in the viewstate somewhere. If I get the pager to work using a little hack, lets say I am on page 3 of the results. If I then re-submit the form by selecting a different state from the dropdown list, the pager remains on page 3.

    You are right. It comes from the CurrentPage:
    protected int CurrentPage
           {
               get
               {
                   int currentPage = 1;
                   object obj = ViewState["CurrentPage"];
                   if (obj != null)
                   {
                       int.TryParse(obj.ToString(), out currentPage);
                   }
                   return currentPage;
               }
               set
               {
                   if (value < 1)
                       throw new ArgumentOutOfRangeException("value", String.Format(Messages.MustBePositive, "CurrentPage"));
                   ViewState["CurrentPage"] = value;
               }
           }

    You can manipulate the CurrentPage from the viewstate by all means.

    I hope this helps, and sorry for the delayed reply.

    Kind regards,
    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
2 posts, 0 answered