WebDrawer - go to end of search results
Background
I had an enhancement request for the WebDrawer search results to include links in the paging to allow the user to go to the first or last page. I thought I might as well post the code for earlier versions for those who may want to use it without waiting for the next major release.
The code
Simply replace the file Views\Shared\searchResults.cshtml with the fixed version for either 82 or 83.
Manual Merge
If you have modified searchResults.cshtml you might prefer to merge my changes into your CSHTML. Look for these changes:
Reduce number of items in page list from 7 to 4:
int pagingLength = 4;
Display a got to start link at the beginning:
if ((progressiveCount - 1) > Model.Results.Count) { queryString["pageSize"] = pageSize.ToString(); queryString["start"] = "1"; <li> <a href="?@queryString.ToFormUrlEncoded()">«</a> </li> queryString["start"] = (progressiveCount - (pageSize * 2)).ToString(); <li> <a href="?@queryString.ToFormUrlEncoded()"><</a> </li> } else { <li class="disabled"><a href="#">«</a></li> <li class="disabled"><a href="#"><</a></li> }
Display a go to end link at the end:
if (progressiveCount < Model.TotalResults) { queryString["pageSize"] = pageSize.ToString(); queryString["start"] = (progressiveCount == pageSize ? progressiveCount + 1 : progressiveCount).ToString(); <li> <a href="?@queryString.ToFormUrlEncoded()">></a> </li> queryString["start"] = (((totalPages - 1) * pageSize) + 1).ToString(); <li> <a href="?@queryString.ToFormUrlEncoded()">»</a> </li> } else { <li class="disabled"><a href="#">></a></li> <li class="disabled"><a href="#">»</a></li> }
Written on March 11, 2016