Showing posts from February, 2016

Sharepoint 2013 search: how to make refiner update 2 search web parts

So my case today is having a nice Search Results Page, with a nice Search Results WP and a Refinement WP updating him.

now i added another Content Search WP, and Oh My! it doesnt updates!
since i am used to MS giving a lot of work to developers, that looked like a nice challenge, some advanced client-side Search-Controls work.

1 - Get the new query that part is easy - its up in the url, with a simple regex i took it out
var rgx = /#Default={[{":,\\}()#\-\[\]a-zA-Z0-9]+}/;
var queryObjStr = decodeURIComponent(window.location.hash)
                     .match(rgx)[0].replace("#Default=", "");
2 - Send it to our control well, MS did gace us some nice Client-Side API, one of the SRCH objects is the QueryState, which is actually the object in the Default up in our hash
var queryState = JSON.parse(queryObjStr);
var queryStateArgs = new Srch.QueryEventArgs(queryState);
//and tell our control to update
var cc = ctx.ClientControl;