The CodePlex Corner: Instant List Filter

The link to the Instant List Filter is https://instantlistfilter.codeplex.com/

This edition of the CodePlex Column delves into the SharePoint Instant List Filter, a project that’s both highly rated and has attracted a significant number of votes. It boasts an impressive 20k+ download count (at the time of writing). It was developed by Jaap Vossers and has previously attracted the attention of Marc Anderson and Alexander Bautz (both well-known JavaScript experts). As the product name suggests, the solution provides filter text boxes on a list/library to allow a “filter-as-you-type” functionality. It also needs JQuery to work successfully when it is deployed. Having being around since 2009, it would be fair to say that the list filter is one of the community products that has stood the test of time.

So, if it has been around for a while, the first question that may spring to mind is; what’s the point in taking a look at it now? The simple answer is the changing SharePoint landscape. As with a few other projects that have been discussed in the CodePlex Corner, the environment that the list filter was born into is very different to the one that we, as SharePoint professionals, have now. Some of the noticeable differences include more powerful versions of SharePoint, newer HTML / CSS standards for each one and of course, very different browser habits to contend with. It’s in this light that an in-depth look at the utility in context of its altered environment might be useful.

A good place to start is to look at how the list filter code responds to the various versions of SharePoint still in use today. Whilst investigating, the opportunity to test the code against the popular browsers of the day also presents itself. The timeline below looks at the release dates of all these products.

Building such a timeline provides two distinct advantages: –

  1. Identifiable points in time at which we can check browsing habits
  2. A linear route to allow us to see which browsers that SharePoint and the list filter would be expected to work with

Cross referencing the most recent three dates from the timeline above with the W3Schools Browser statistics provides the following insights into browser trends at the time of release for each product. The most noticeable thing is the huge increase in Chrome usage and the sharp drop in how many users are sticking with Internet Explorer. Mozilla’s Firefox, despite losing almost a third of its user base between May 2010 and November 2012 does still remain the intermediate browser of choice.

Date

IE

Firefox

Chrome

Mar-09

43.30%

46.50%

4.20%

May-10

32.20%

46.90%

14.50%

Nov-12

15.10%

31.20%

46.30%

Aug-14

8.30%

24.70%

60.10%

Whilst these statistics are for overall browser usage and not specific to SharePoint utilisation, keeping these trends in mind is important as SharePoint doesn’t necessarily play nicely with non-Microsoft browsers. Some of the more unique SharePoint features (like these) are built in Active-X, a proprietary technology that only works in Internet Explorer. Knowing these limits when planning browser support around a SharePoint deployment is invaluable. Extending this line of thinking to third party products both commercial and open source should be seen as a wise investment.

Armed with an idea of the likely browser habits of your audience, a SharePoint professional will know where to begin assessing the list filter. Should the project not work in any of the browsers above, they can now work what the potential damage will be. Having deployed the list filter against several versions of SharePoint in the browsers listed above, the following behaviours were noted.

SP Version

IE

Firefox

Chrome

SharePoint 2007

Rendered

Didn’t render

Rendered

SharePoint 2010

Rendered

Didn’t render

Rendered

SharePoint 2013

Rendered

Didn’t render

Rendered

What these notes (as seen in the project forums here) show are that any FireFox user is not likely to see the list filter render to any SharePoint deployment that they may be visiting. As of August 2014 at 24.7% usability, that’s almost 1 in 4 of any user base, which is a significant number. (How to get the script working with Firefox is the companion tutorial for this article).

Moving on from this, knowing what versions of SharePoint the list filter works on is only one part of our journey. As Microsoft ships the product with several different list and library templates it would be easy to assume that if the List Filter works on one, it would work on all of them. To explore this assumption in greater detail, these templates were all tested. Please see the table below for the results. Please note that only a custom list was tested, not each specific list template packaged.

 

 

Template

Rendered

Worked

Custom List

Rendered

Yes

Asset Library

Didn’t render

No

Data Connection Library

Rendered

Yes

Document Library

Rendered

Yes

Form Library

Rendered

Yes

Record Library

Rendered

Yes

Wiki Page Library

Rendered

Yes

 

The last level that we can assess the list filter on is the column level. It provides a great freebie in that you can use it to filter on field types that normally aren’t filterable. This includes calculated columns and notes (multiple lines of text) fields.

