Showing posts with label Xslt List View. Show all posts
Showing posts with label Xslt List View. 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.

Saturday 31 July 2010

SharePoint 2010 simple reporting options

Overview: SSRS has it's place but I want to gather reports from a composite application where data is stored in SharePoint lists.
Solutions:
OOTB web parts - UI may be tricky to get right but useful for quick reporting that can be performed by power users for general business users. Use filter, List View (XLVWP), CQWP, data View, chart web parts.
Custom Web parts - either write or buy web parts for querying lists. Custom CAML queries provide a solution to display data. Con is that it's pretty development heavy, inflexible and requires code deployment. SPMetal has issues with joins, publish columns and hidden columns such as "Created by". Also see Ninetix reporting.
Dataviews - Displaying list data using SPD - need SPD access. Joining 2 lists.

Giles Hamson has a good chart explaining reporting options.

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):

Filter web parts are missing

I couldn't find the "filter web parts" on my SP 2010 installation, they are there just add them to the web part gallery.
In the RTM the filter WP are available by default and didn't need to be added.

A list of OOTB Web Parts

How Filter WP work from the MS site. Writen for MOSS but still applies to SP2010.

  1. Connect a filter Web Part to a List View Web Part to display a subset of data.
  2. The filter Web Part provides a value.
  3. The filter value is passed to a column in the List View Web Part by using a Web Part connection.
  4. The List View Web Part displays only those columns that match the filter value

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)