For a WCM project that I’m working on I’ve been looking at the new and improved Content Query Web Part in SharePoint 2010. I stumbled across some properties in the .webpart file of a CQWP that seemed to indicate it was possible to enable AJAX for the web part… and so it proved to be!
If you’ve used the List View Web Part in SP2010 to drop a view of a library or list onto a page you may have noticed that there’s a category in the web part properties for ‘AJAX Options’:
Enabling these options for your List View Web Part allows for the asynchronous update of the content being displayed – which is fantastic. So how do we get the Content Query Web Part to behave in a similar way?
Looking in the web part properties pane of the CQWP you will notice that the ‘AJAX Options’ section is missing. The options however are available if you export the web part and manually edit the .webpart file. [Looking on MSDN you can see that the AJAX options seem to be available because the CQWP inherits from the Data Form Web Part]
From my understanding the properties map as per below:
|CQWP .webpart Property||LVWP Property|
|InitialAsyncDataFetch||Enable Asynchronous Load|
|AsyncRefresh||Enable Asynchronous Update|
|ManualRefresh||Show Manual Refresh Button|
|AutoRefresh||Enable Asynchronous Automatic Refresh|
|AutoRefreshInterveral||Automatic Refresh Interval (seconds)|
By setting AsyncRefresh and AutoRefresh to True I was able to see the contents of my content query web part update themselves without a page refresh. Awesome! I need to do a lot more investigation about how/ if this is usable in a real world situation but it’s a pretty cool start.
And now for a disclaimer! It’s highly likely that these options are not presented to the user for a reason. My guess would be that it’s because of a performance hit. So by following the instructions in this post you’ll need to consider what impact this has on the performance of your solution.