2011-03-01 3 views
0

현재 updatemode 조건부를 가진 UpdatePanel을 사용하여 검색 기능을 구축 중입니다. 이 updatepanel에 대한 트리거는 내 searchPhrase TextBox입니다. TextChanged가 실행되면 내 패널이 업데이트되고 올바른 검색 결과가 표시됩니다. 그러나 내 searchresults 함께 작동하는 페이징 기능을 구현하는 방법에 대한 단서가 있어요. 부분 페이지 업데이트에 페이지 링크가 표시되기를 원하며 호출기가 내 searchResults를 업데이트하기를 원합니다 (한 페이지에 3 개의 결과 만 표시하려는 경우). 어떻게 올바르게 설정합니까? Ajax 검색 기반 웹 컨트롤에서 페이징 기능성 구현

은 (ASCX)




내 코드입니다 = "서버"

<div class="filterBox"> 
     <asp:PlaceHolder ID="filterOnePlaceholder" 

RUNAT>

<div class="filterBox"> 
     <asp:PlaceHolder ID="filterTwoPlaceholder" 

RUNAT = "서버" > PaginaMarker DIV :,745 1,515,

<script type="text/javascript"> 
     function ClientCallbackFunction(args) 
     { 

     } 
    </script> 


    <asp:Button ID="btnBackwards" Text="Vorige" 

의 OnClick = "MyServerCall (this.value)"/>

<asp:DropDownList ID="DropDownListChoice" runat="server" 

의 onChange = "MyServerCall (this.value)"> 선택 초이스 선택 선택 사항 4

(CS)

//의 SearchResult를 저장하는 데 필요한 목록 validSearchResults = 새 목록();

private List<string> listOneSelectedItems = new 

List(); 비공개 목록 listTwoSelectedItems = new List();

private string currentCategoryPath = string.Empty; 

    private string _callbackArgs; 


    /// <summary> 
    /// Raises the <see cref="E:System.Web.UI.Control.Init"/> 

이벤트. /// /// 이벤트 데이터가 들어있는 객체 . protected override void OnInit (EventArgs e) { base.OnInit (e);

 this.UpdateSelectedItemLists(); 
     this.currentCategoryPath = Sitecore.Context.Item.Paths.FullPath; 

     this.searchPhrase.TextChanged += new 

EventHandler (searchPhrase_TextChanged);

 this.filterOneCbl.SelectedIndexChanged 

= new EventHandler (filterOneCbl_SelectedIndexChanged); this.filterTwoCbl.SelectedIndexChanged = 새 EventHandler (filterTwoCbl_SelectedIndexChanged); this.ProductRepeater.ItemDataBound + = 새 RepeaterItemEventHandler (ProductRepeater_ItemDataBound); } 인덱스 this.UpdateSelectedItemLists에서 새로운 아이템의

private void UpdateScreen() 
    { 
     // update the list of selectedItems for use with the 

선택(); this.GetSearchResults(); 인덱스 this.UpdateSelectedItemLists에서 새로운 항목이

 ProductRepeater.DataSource = validSearchResults; 
     ProductRepeater.DataBind(); 

     ProductenUpdate.Update(); 
    } 

    void btnSearch_Click(object sender, EventArgs e) 
    { 
     // update the list of selectedItems for use with the 

선택(); this.GetSearchResults();

 ProductRepeater.DataSource = validSearchResults; 
     ProductRepeater.DataBind(); 

     ProductenUpdate.Update(); 
    } 

    private void ProductRepeater_ItemDataBound(object 

송신자 RepeaterItemEventArgs E) { 있는 DataItem = 아이템 (아이템) e.Item.DataItem;

 // if there is a dataItem 
     if (dataItem != null) 
     { 
      if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType 

== ListItemType.Item) { Sitecore.Web.UI.WebControls.Text Titel = (Sitecore.Web.UI.WebControls.Text) e.Item.FindControl ("Titel"); Sitecore.Web.UI.WebControls.Text Auteur = (Sitecore.Web.UI.WebControls.Text) e.Item.FindControl ("Auteur"); Sitecore.Web.UI.WebControls.Text 소개 = (Sitecore.Web.UI.WebControls.Text) e.Item.FindControl ("소개"); Sitecore.Web.UI.WebControls.Image Thumb = (Sitecore.Web.UI.WebControls.Image) e.Item.FindControl ("Thumb");

   if (Thumb != null) 
       { 
        Thumb.Item = dataItem; 
       } 

       if (Titel != null) 
       { 
        Titel.Item = dataItem; 
       } 

       if (Auteur != null) 
       { 
        Auteur.Item = dataItem; 
       } 

       if (Intro != null) 
       { 
        Intro.Item = dataItem; 
       } 
      } 
     }    
    } 

    /// <summary> 
    /// Handles the TextChanged event of the searchPhrase control. 
    /// </summary> 
    /// <param name="sender">The source of the event.</param> 
    /// <param name="e">The <see cref="System.EventArgs"/> instance 

