locked
HTML form Web Part List Filter use Contains or In instead of Equals RRS feed

  • Question

  • Hello,

    I have an HTML form web part with connections to a SharePoint list for filter purposes. I've used SharePoint designer to have multiple connections from each different <input> to its respective List Column.

    The filter works great, except the filter operator is Equals, is there anyway to modify the xsl or something in order to force the HTML form web part filter to use Contains or In as an operator?

    I've tried manually creating a CAML query to execute when a search button is clicked but that was unsuccessful.

    Thanks,

    Brian H.

    Thursday, July 7, 2016 2:04 PM

Answers

  • Brian, while it is not possible via GUI it can be done via SharePoint Designer. I've implemented similar solution and it works fine with Contains condition.

    The high level overview is below.

    1. Using SPD create new Parameter in the XSLTListViewWebPart, call it some how (e.g. Filter).
    2. Modify the query in the view inside the XSLTListViewWebPart from Equals to Contains and place {Filter} inside <Value> node : ...<Where><Contains><FieldRef Name="Surname"/><Value Type="Text">{Filter}</Value></Contains></Where>...
    3. Now via SPD or GUI you can create web part connection. Please, ensure you choose Send PARAMETER values to, and select Filter parameter.

    Please, let me know if you need further details


    If my suggestion helped you to solve your problem, please don't forget to mark it as Answer

    • Marked as answer by ln1000000 Monday, July 11, 2016 7:00 PM
    Friday, July 8, 2016 11:15 AM

All replies

  • Hi Brian,

    It is not supported to use Contains or In instead of Equals because the operator is provided by the connection.

    For now, the connection only supports Equals operator.

    If you want to use Contains or In operator, then you need to create a custom web part connection which supports Contains or In operator.

    Best Regards,

    Victoria

    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Friday, July 8, 2016 8:12 AM
  • Brian, while it is not possible via GUI it can be done via SharePoint Designer. I've implemented similar solution and it works fine with Contains condition.

    The high level overview is below.

    1. Using SPD create new Parameter in the XSLTListViewWebPart, call it some how (e.g. Filter).
    2. Modify the query in the view inside the XSLTListViewWebPart from Equals to Contains and place {Filter} inside <Value> node : ...<Where><Contains><FieldRef Name="Surname"/><Value Type="Text">{Filter}</Value></Contains></Where>...
    3. Now via SPD or GUI you can create web part connection. Please, ensure you choose Send PARAMETER values to, and select Filter parameter.

    Please, let me know if you need further details


    If my suggestion helped you to solve your problem, please don't forget to mark it as Answer

    • Marked as answer by ln1000000 Monday, July 11, 2016 7:00 PM
    Friday, July 8, 2016 11:15 AM
  • Thanks, this is the response I was looking for. I'll let you know how things go. Just confirming I'm using an HTML webpart and not a Content Editor (I've tried that already, and while the Contains works, the filter values are lost on postback.)

    Edit: Works like a charm, even with multiple <inputs> and an Or Group. Thank you so much.

    Brian H.

    • Edited by ln1000000 Monday, July 11, 2016 7:01 PM
    Monday, July 11, 2016 6:06 PM
  • Hi Victoria,

    This was my first iteration; I used a Content Editor Web part with a custom CAML query using Contains as the operator. Unfortunately, while the filter was correct, the filter values were lost on postback, so clients that attempted to sort or page the list after the filter action had finished, would wind up with a blank list.

    Thanks,

    Brian H.

    Monday, July 11, 2016 6:09 PM