I didn’t know how if this could be done, so I did what came natural. Poke around 'til I finally get an answer. Usually I end up with a dead-end but today, I definitely found something of value. It’s a lot more simple than what I originally thought. Tools needed: SharePoint Designer and Notepad. This could all be done within SPD but since it crashes on me, I tend to take my code offline, then paste it back into SPD, right before saving.
So where do we start? How about cracking open the list that you’d like to create a secure view on. I needed a way to create a secure view of a Gantt Chart and mash it up with a few other lists. So since I didn’t know how to make a Gantt chart with a DVWP, I poked around a little. I created a Gantt Chart view using the GUI. When you save the view, there is a .aspx page that shows up within the Folder Navigation. My custom view is cleverly called, PersonalViews.aspx
Once this view is created, you can open the page up and *reuse* all of that code somewhere else… So, since I already have a Benchmarking Doc Library that uses custom permissions, this will be a perfect place for my PersonalViews.aspx page. After opening the page, click over to the code view and select all of the code. This is where Notepad comes into play. I take all of that code and paste it directly into a fresh Notepad .txt file. That way I have all of that code within another program… Just a preference, but we all have our ways ;-). With all of that code, we can now navigate the GUI and delete the view we created. There’s no need for it anymore and it’s best to delete the view within the GUI. I’m not sure what happens if you just delete the .aspx page, but to be safe, use the GUI. Why are we deleting what we just created? Doesn’t that defeat the purpose? NO! We have all of the code that’s needed in Notepad, remember? What we need to do now is create a new .aspx page within SPD. I deleted all of the auto generated code:
We don’t need any of that gunking up our new view. Now copy all of the code from Notepad into the code view of the .aspx page. When this page renders, it’ll give you a nasty looking error:
I thought this was a show stopper, until I saved it in my secure location: Benchmarking Doc Library. Here only the owners of the site are allowed to view. I’ve tested logging in as many different users and even if they are allowed to view the Benchmarking Doc Library, if they don’t have explicit rights to this aspx page, they’ll get security trimmed. List Views can now be security trimmed!!! Also, you’ll notice within your list, the drop-down for all of the views has a new view. It’s called whatever you named your aspx page. However, when someone without rights to the page clicks on the view from the drop down, they’ll soon realize they are in the wrong spot:
If you use this and find more purposes for this, please drop a comment. I’d like to hear about it.