none
Connected web parts and query string RRS feed

  • Question

  • I have created a wiki page in SharePoint Online which has the following three web parts

    1. A query string web part
    2. Parent web part
    3. Child web part

    - QueryString Web part is connected to Parent Web part and provides filter to it.
    - Parent and Child web parts are 'connected' web parts.

    1. When the page gets loaded, the query string web part provides filter based on query string to the Parent web part. Parent web part shows only filtered records (say all orders of customer whose id was provided in query string).

    2. Now when user selects a record from the connected Parent web part, page gets refreshed and now the Parent web part contains all the records and not just filtered records.

    Behavior 2 is understandable, as when user selected a record, request was sent to the server and querystring now no longer contains the customer id.

    My Question

    How can the query string be retained so that when user selects a record in the Parent web part and request sent to sever, only the filtered records are displayed i.e and not all the records (not all the customers)?

    Monday, March 27, 2017 6:40 AM

All replies

  • Hi,

    Thank you for your post.

    This is a quick note to let you know that we are performing research on this issue.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, March 29, 2017 9:51 AM
  • Hi,

    Here is my test workaround for your reference, as filter is triggered by JavaScript function SelectField, so I just overwrite this function to reload the page and keep the query string parameter in URL.

    This may need update based on your scenario, as I keep the default query string in URL for test purpose.

     <script type="text/javascript" src="./SiteAssets/jquery-1.6.1.min.js"></script>
        <script type="text/javascript">
            var _SelectField = SelectField;
            SelectField = function (b, a) {
                //var paraSession = localStorage.getItem("Paras");
                var initPara = getQueryStringParameter("Title");
                //var _SelectedID = getQueryStringParameter("SelectedID");
                var newURL;
                if (initPara) {
                    //localStorage.setItem("Paras", initPara);
                    newURL = window.location.href + "&View=" + b + "&SelectedID=" + a; //+ "&Title=" + paraSession;
    
                }
                window.location.href = newURL;
            }
    
            function getQueryStringParameter(paramToRetrieve) {
                if (document.URL.indexOf('?') > 0) {
                    var params = document.URL.split("?")[1].split("&");
                    for (var i = 0; i < params.length; i = i + 1) {
                        var singleParam = params[i].split("=");
                        if (singleParam[0] == paramToRetrieve) return singleParam[1];
                    }
                }
                else {
                    return false;
                }
            }
        </script>

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, March 31, 2017 1:13 PM