Link to SharePointReviews.com product review

Currently there is no entry on http://www.sharepointreviews.com for the Instant List Filter.

“End User – Developer” scale

This tool fits squarely in in the End User part of the “End User – Developer” scale. The list filter is easily deployed to the client with little effort, from which point it pretty much becomes a “fire and forget” solution. There are several other ways to install the solution but the ability to copy and paste the code into a Content Editor Web Part makes this very accessible.

Potential pitfalls / problems

The instant list filter was originally developed for SharePoint 2007. This is the single biggest problem that IT professionals are likely to have with it. It can work with SharePoint 2010 / 2013 though. The issues that you are likely to experience with it are:-

  1. It only filters on returned item count and doesn’t go past pagination. For instance, if you have a list with 3000 items but have set pagination to 100 per page, the list filter only works on those 100 items.
  2. It also doesn’t work on external lists unless modified to do so.
  3. It doesn’t work very well with FireFox unless modified to do so.

Tutorials

Because the list filter is easy enough to get started with, an installation tutorial would be pointless. Instead, what we’ll look at is how to get the script working with FireFox, which appears to be problematic for some users.

Conclusion

When installed and operational the instant list filter looks and feels like it should have been part of the SharePoint product itself. It’s a classy and easy-to-use extension that complements the OOB search tools very well. The ability to filter on traditionally non-filterable field types is a big bonus. It does have its limitations however, with the most potent of these being that it only filters on the rendered page items NOT the entire list.

The links below are my reference list: –

  1. Original CodePlex Project Link: – https://instantlistfilter.codeplex.com/
  2. Jaap Vossers Blog – http://blog.vossers.com/
  3. Business Data List Web Part usage – https://instantlistfilter.codeplex.com/discussions/228167
  4. Visual Upgrade changes – https://instantlistfilter.codeplex.com/discussions/262132
  5. Filtering on just a single column – https://instantlistfilter.codeplex.com/discussions/257825
  6. 2010 Code – https://instantlistfilter.codeplex.com/discussions/49123
  7. W3C Browser Statistics & trends – http://www.w3schools.com/browsers/browsers_stats.asp
Advertisements

Building a list-specific search with JavaScript

Whilst writing an article that looks at the Instant List Filter (hosted on CodePlex) I started wondering if there was an “Out of the Box” search solution that allows users to search within specific lists. It’s a discussion that I’ve frequently seen in the TechNet forums, particularly whenever search scopes are mentioned. Whilst I wasn’t able to locate anything via the SharePoint GUI, there is indeed a way that this can be achieved, simply by using JavaScript and the Content Editor Web Part.

Solution Details

The core solution is to embed some JavaScript code within a Content Editor Web Part (CEWP) and to tweak it for your list / library. Within the source code (HTML view for SP2010) the code snippet entered provides the end user with a dropdown box, a textbox, and two buttons. These buttons are a Search button and a Clear button.

The dropdown list provided will contain a hardcoded list of all the column names that you want to make searchable. The intention is that the user selects the column to search by picking it from the dropdown box, enters his search text and then clicks the Search button.

The JavaScript will then redirect the user to the same page, with query string data appended to the URL. The Clear button sets the query string url back to blank, which in effect clears the search data and ensures that the entire list is back in view.

When search scopes are enabled in SP2010, the option to search the list is automatically included in the list of options. However, search scopes are enabled at the site collection level, meaning that once enabled, all lists within your site collection will get this option. This JavaScript alternative is particularly useful if you want to enable list-level search for specific lists only. It also has the added advantage of allowing results to be displayed in situ instead of redirecting to a search results page. However, rather than jumping straight into the code, let’s look a little at how OOB list filtering works as this is the functionality that the script plugs into.

Looking at the query string in greater detail

  • In your SharePoint site create a list that has a high number of columns. The Contacts list works perfectly for this

  • Next, input a few dummy items. Having a few rows to play with works best. In my example I’ve used two football managers from the UK Premier League as well as the national team manager

  • Now that you have some test data, apply a filter and wait for the page to reload. The demonstration screenshot below applies a filter to the Last Name column.

