1

On my web part page I have 2 list view: Parent and Child. Child is connected to Parent. Parent view is filtered Display=1. I click item "DDD" on parent list, take it to edit, change value Display=0 and save. After returning to original page situation looks like picture shows:

  • Parent list have correct selected item "EEE"
  • url contains non correct SelectedID=8 which means item "DDD"
  • Child list is non correct filtered for origin parent item "DDD"

enter image description here

I tried to laborate with onLoad scipts to force reload page with correct Id. (Checking images on page for alt="Selected" , checking anchors for javascript:SelectField ... etc.).

Please, is there some recommended solution for this situation ?

4
  • Don't think you'll find an answer for that. The filter is causing the problem. When you take it to Edit, the current URL is passed as the location to return when finished. Due to the fact that you are changing the value which is filtered on, the URL becomes incorrect. You would need to modify the return portion of the URL that takes you to Edit...
    – WhiteHat
    Commented Jul 31, 2015 at 11:39
  • @WhiteHat Thanks. I know fact about return url. I think this problem has solution. I must investigate : selectedItem/focused/child items/anchors and many other things on page after load... Using pure javascript (no jquery enabled). Maybe, someone do this before me.
    – Marian
    Commented Jul 31, 2015 at 11:50
  • JavaScript -- That's what I meant by modifying the URL. I could probably help you there but I need more info. Will the user always take it to edit and change the value to remove it from the filter?
    – WhiteHat
    Commented Jul 31, 2015 at 12:06
  • @WhiteHat: Item can go away from filter by: editing in editform (modal or full) , deleting or making Stop editing in list edit mode.
    – Marian
    Commented Jul 31, 2015 at 12:42

1 Answer 1

0

This javascript solve me the main problems. Attention: not working for inline edit mode of parent list. (Thanks to my colleague Peter):

<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("dfnInitLists");
function dfnInitLists()
{
   var selectedID = dgnParameterByName("SelectedID");
   if(selectedID && !dgnExistsDiv(selectedID))
        {
          console.log("window.location: " + window.location.pathname);
          window.location = window.location.pathname;             
        }
}
function dgnParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
function dgnExistsDiv(id)
{
  var allElements = document.getElementsByTagName('div');
  for (var i = 0, n = allElements.length; i < n; i++)
    if (allElements[i].getAttribute("id") == id)
                return true;
  return false;
}
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.