A web part which shows a list is supposed to display only one view of the list - Asif Rehmani |
Wednesday, February 28, 2007 4:50 PM
|
A web part which shows a list is supposed to display only one view of the
list at a time. You can definitely change the view by modifying the shared
web part properties.
So the question comes to mind: "Why would I want to display only one view of
a list?". Well, consider this scenario:
You have a list which displays Job Postings within the company. In that
list, you have defined "Begin date" and "Expiration date" columns. Now
let's say you create 3 views on that list and call them "Current Job
Postings", "Previous Job Postings" and "Upcoming Job Postings". You use the
Begin date and Expiration date column to define which records to show for
each view. Now you can deploy 3 web parts on your site and each of the web
parts would be displaying the Job Postings list with a different view
exposed.
Hope that made sense. Let me know if you need further clarification.
--
_______________________________
Asif Rehmani, MCT
Trainer / Solution Architect
SharePoint Solutions | Chicago Office
asif@sharepointsolutions.com.(no-spam)
SharePoint Training: http://www.sharepointsolutions.com/chicago
SharePoint 2007 Videos: http://www.sharepoint-screencasts.com
SharePoint Blog: http://sharepoint-screencasts.com/blog |
 |
Ok, I understand why it is a good thing to predefine a view. - TomVervoor |
Wednesday, February 28, 2007 5:07 PM
|
Ok, I understand why it is a good thing to predefine a view. But here's what
I don't get:
If you create a list, the default view is 'All items'. If you open up
'allitems.aspx' in the SharePoint Designer, you see that it is actually just
a ListViewWebpart with the ability to change the view.
If you display the list on another page, it is also a ListViewWebpart, but
you don't have the option to change the view anymore. At least... the
end-user can't change this anymore.
Still, it is twice the same webpart ! |
 |
Hi Tom,The reason that you see the difference in behavior between a - mark.parson |
Wednesday, February 28, 2007 6:03 PM
|
Hi Tom,
The reason that you see the difference in behavior between a ListViewWebPart
in the AllItems.aspx page vs. a ListViewWebPart that you add to a web page is
because there are web part properties such as the ListViewXML property that
are set differently.
The ListViewXML property contains CAML that defines the view. When you
create a custom list or library, SharePoint generates a list view web part
for you, named after your custom list. It also automatically sets the
ListViewXML property for the web part with CAML that describes how to display
your list as you see it when you add the part to a page. This automatic
configuration does not include the drop down and other nice features that the
web part on the AllItems.aspx includes. The list view web part on the
AllItems.aspx page contains CAML that includes the features such as the drop
down list with different views.
SharePoint gives you no user interface to manipulate this CAML besides that
you can do by modifying a view, which is not much. You can directly edit the
ListViewXML from the tag properties panel, but to do anything sophisticated
using this technique would be extremely difficult.
You might try copying the ListViewWebPart definition from the AllItems.aspx
page to your new ListViewWebPart.
You could also convert I would suggest that you convert the ListViewWebPart
on the AllItems.aspx page to a DataView and copy that. This is what I would
do, since all of the CAML gets converted to XSLT which can be manually
changed to do whatever you like.
Hope this helps - mark
--
_______________________________
Mark Parsons | Cofounder, Architect
Distributed Logic Corp.
mark.parsons@distributedlogic.com Team Blog:
http://www.sharepointplatform.com/teamblog |
 |
change view in webpart - TomVervoor |
Thursday, March 01, 2007 1:21 AM
|
Your answer is all I needed to know... thanks ! |
 |