DVWP How to remove duplicate entries in filter dropdown list

By peter.stilgoe









When displaying the filter bar in a data view webpart it will list multiple instances of the same option if the data exists multiple times in your datasource ie. say you have a 100 list items & one of the columns contains a ‘yes’ or ‘no’, it will list them 100 times instead of just a single ‘yes’ / ‘no’ option to apply on your filter.

To remove duplicate filter options, open your dataview webpart in Sharepoint Designer & look for:

Simply remove the ‘[1]‘ from each filter option, now your filter dropdowns will only display unique values, removing the duplicate options.




Share

, ,

About... peter.stilgoe

peter.stilgoeThis author published 482 posts in this site.
Sharepoint, InfoPath, K2, Nintex, Business Process Mapping, Business Intelligence, Automation, ECM, Document Management, Document Imaging, Internet Marketing & Online Business Consultant Email / MSN: pstilgoe@hotmail.com LinkedIn: Pete Stilgoe - Sharepoint Consultant









Share

FacebookTwitterEmailWindows LiveTechnoratiDeliciousDiggStumbleponMyspaceLikedin

9 Comments

  • At 2010.11.26 06:53, Madhavan said:

    Excellent..and very deed time i found your page…save much time….

    [Reply]

    • At 2011.01.10 14:10, Rao said:

      Simply Excellent. ThanQ you so much for you valueble information.

      [Reply]

      • At 2011.04.27 02:45, Jenny said:

        Ok..I cannot found the code in my SPD..anyone can help?

        Table

        Title
        Broadcast Date
        Business Unit
        Broadcast Channel
        Type of Project
        Size
        Revenue
        Cost

        ms-alternating

        [Reply]

        • At 2011.04.27 03:08, Jenny said:

          I cannot find the code..i just find this one in my SPD

          [Reply]





          peter.stilgoe

          peter.stilgoe Reply:

          Not sure why you cant see it, try exporting the webpart & then edit it & see if you can see the code. I presume you have turned on the filter bar in SPD for your DVWP?

          [Reply]





          • At 2011.04.29 02:12, Jenny said:

            Ok.Thanks!!..I’m already found the code.

            But the problem is when I selected filter, the data view webpart is returning different type of value.

            For example in Business Unit column, I have Email and SMS.

            In the filter dropdown list, it have Email and SMS value.But when I selected Email, It don’t return email as the filter value but return SMS.

            Why?

            [Reply]

            • At 2011.04.29 04:06, Aiman said:

              Thanks!Excellent solutions.

              I would like to know if I can combine filter in the DVWP.

              For Example :

              Here’s a sample

              country city size
              usa new york big
              usa boston medium
              usa miami medium
              usa omaha small
              spain madrid big
              spain barcelone medium
              spain majorca small
              spain seville small

              Now i just can filter country or city or size. if i select usa, the
              data wiew will show

              country city size
              usa new york big
              usa boston medium
              usa miami medium
              usa omaha small

              But if i check the City o Size select fields they will show the whole
              list as i’m not able to combine. I’d like to see just the us cities. Or
              select Size=Big (and usa still filterede) and the data view should just
              show new york. By now, if i select Size=Big, it will show Madrid and
              New York

              Some idea?
              Thanks

              [Reply]

              • At 2011.08.02 02:30, Flowerbot said:

                Thank you for this. It works great for regular text fields, but it doesn’t work for user type fields, any ideas? Is there a simple elegant way to get user names to display correctly in a filter option list? Ie, no duplicates, and no rich text? And for the filter to still work?

                [Reply]

                • At 2011.11.08 20:32, raki said:

                  this solution is not working for me. Please suggest any other

                  [Reply]

                  (Required)
                  (Required, will not be published)