Adil Baig's Tech Blog

Wednesday, June 25, 2008

Recent N Documents Webpart for Sharepoint


Before I proceed, a great thanks to Jan Tielens and Robin
who tolerated me even in middle of night!!

Coming to the webpart...little upgrade that this guy has over Jan's SmartTools - WhatsNewWebpart v1.1 is that it gives configurable "Group By" property and ability to sort on columns(asc/desc)

So you must be thinking whats the deal about this thing.. its just another webpart that uses SPSiteDataQuery to get some recent data from document libraries like the Content Query Webpart. Well, yes it probably is and there is no rocket science involved here.

Only one problem here that i faced was "sorting and grouping together!!"..
Initially we get a cool "group by" in SPGridView but when you click on the grid's column for sorting is when things get a little awkward like this:



This started worrying me so much so that i almost forgot the most basic SQL thing there is:

always GROUP BY somecolumn ORDER BY somecolumn

Envisioning the above scenario, my GROUP BY and sorting (ORDER BY) were two different things that were not related and hence once i try to sort on any column, it damaged my group by
First i thought of doing the sorting in the CAML that is fed to the SPSiteDataQuery itself. But it started getting a little tedious thing as my SPGridView and the DataTable getting bound to the grid was getting generated in the CreateChildControl() event and the Sorting is a postback event of the control that happens after the CreateChildControl.

The logical solution i could see here was performing the group by and then sort by in the DataTable object itself and then binding the updated DataTable a little late in the control life cycle to the Grid..in OnPreRender for instance.

This obviously meant that i write some extra bit of code but it was not late that i discovered that Microsoft has already done that for us in DataSet Select DISTINCT Helper Class and CREATE TABLE Helper Class.

The Webpart can be found on my CodePlex Page

8 comments:

Richard Edwards said...

Hey Adil,

I downloaded the current release from CodePlex and when I went to take a look at the install and other files like the wsp they were all dealing with a DatePicker control and not the Recent N Documents webpart.

Anonymous said...

The new setup.exe throws an error:
***** SOLUTION DEPLOYMENT *****
***** ERROR *****
This solution contains resources scoped for a Web application and must be deployed to one or more Web applications.
CodePlex.SharePointInstaller.InstallException: This solution contains resources scoped for a Web application and must be deployed to one or more Web applications. ---> Microsoft.SharePoint.SPException: This solution contains resources scoped for a Web application and must be deployed to one or more Web applications.
at Microsoft.SharePoint.Administration.SPSolutionLanguagePack.CheckDeployParameters(Collection`1 collWebApps, Boolean globalInstallWPPackDlls, Boolean force)
at Microsoft.SharePoint.Administration.SPSolutionLanguagePack.CreateSolutionDeployTimerJob(DateTime dt, Collection`1 webApplications, SPSolutionDeploymentJobType jobType, Boolean globalInstallDlls, Boolean force)
at Microsoft.SharePoint.Administration.SPSolutionLanguagePack.Deploy(DateTime dt, Boolean globalInstallWPPackDlls, Boolean force)
at Microsoft.SharePoint.Administration.SPSolution.Deploy(DateTime dt, Boolean globalInstallWPPackDlls, Boolean force)
at CodePlex.SharePointInstaller.InstallProcessControl.CreateDeploymentJobCommand.Execute()
--- End of inner exception stack trace ---
at CodePlex.SharePointInstaller.InstallProcessControl.CreateDeploymentJobCommand.Execute()
at CodePlex.SharePointInstaller.InstallProcessControl.TimerEventInstall(Object myObject, EventArgs myEventArgs)

Mac - The Wanderer said...

Hi Adil,

Excellent content. Can you also provide the same .dwp for MOSS 2007 as this version throws up an error "Cannot import a Digital Dashboard Resource Kit (DDRK) version 3.0 Web Part. For more information, see the Windows SharePoint Services SDK or the SharePoint Products and Technologies SDK. " and realized that this is because i am using MOSS 2007

Adil A. Baig said...

I really don't know why are you getting this error, cause i have not made the web part for sharepoint 2003 or previous version. You get this when there are backward or forward compatibility issues.

Mickey said...

Hi Adil,
I downloaded the version and install in my WSS 3.0. everything went fine. is this works only for recent uploaded documents? i didnot see recent updated ones

thanks you very much for the post.

Ms. Chilli Micela

Adrian said...

There is a recent document webpart definition that runs with SP2007 & SP2010:
http://www.fiechter.eu/blog/Lists/Posts/Post.aspx?ID=19&mobile=0

SharePoint said...

Hello,

It's not work if i have more than 2 000 items, have u got a solution ?

digital certificate said...

Thanks a lot. I am new to SharePoint and your post just really solved my issues !!! Works like a charm !