Monday, March 07, 2011

Passing URL Querystring to IntelliGantt Web Part

One of our design goals for the IntelliGantt Web Part was to make it easy for users AND for system integrators. For instance, we know how important a brand is so we reserve an area of the gantt chart to display a customizable name with a url link. Additional configuration options like colors, zooms, custom list IDs and more are available via the web part editor or passing parameters via the initParams string (our control being a good Silverlight citizen).

Then someone asked us 'can I pass configuration parameters with the url querystring?'

What a simple and powerful idea! Last Wednesday we said 'no', but today we can say YES!

We have created a table of all the parameters IntelliGantt recognizes. You can use these parameters via the initParams property if you've configured a 'Site Only' instance of the IntelliGantt Web Part, or you can pass these parameters to the SharePoint page housing the IntelliGantt Web Part via the url querystring and make things really dynamic.

The best example of this new capability is how you can now select a task list and view by placing information in the url querystring. Let's say I have a SharePoint site with two task lists: Tasks and Big Project. By default, the IntelliGantt Web Part finds all the task lists in your site and displays them:




Yes, we can either use the 'Exporer' to select just one project, or we can use the web part editor page to select a single project. But what if we could determine the list to show before-hand and construct a url with selected project and view information? Then we can actually plug the web part into a multi-step workflow process.

First, let's add a SelectListIDs value to the url so that just one project is selected. You can find a task list id value by first navigating to the task list:




and then going to the List Settings:




Once in the List Settings, notice that the url string in your web browser contains a querystring parameter of List=:




We can use this exact same list idea value in the querystring of the url of the IntelliGantt Web Part page. Rather than just 'List', we use 'SelectedListIDs' because we think it's clearer and we support multiple lists in the view. There, we create an url like so:




Finally, you can add multiple paramteters to the querystring just as you'd expect-- by concatenating them with the '&'. So, now that we've selected the right list, we can also select the view to use via the query string by appending the view name:




And voila, the task list and view for the IntelliGantt Web Part have been determined by the values in the querystring. What if the same parameter is defined in the web part editor? Then the web part editor value will take precedence. In order use the querystring parameter, make sure the corresponding field in the web part editor is blank.

As we add more configuration options to the IntelliGantt Web Part, we will make sure they can be set via the web part editor, the initParams or the querystring. This will ensure our design goal of making our web part as flexible for system integrators as possible.

2 comments:

Jim Thomas said...

Good stuff. Am wondering if it is possible to pass list filter parameters as well. We are evaluating changing the design of our Project Management System. In one of our concepts, schedules for all projects would reside in a single list. We plan to construct a single schedule page that contains Intelligantt and would like to pass the project name or ID via the URL so that only the tasks for the pertinent project are displayed on the page. That way we only have one physical schedule page for all projects. Can that be done?

John Milan said...

Yes, all the parameters can be passed on the URL string. We should have this documented in the forum.

To answer your specific question you would pass the following:

SelectedListIDs=

For example:

SelectedListIDs={140045A6-BFA6-4A71-B652-1A8B085A7453}

To add more than one list Guid, separate them with semicolons.