Script Details & how to amend

  • Step One: On the page that you want to apply the search field to, use Site Actions à Edit Page
  • Step Two: Click Add a Web Part
  • Step Three: Add an HTML Form Web Part or a Contend Editor Web Part, either will work

  • Step Four: Input the code snippet below and make the following changes
    • In the function RedirectURL add the columns you want to make searchable from left to right using the format “Column2”, “Column3” and so on
    • In the same function, locate this text window.location.href = “AllItems.aspx?” and set this to the page you want the search results rendered on. The script has this set to the default view AllItems.aspx. Please note that you MUST keep the question mark in the code.
    • In the Search field you’ll see some options that look like this: – <option
      value=”Title”>.
      These fields need to correspond to the internal name NOT the display name of the
      columns that you want to make searchable. Column internal names are explained very well here.
  • Step Five: Save the file once you’ve made your amendments and your page should reload looking something like the below, with a basic but list-specific search engine at the top of the page

Further usage

There are probably some things that you can do to take this further if so desired. Some of the tweaks I’ve made include: –

  1. Styling the buttons according to branding requirements
  2. Keeping this code in a separate HTML file and linking it within a CEWP
  3. Hiding all but the first selection field to force searching within only one column

The CodePlex Corner: JavaScript Editor for SharePoint (JEFS)

The link to the project is http://jefs.codeplex.com/

This edition of the CodePlex Corner looks at a project called JavaScript Editor for SharePoint or JEFS for short. It has been coded and released by Tomek Stojecki and is available for SharePoint 2010 (all editions) as a sandboxed solution. The project provides some nifty features for WFE development, and anyone who’s ever been tasked with JQuery or CSS changes to their SharePoint installation will appreciate the utility that JEFS provides. It effectively does away with the necessity of having to use Content Editor Web Parts to hide and tweak code.

It’s fair to state that a large number of CodePlex projects are poorly documented, but JEFS is a project that bucks this trend. Tomek has provided a well written introduction, which explains both the components and the history of the project. He also provides an installation guide and a PowerShell script for easily installing it. This script will detect previous installs of the project and will ask if you want to back-up any content created in it prior to being upgraded.

Because JEFS has been packaged as a sandboxed solution there are several things to keep in mind. For those that aren’t aware, a sandboxed solution is one that doesn’t have full access to all of the server or system resources. Nor can they access content outside of the Site Collection that they are deployed to. The plus point of this restriction is that the solution doesn’t need to be installed by a systems administrator. As such, a clear benefit here is that the IT department need not be involved – JEFS can be installed by the site collection administrator instead. It should also be noted that as a sandboxed solution, JEFS usage is governed by the resource throttle limits set by your SharePoint administrators. This resource throttle is a configurable maximum of daily resource points for site collections, which if breached, terminates all sandboxed solutions for running for the remainder of the day.

So, with all that being said the next logical question is; what does it let you do? Put simply JEFS is an in-browser editor that does away with the need to bundle code in CEWPs. It provides one single resource for managing all of your JavaScript, CSS and library references. This screenshot shows code positioned within two panels of JEFS. The drop down menu highlights the JavaScript libraries that are available for referencing in any solutions.

Separating out this code into clearly visible panels is a world away from embedding it within an HTML view or adding JQuery (and other library references) directly into .aspx pages via Designer. It additionally removes the frustration of seeing SharePoint mangling any structural formatting of code that it placed in a CEWP. Lastly, depending upon where JEFS is invoked from, you also have the ability to select which web part zone your changes are applied to. Add into the mixture syntax specific highlighting for each distinct panel and language, and JEFS becomes both a powerful and time saving tool.

As mentioned earlier, some JavaScript libraries are available for inclusion in your code. Tomek has packaged the following libraries with the product as well as including an editing panel in which they can be referenced: –

  1. JQuery
  2. JQuery UI
  3. SPServices
  4. Ext JS
  5. Knockout

Another part of the power that JEFS adds is where it interfaces within SharePoint. The screenshot below shows the JEFS entry point on a web part page but it is also accessible from: –

  1. List view and form pages
  2. Document library view and form pages
  3. Wiki pages

