0

I am building a custom list filter webpart farm solution for Sharepoint 2013 and 2016. It is put on the same page as the XsltListViewWebPart to be filtered. I do this by changing the caml query inside XmlDefintion. Filtering work nicely when I click on the confirm button in my custom webpart.

Here is part of my code:

XsltListViewWebPart xsltWp;
protected void Page_Load(object sender, EventArgs e)
{
    //get xsltWp
    //and do other settings
}
potected void buttonConfirm_Click(object sender, EventArgs e)
{
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(xsltWp.XmlDefinition);
    XmlNode queryNode = xmlDoc.DocumentElement.SelectSingleNode("Query");
    //hard code here for example
    queryNode.innerXml = "<Where><Eq><FieldRef Name=\"Title\"/><Value Type=\"Text\">filteringText</Value></Eq></Where>";
    xsltWp.XmlDefinition = xmlDoc.OuterXml;
}

I need to solve these two problems:

  1. Everytime a postback happened (e.g. navigate into a folder), the xml is lost and need to click the confirm button again to see filtering result. How can i maintain the filtering?
    I am currently thinking to do a custom databind for the xsltWp but not sure if it can solve the second problem.

  2. Paging is enabled but when switching to pages other than first page, the filtering doesn't work. Even clicking the confirm button again the list still show all result (same as the result not filtering would have on the same page). How should I do this filtering while having the paging function?
    Same had been asked here long ago but no answer. XsltListViewWebPart Custom Filtering on Query String with paging
    I found that no postback happen when switching page. I have also tried adding things like "Paged=TRUE-p_ID=51-PageFirstRow=31" the Url attribute in the xml View node but nothing changed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.