이벤트 데이터가 들어 있습니다. private void searchPhrase_TextChanged (개체 보낸 사람, EventArgs e) { this.UpdateScreen(); }

/// <summary> 
    /// Handles the SelectedIndexChanged event of the 

filterTwoCbl 컨트롤. /// /// 이벤트 소스. /// 이벤트 데이터가 들어있는 인스턴스 . private void filterTwoCbl_SelectedIndexChanged (개체 보낸 사람, 이벤트 아규먼트) { this.UpdateScreen(); }

/// <summary> 
    /// Handles the SelectedIndexChanged event of the 

filterOneCbl 컨트롤. /// /// 이벤트 소스. /// 이벤트 데이터가 들어있는 인스턴스 . private void filterOneCbl_SelectedIndexChanged (개체 보낸 사람, 이벤트 아규먼트) { this.UpdateScreen(); }

/// <summary> 
    /// Updates the selected item lists. 
    /// </summary> 
    private void UpdateSelectedItemLists() 
    { 
     foreach (ListItem thisItem in filterOneCbl.Items) 
     { 
      if (thisItem.Selected) 
      { 
       if (!listOneSelectedItems.Contains(thisItem.Value.ToUpper())) 
       { 
        listOneSelectedItems.Add(thisItem.Value.ToUpper()); 
       } 
      } 
     } 

     foreach (ListItem thisItem in filterTwoCbl.Items) 
     { 
      if (thisItem.Selected) 
      { 
       if (!listTwoSelectedItems.Contains(thisItem.Value.ToUpper())) 
       { 
        listTwoSelectedItems.Add(thisItem.Value.ToUpper()); 
       } 
      } 
     } 
    } 

    /// <summary> 
    /// Gets the search results. 
    /// </summary> 
    private void GetSearchResults() 
    { 
     SearchResultRetreiver retriever = new 

SearchResultRetreiver ("productenSearch"); IndexSearcher searcher = null;

 Hits mySearchResults = retriever.GetSearchResults(searchPhrase.Text.Trim(), 

ref searcher);

 if (mySearchResults != null) 
     { 
      for (int i = 0; i < mySearchResults.Length(); i++) 
      { 
       Item newItem = Sitecore.Data.Indexing.Index.GetItem(mySearchResults.Doc(i), 

Sitecore.Context.Database); string itemTitel = SitecoreHelper.ShowItemTitel (newItem); bool addItem = true; if (itemTitel.StartsWith ("$")) addItem = false; if (itemTitel.StartsWith ("_")) addItem = false;

   if (addItem) 
       { 
        this.validSearchResults.Add(newItem); 
       } 
      } 
     } 
    } 

    private void FilterSearchResults() 
    { 



    } 

    /// <summary> 
    /// Handles the Load event of the Page control. 
    /// </summary> 
    /// <param name="sender">The source of the event.</param> 
    /// <param name="e">The <see cref="System.EventArgs"/> instance 

