Showing posts with label XLVWP. Show all posts
Showing posts with label XLVWP. Show all posts

Monday 25 October 2010

Using SPGridView and Linq to display filterable lists

Problem: Display a SharePoint list and make it filterable. 

Initial Hypothesis: Create new page add the new Xslt List View Web Part (XLVWP) to the page. Customise the Xslt using SharePoint Designer (SPD).  The web part can now be exported if required.  Add filter web parts to filter the data for end users.

Resolution:  This gives a comprehensive solution for internal users but clients needing a specific design or advanced querying will need a different solution.  You can customise the xslt for the list and paging and sorting are built in.  However in my instance I needed drop down lists that could query against multi select choice columns. 

Problem Redefined: Using the SPGridView control display user's data based on selection criteria.

Hypothesis:
  1. Create a list that contains a choice column, the column should allow multiple choices.
  2. Ensure your generate a Linq to SharePoint proxy
  3. Create a Visual Web Part project that uses a visual web part to display the list results and the results are filtered by a drop down lists that works against the SharePoint list.
Resolution:
Filter the SPDataGrip using LINQ to SharePoint as shown below:
Step 1: Create the "Customers" list.
Stet 2 : Add the new column based on a multiple choice field type.

Shown above is my custom list "Customer", it has two columns namely: "Title" of type string and "Industry" of type choice (multi)
Step 3: Add a few random records.
Step 4: Create a new Visual Studio project, I chose a "Visual Web Part Project".
Step 5: Add the generate SPMetal code to your new project.  I used the SPMetal template provided by CKSDev but as long as you have added the SPMetal for the new list it will work.
Step 6:  Open the user control ascx and add a SPGridfiew and a drop down list.
Step 7:  In the code behind add the Linq query to retrieve the Customers list.
Different approach for using LINQ to SharePoint for this step is:

Step 8: Deploy you code and ensure it is working.

Tuesday 22 June 2010

XLV Web Part with filtering and customised UI (xslt)

Overview: Create a filterable view to display orders. 2 SharePoint lists: Product & Order and connected via a lookup column. Each product has an owner that we call the printer. We will use an Xslt List View (XLV) Web Part (WP) to display the multiple orders information. The UI will be customised using xslt and lastly a filter is needed to select the Printer/Owners. This will allow the Owner to see all their outstanding orders.
Steps:
1.> Create a new Site Page using the SharePoint 2010 site.

2.> Insert a SharePoint List Filter Web Part.

3.> Insert a XLV WP, this is created by SharePoint for any list/library that is create in SP2010. You will see the appropriate WP under the “List and Libraries” category when adding a WP to a page.


4.> Configure the SPListFilter to display the Owners/Printers.

5.> Setup the 2 WP to be connected WPs.


6.> Web page for ready for testing.

7.> Perform filtering using the Owner filter.

8.> Results Displayed

Thursday 17 June 2010

XLVWP - Filtering the xslt List View Web Part Series

Overview: Xslt List View (XLV) Web Part is widely used in SP 2010. This series of posts shows how to use this Web Part. Various connected web parts can be used to filter the XLVWP such as a List Filter Web Part.

Filtering: The filtering web parts provides a good way to filter data in the XLVWP. Using Connected Web Parts it is easy to filter the data you wish to retrieve. Below is the setup of 2 List View Web parts that are used to filter depending on the selected data.


Presentation: SPD 2010 provides a good tool for customising the presentation of the XLV WP. Additionally you can uncouple the default shared XSLT and provide your own customised xslt.

Also see:XSLT List View Web Part (XLV):

Sunday 13 June 2010

XSLT List View Web Part (XLV)

Overview:
SharePoint 2010 has a heavy reliance on the Xslt List (XLV) View Web Part (WP). The replaces the MOSS List View Web Part (LVWP). In MOSS the Content Query Web Part (CQWP) was heavily utilised and the XLV WP is often a better option in SP 2010.

The old LVWP used CAML to provide custom views of the data/lists. Customising the XLVWP display is is done using xslt.

XLVWP has a default xslt for display located in the 14 hive at _layouts/xsl/main.xsl
main.xsl uses vwstyles.xsl and fldtypes.xsl that does most of the work on all the XLVWP in your SP farm.

Note. "XSLT is schema dependent because it iterates through the list of columns by naming each one explicitly. Using XSLT, the schema of the rendered list is fixed; it’s not possible to change the set of fields without changing the XSLT." - Eric Andeen.

XLV WP model - How it works

A custom xslt can either be placed ina style library or in th 14 hive.
Using SharePoint Designer (SPD)2010, you can customise the the XLVWP

More Info
SPD 2010 working with XLVWP
XSLT customisation
Customise the XLVWP
Connected Web Parts (XLVWP)