I'm on SP2010, managed by my company so unfortunately no access to server and can't add additional web parts.

I previously had the need to build an A to Z filter in a library. I have used a Jscript on the top web form to show the A to Z selection and filter a bottom list form depending on the letter I click on the web form.

I have a bug: let's say that I click A, the list view is filtered showing only the folders starting with A. Now if I enter in one of this folders, unfortunately the filter remains applied so I can't see any file/folders contained in this folder. I'd like a way to undo the Jscript filter once I enter in one of the folders in the list view. Is that possible adding any code to the following script? On the list view of course I am not allowed to add script as this functionality is only allowed on the web form.

This is the Jscript I have used:

<script type="text/javascript">
   function qs(paramName) {
   var args = document.location.search.substring(1).split("&");
   for(j = 0; j < args.length; j++) {
   nameValues = args[j].split("=");
   if(nameValues[0] == paramName) return nameValues[1];
   return null;

    var filterField = "FL";
    var filterValuesDelimiter = " : ";
    var filterValues = new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
    var selectedValueStyle = "font-weight: bold;";
    var filterDivStyle = "margin: 5px;";
    var filterLinks = new Array();
    for (var i = 0; i < filterValues.length; i++) {
            filterLinks.push('<a ' + (qs("FilterValue1") == filterValues[i] ? 'style="' + selectedValueStyle + ' ' : '') + 'href="' + document.location.pathname + '?FilterField1=' + filterField + '&FilterValue1=' + filterValues[i] + '">' + filterValues[i] + '</a>');
    document.write('<div style="' + filterDivStyle + '">' + filterLinks.join(filterValuesDelimiter) + '</div>' + '</br>' + 'Please select a letter to view the available customer documentation');

Ok quick addition, I think I understood what I need:

I need in some way to handle any click I make on any folder in the bottom document form web part, and before the folder content is loaded I need some JScript code that removes the existing filter from the URL, but then it still has to complete the loading of the content of the folder. I have been able to get access to SPDesigner so now I should be able to add code in the DispForm.aspx page.

Anyone knows which event on the form allows me to catch the moment I click on ANY folder in the library and which instructions can I use to remove the FilterValue but not stopping the next page to load?


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.