Can you add a dataview webpart (a XSLT webpart) into the solution and make it deployable?
Yes, you can! But first you need to be aware of the following:
1. SharePoint Designer will let you convert a simple list view webpart into XSLT webpart really easy, but it will hardcode the id of the list. It makes you xslt webpart not deployable to any other site.
2. In case you know how (if you don't know - I will explain further) to resolve the first issue, you need to implement module features with file element which has a AllUsersWebPart element. In that element you need to insert you xslt web part. !You need to insert your imported xslt webpart.
3.Sometimes it is really hard to guess what went wrong during module activation and why web part won't appear.
Once you are aware of it, we can run straight ahead to the implementation:
1. Open your SPD, the page where you want to add your xstl web part. And start crafting it:
option "create a dataview webpart": place your cursor inside a webpartzone and select from the main menu : Insert->SharePoint Controls ->Data View
option "convert to a dataview" : select the listview webpart which is already - right click - select in the context menu "Convert to a XSLT Data View". Make changes that you want to make it. Save it.
Here is you go - your xslt webpart on the page, but it's not deployable.
2. To make this webpart deployable we have to add it to the module feature. Prior to adding -we need at first import the web part. Go to the page with your webpart in the browser. Click on a right corner arrow and select "Import". I would prefer on this phase to test the webpart and export it back to the page.
Recently I have killed almost half of the day trying to figure out why the web part is broken after the module feature activation. If I had tested before, I would have known that's because imported webpart has a wrong value for a property (<property name="ViewFlag" type="string"></property>. I have deleted the value.)
Ok, as soon as the webpart can easily export back, you can proceed with the module feature.
Refer to detail explanation how to provision a file to msdn.
Let's assume that you have managed you way out and got you a module feature with the reference to a page you want to provision and element <AllUsersWebPart>. Let me just point it out that you have to put under this element <AllUsersWebpart> - <![CDATA[
{exported web part content starting with <webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">}]]>
Good deal! But it's still undeployable because the exported web part has a hard-coded value of the list Id.
Refer to out custom approach of an id replacement
Once you have handled the id replacement, you are fearless and with deployable xslt web part on your site.
No comments:
Post a Comment