locked
Which method should be used to create a view for a list/ library? RRS feed

  • Question

  •  

    Ho all,

    To create the view for a list or library we have three options given below-

    1. Create the Views in list/library’s XML schema itself.

    2. Create the View by List view web part.

    3. Create the View by Data view web part.

    Option 1 is very hard to do as we have to create the view in XML. As far as I know there is no tool available for same. Compare to the Option 1, Option 2 & 3 is relatively easy. I would say very easy. Can anyone please tell me what the best approach is? In what scenario option 1 should be used and in what scenario option 2 & 3 should be used?  Thanks in adv.

    Regards Amit K


    • Edited by Mike Walsh FIN Monday, May 2, 2011 11:35 AM Title amended by the addition of "Which method should be used" + ?
    Monday, May 2, 2011 8:02 AM

Answers

  • I wouldn't say that option 1 is not very hard to implement. In most cases you need to copy some existing view, change its id (BaseViewID attribute), title and url and specify appropriate fields in <ViewFields> section. Later you can use id of this view e.g. for LVWP which requires both list and its view id.

    Option 2 as I said is used in conjunction with option 1 - i.e. you specify what list view id should be used in web part. It can be also changed in UI via web part properties.

    Option 3 requires more customization if you will need some specific UI requirements.

    Option 4 is to create custom web part using e.g. SPGridView, ListViewByQuery or custom control. It gives you more flexibility but requires development.


    Blog - http://sadomovalex.blogspot.com
    CAML via C# - http://camlex.codeplex.com
    Monday, May 2, 2011 6:07 PM

All replies

  • In most cases you would use the out-of-the box option i.e. 2. (LVWP).

    Use 3. (DVWP) if you want to create a web part using List data from another site/sub-site in the same site collection.

    Use 1. very rarely and typically as a bi-product of a DVWP when you want extra functionality (and therefore convert to XSLT).


    SP 2010 "FAQ" (mainly useful links): http://wssv4faq.mindsharp.com/default.aspx
    WSS3/MOSS FAQ (FAQ and Links) http://wssv3faq.mindsharp.com/default.aspx
    Both also have links to extensive book lists and to (free) on-line chapters
    Monday, May 2, 2011 11:38 AM
  • I wouldn't say that option 1 is not very hard to implement. In most cases you need to copy some existing view, change its id (BaseViewID attribute), title and url and specify appropriate fields in <ViewFields> section. Later you can use id of this view e.g. for LVWP which requires both list and its view id.

    Option 2 as I said is used in conjunction with option 1 - i.e. you specify what list view id should be used in web part. It can be also changed in UI via web part properties.

    Option 3 requires more customization if you will need some specific UI requirements.

    Option 4 is to create custom web part using e.g. SPGridView, ListViewByQuery or custom control. It gives you more flexibility but requires development.


    Blog - http://sadomovalex.blogspot.com
    CAML via C# - http://camlex.codeplex.com
    Monday, May 2, 2011 6:07 PM