이벤트 데이터가 들어 있습니다. 보호 된 무효 Page_Load (개체 보낸 사람, EventArgs 전자) { 항목 contextItem = Sitecore.Context.Item; 항목 subwebsiteItem = contextItem.Axes.GetAncestors(). (c => c.Axes.Level == 4) .FirstOrDefault();

 Sitecore.Data.Fields.CheckboxField 

filterOneSelected = subwebsiteItem.Fields [ "Filter1Actief"]; Sitecore.Data.Fields.CheckboxField filterTwoSelected = subwebsiteItem.Fields [ "Filter2Actief"];

 if (filterOneSelected.Checked) 
     { 
      TitelTwo.Item = subwebsiteItem; 
     } 

     if (filterTwoSelected.Checked) 
     { 
      TitelOne.Item = subwebsiteItem; 
     } 

     if (!Page.IsPostBack) 
     { 
      string callbackRef = Page.ClientScript.GetCallbackEventReference(this, 

"args", "ClientCallbackFunction", "");

  string callbackScript = "function MyServerCall(args)" + 
       "{" + callbackRef + "}"; 

      Page.ClientScript.RegisterClientScriptBlock(this.GetType(), 

"MyServerCall", callbackScript, true);

  filterOnePlaceholder.Visible = false; 
      filterTwoPlaceholder.Visible = false; 

      if (subwebsiteItem != null) 
      {     
       if (filterOneSelected.Checked) 
       { 
        filterOnePlaceholder.Visible = true; 


        Item filterOneLocation = 

Sitecore.Context.Database.GetItem (subwebsiteItem.Paths.FullPath + "/ 필터/필터 1"); 목록 filterOneList = 새 목록();

    filterOneList = filterOneLocation.GetChildren().Where(c 

=> c.TemplateName.ToLower() == "filter"). ToList();

    foreach (Item filterItem in filterOneList) 
        { 
         ListItem thisItem = new 

을 ListItem (. filterItem [ "나암"] filterItem.ID.ToGuid의 toString()()); this.filterOneCbl.Items.Add (thisItem); }}

   if (filterTwoSelected.Checked) 
       { 
        filterTwoPlaceholder.Visible = true; 

        Item filterTwoLocation = 

Sitecore.Context.Database.GetItem ( + "/ 필터/필터 2"subwebsiteItem.Paths.FullPath); 목록 filterTwoList = 새 목록();

    filterTwoList = filterTwoLocation.GetChildren().Where(c 

=> c.TemplateName.ToLower() == "필터").ToList();

    foreach (Item filterItem in filterTwoList) 
        { 
         ListItem thisItem = new 

을 ListItem (. filterItem [ "나암"] filterItem.ID.ToGuid의 toString()()); this.filterTwoCbl.Items.Add (thisItem); }} }}}

#region ICallbackEventHandler Members 

    /// <summary> 
    /// Returns the results of a callback event that targets a control. 
    /// </summary> 
    /// <returns>The result of the callback.</returns> 
    public string GetCallbackResult() 
    { 
     return this._callbackArgs; 
    } 

    /// <summary> 
    /// Processes a callback event that targets a control. 
    /// </summary> 
    /// <param name="eventArgument">A string that 

이벤트 핸들러 를 전달하는 이벤트 인수를 나타낸다. 공개 무효 RaiseCallbackEvent (문자열 eventArgument) { this._callbackArgs = eventArgument; }

내 솔루션에 대한 호출기 작동 방법을 살펴보십시오.

답변

0

저는 GetList() 메서드와 서로 후에 호출 된 Update() 메서드를 도입하여이 문제를 해결했습니다. de GetList() metthod에서 항목의 총량을 설정하고 Update 메서드에서 호출기를 만들 수있는 다른 메서드를 호출했습니다. 이것이 내 질문을 해결했습니다.