locked
Having trouble filtering data view inserted on DispForm.aspx by field value already on the page. RRS feed

  • Question

  • I have a DispForm.aspx page showing, of course, the names and values of fields of an item within a custom list that I have created.

    I have inserted a dataview of another custom list onto this page.  Of course, when doing so, SharePoint Designer allows you to create a filter for this view.

    I would like to filter this dataview using a value of a field of an item of the FIRST custom list (a value already shown on this page).

    I mistakenly thought creating a data view parameter of "Form" source was the solution, but it is not.

    Is there a way I can capture data appearing on the page (from the original DispForm) and use this value as a filter?

    Any assistance would be most helpful.
    Monday, March 8, 2010 3:38 PM

Answers

  • You can use web part connections.

    Selecting a value in the other custom list will then filter the data view web part to show only items that match that value.
    FAQ sites: (SP 2010) http://wssv4faq.mindsharp.com; (v3) http://wssv3faq.mindsharp.com and (WSS 2.0) http://wssv2faq.mindsharp.com
    Complete Book Lists (incl. foreign language) on each site.
    • Marked as answer by TomK21 Monday, March 8, 2010 4:25 PM
    Monday, March 8, 2010 3:47 PM
  • Amazingly easy.  Thank you Mike!

    For those in a similar situation (and not familiar with web part connections, like myself) here is what I did:

    - On the data view Common Tasks menu, select 'Web Part Connections' (leave 'Filter' alone! clear it out if you've attempted a filter)
    - select 'Get Filter Values From' in the drop-down list from the Connections Wizard that pops-up; click 'Next'
    - make sure 'Connect to a Web Part on this page' is selected; click 'Next'
    - target web part should be your current, original custom List; target action: 'Send Row of Data To'; click 'Next'
    - in the right column (Inputs to <source web part>), scroll to find the field name on the dataview that contains the data you want to filter against; in the left column, select from the drop-down the name of the field in your original custom list whose value will be providing the filter for the dataview; click 'Next'
    - select, again, the field from the original custom list that will be providing the filter value; click 'Next'
    - click Finish

    voila!

    Is there anyway to remove the hyperlink created? Since it's on a DispForm, the value will never change and there will be no reason to click on this link ... best I could do is add a style attribute to the anchor tag setting text-decoration to 'none' and changing text color to make it not look like a link ...

    Thank you again, Mike, for a simple, elegant solution!
    • Marked as answer by TomK21 Monday, March 8, 2010 4:26 PM
    Monday, March 8, 2010 4:25 PM

All replies

  • You can use web part connections.

    Selecting a value in the other custom list will then filter the data view web part to show only items that match that value.
    FAQ sites: (SP 2010) http://wssv4faq.mindsharp.com; (v3) http://wssv3faq.mindsharp.com and (WSS 2.0) http://wssv2faq.mindsharp.com
    Complete Book Lists (incl. foreign language) on each site.
    • Marked as answer by TomK21 Monday, March 8, 2010 4:25 PM
    Monday, March 8, 2010 3:47 PM
  • Amazingly easy.  Thank you Mike!

    For those in a similar situation (and not familiar with web part connections, like myself) here is what I did:

    - On the data view Common Tasks menu, select 'Web Part Connections' (leave 'Filter' alone! clear it out if you've attempted a filter)
    - select 'Get Filter Values From' in the drop-down list from the Connections Wizard that pops-up; click 'Next'
    - make sure 'Connect to a Web Part on this page' is selected; click 'Next'
    - target web part should be your current, original custom List; target action: 'Send Row of Data To'; click 'Next'
    - in the right column (Inputs to <source web part>), scroll to find the field name on the dataview that contains the data you want to filter against; in the left column, select from the drop-down the name of the field in your original custom list whose value will be providing the filter for the dataview; click 'Next'
    - select, again, the field from the original custom list that will be providing the filter value; click 'Next'
    - click Finish

    voila!

    Is there anyway to remove the hyperlink created? Since it's on a DispForm, the value will never change and there will be no reason to click on this link ... best I could do is add a style attribute to the anchor tag setting text-decoration to 'none' and changing text color to make it not look like a link ...

    Thank you again, Mike, for a simple, elegant solution!
    • Marked as answer by TomK21 Monday, March 8, 2010 4:26 PM
    Monday, March 8, 2010 4:25 PM
  • Thanks for this solution - Great for SharePoint Designer newbs like myself. One important thing that I had to figure out though, was that you have to have to first hide the default ListFormWebPart and re-add it as a custom list form. Otherwise, the webpartconnection feature doesn't work. Steps:

    Select the default list web part (WebPartPages: ListFormWebPart)
    Right-click, select Web Part Properties
    Expand Layout, select Hidden, OK
    Insert > SharePoint Controls > Custom List Form
    Select the list you're editing, type of form: Display item form

    Now you can insert a data view of your other list and follow Mike's steps.

    Thursday, July 8, 2010 5:10 PM
  • I'm struggling!

    I've got a custom list called "Company" with names Ford, Chevy, Toyota. 

    I've got a custom list called "cars" with titles Camry, Volt, Tundra, Taurus, F150.  This list has a lookup column called "Company" (from the list "company")

    on the list Company - i've modified dispform.aspx to include a dataview webpart of "Cars"  (I want to show a filtered list of "Cars" that are associated to the dispform ID's Company.

    In following this sequence - do I first select the Dispform webpart, or the inserted dataview webpart for the Connection?

    (Selecting the dispform webpart and choosing webpart connection reports the error: "The Company Web Part does not support connections")

    (Selecting the dataview Web Part and choosing web part connections allows me to the dialog - but does not allow the dispform webpart as a source for the filter..)

    (no joy) - thoughts?

    Thursday, December 2, 2010 4:22 AM