Filter Data View via Drop Down Menu

…this post was published on 2011 June 22.

The example started from a post on Sharepoint Forum.​

So, first task it’s to create an .aspx file, in which I attached a list data view. This zone can be a data web view as well.
I populated the view it with minimal number of column just for understanding the message.

Attached to this view, I inserted a parameter as you see in  the picture bellow:

On same view I used filter on from Ribbon menu, to attach a filtering option

After that i populated a droptdown list with some Category type items ( see category column in right zone )  and also an input buttom with an javascript action to onclick() event ( onclick=”act()”) , the example is finished, ready to read it.
For the page, click here; the code included in that page is:
   – for the dropdown list:
        <select name=”Select1″ id=”lista”>
          <option >Coding</option>
          <option>Hyperlink</option>
          <option>Sharepoint</option>
        </select>
    – for button:
         <input type=”button” VALUE=”Filter list in right side” OnClick=”act()” style=”width: 133px”/>
   – for script:
        <script type=”text/javascript”>
          function act()    {
            var element=document.getElementById(‘lista’);
            alert(“You have selected: “+element.options[element.selectedIndex].text);
            address=’http://www.romeodonca.ro/sitepages/examples/Filter_Data_List_via_Drop_Down_Menu.aspx?filter=’+element.options[element.selectedIndex].text;
            alert(“The new refresh page URL address is:\r”+ address);
            window.location.href=address;
          }
        </script>
This entry was posted in Uncategorized. Bookmark the permalink.