Wider refinement panel – with no access to backend

I had the challenge that the standard search refiners were not wide enough to accomodate the values we had coming back. In the "Refinement" web part, you can increase the number of characters that are displayed. So I started with that. Here is a similar scenario using the downloadable demo VM from Microsoft:

As you can see, the site names get trimmed, which doesn't look too good. If you edit the web part, you can increase the number of characters to display:

Now, the strings are no longer trimmed. But if they are too long, a line break is inserted, which can look awkward, too. (And it was much worse in our case, since the strings were so long that they extended outside the web part!)

There is no setting for increasing the width of the web part itself, and we did not have access to edit the page layout or CSS files. So, we turned to JavaScript for a quick and easy solution! We added a "Content Editor" web part to the top of the page, and removed it's styling, so that it was invisible to the user. Then we added the following lines of code:

<script language="javascript">
var existing = window.onload;
 /* Needed to make sure existing SharePoint onload JavaScript still gets executed! */
window.onload = function() {

if(typeof(existing) == "function"){ existing(); }
/* resize refiner width */

There were three challenges to getting the above code to run properly:

  1. Finding out that 'SRCHREF' was the element id of the refinement panel
  2. Making sure the code ran after the page was fully loaded, since the refinements are displayed asyncronously
  3. Making sure existing "onload" code continued to run, otherwise the ribbon functionality was broken

And now, everything looks just the way we want:

Comments (4)

  1. theChrisKent says:

    Awesome, exactly what I needed, thanks.

  2. Dean says:

    all of the sites in my web app begin with the same 30 characters, do you know how i can get the refinement panel to ignore those and just dispaly the text after these characters?


  3. Hi Dean!

    There is no out-of-the-box way to trim characters, but it could easily be done using JavaScript, so I suggest looking into that as a quick-and-dirty front-end fix.

    Cheers, Thomas

  4. /* refinement panel width */

    #SRCHREF {

    width: 225px;  


Skip to main content