As a sandboxed solution, JEFS also has the capability to run within both SharePoint 2013 and Office 365. When looking at the functionality and set of features included with these platforms, one in particular stands out: the NAPA editor for Office 365. This is also an in-browser editor, but one that is provided specifically for application building in a cloud environment. As such, a quick feature comparison between the two presented side by side may be useful. Please note that is not offered as a fully exhaustive list.

NAPA Functionality for Office 365

JEFS Functionality for SharePoint 2010

  • No desktop installation needed – launches within the browser
  • Allows you to connect to Visual Studio
  • Allows editing of CSS, JavaScript and HTML
  • Syntax highlighting and IntelliSense
  • Ability to package and publish apps via the Office Store or internal app catalogues
  • Similarity to IDE environment and ability to edit .aspx pages
  • JavaScript, HTML and CSS editors with syntax highlighting
  • Ability to easily reference external JavaScript libraries such as jQuery
  • Sandboxed solution for localised activation
  • Split screen with resizable panels
  • Ability to add the content editor web part to the web part page and link it to the HTML content of JEFS
  • Launched from Ribbon, can be added to other navigation components within SharePoint

 

As with any choice of tool, understanding your needs will have a deciding influence on which tool to pick. JEFS lends itself well to rapid code deployments for WFE development. It is a further timesaver in that things like HTML source views and SharePoint Designer changes can be consigned mostly to the past. NAPA as a utility that has been built specifically for Office 365 has different tools aimed application development for the cloud edition of SharePoint. Both of them are developer tools, but with different scenarios in which they can most effectively be utilised.

As JEFS is a browser-based editor, being aware of browser support for SharePoint 2010 is advantageous. The tool, as with SharePoint itself, was designed with specific browser support in mind. Microsoft has published a TechNet article that discusses browser support and compatibility. This article can be read on this URL

HTML document Standards mode within IE comes into play when using JEFS. As IE allows you to specify both the browser standard and the document mode standard used for page rendering, selecting the correct ones for your development work is important. For example, developing a page in IE9 uses a Document Mode (IE7 standards) that can render things very differently than later standards. Ensuring that any JEFS output is tested sufficiently against both the IE compatibility and document modes can save further problems in the future.

Link to SharePointReviews.com product review

The product entry for JEFS on SharePointReviews.com has been posted under Development & Deployment à Development Tools. The link is http://www.sharepointreviews.com/sharepoint-development/1284-Javascript-Editor-for-SharePoint

“End User – Developer” scale

Trying to determine the best audience for JEFS is somewhat difficult. This is a tool that has two potential audiences: –

  1. SharePoint Developers
  2. IT Professionals that are tasked with making changes

Despite the second group standing to benefit from JEFS, the tool is clearly more suited to those that are comfortable with the various languages that are involved with WFE customisation. For that purpose JEFS scales more towards the developer rather than power users or administrators.

Potential pitfalls / problems

As with any new solution that you want to introduce to a SharePoint deployment, testing and configuration are important parts of good IT governance. The only issues that you may experience with JEFS are: –

  1. Broken rendering when used on sub-sites: – If an older version of JEFS has been installed than an error may be experienced which involves a broken web service call that tries to call web part zones. This was fixed in the January 9th release of JEFS (beta 2.03)
  2. Debug set to the correct standard: Be wary of the standards used. Mostly applicable to Internet Explorer, the document mode can have some differing results on your rendered results

Tutorials

Two companion tutorials have been written to accompany this article to highlight how JEFS can be used. These are: –

  1. Building a small application in JEFS using the Rotten Tomatoes API (pending)
  2. Editing a SharePoint form in JEFS using JQuery and SPServices (pending)

Conclude and add any relevant links

In closing, JEFS is one of the SharePoint-related hidden marvels of CodePlex. It is a tool that can potentially make life easier for both developers and IT professionals alike. When taking into account the different areas of SharePoint that JEFS can be invoked from, it feels like a natural extension to the SharePoint platform. The tutorials above are designed to give you a flavour of how you can use JEFS, but it is capable of much more.

A lot of credit needs to be given to Tomek for both coding up and releasing JEFS and for his contributions to this column.

The resources below were referenced for this article: –

  1. JEFS on CodePlex
  2. Introducing NAPA
  3. Tomek’s Twitter Feed
  4. Resource Limits on Sandboxed Solutions