Link to home
Start Free TrialLog in
Avatar of tolppa
tolppa

asked on

SP2013 Sandbox: How to add listview webpart to page?

I wanted to create a module to provision an aspx page with few listview webparts. I have no problem if list exist in page, but seems like this does not work if list are provisioned from the same solution. Perhaps Sharepoint randomizes guids or something like that. Any Ideas?
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tolppa
tolppa

ASKER

I used sharepoint designer configured .aspx -file because it would make everything much easier. Apparently this does not work with views.

I created module that should create my page with views. Not too hard:

    <File Path="Pages\wkpstd.aspx" Url="MyTest.aspx"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" >
      <Property Name="WikiField" Type="string" Value="&lt;div class=&quot;ms-rtestate-read ms-rte-wpbox&quot; contentEditable=&quot;false&quot;&gt;&lt;div class=&quot;ms-rtestate-read 46113482-da36-45a5-bbac-e1e1771c19fa&quot; id=&quot;div_46113482-da36-45a5-bbac-e1e1771c19fa&quot;&gt;&lt;/div&gt;&lt;div style='display:none' id=&quot;vid_46113482-da36-45a5-bbac-e1e1771c19fa&quot;&gt;&lt;/div&gt;&lt;/div&gt; "/>
      <View List="Lists/MyList" BaseViewID="2" Type="HTML" WebPartZoneID="wpz" WebPartOrder="4" ID="g_46113482_da36_45a5_bbac_e1e1771c19fa" />
    </File>

Open in new window


Unfotunately I need more complex layout which can be created with:
<File Path="Pages\wkpstd.aspx" Url="mytest.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" >
<Property Name="WikiField" Value="&lt;table id=&quot;layoutsTable&quot; style=&quot;width:100%&quot;&gt;&lt;tbody&gt;&lt;tr style=&quot;vertical-align:top&quot;&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;div class=&quot;ms-rte-layoutszone-outer&quot; style=&quot;width:100%&quot;&gt;&lt;div class=&quot;ms-rte-layoutszone-inner&quot;&gt;&lt;/div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;vertical-align:top&quot;&gt;&lt;td style=&quot;width:49.95%&quot;&gt;&lt;div class=&quot;ms-rte-layoutszone-outer&quot; style=&quot;width:100%&quot;&gt;&lt;div class=&quot;ms-rte-layoutszone-inner&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;width:49.95%&quot;&gt;&lt;div class=&quot;ms-rte-layoutszone-outer&quot; style=&quot;width:100%&quot;&gt;&lt;div class='ms-rte-layoutszone-inner'&gt;&lt;/div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;vertical-align:top&quot;&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;div class=&quot;ms-rte-layoutszone-outer&quot; style=&quot;width:100%&quot;&gt;&lt;div class=&quot;ms-rte-layoutszone-inner&quot;&gt;&lt;/div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span id='layoutsData' style='display:none'&gt;true,true,2&lt;/span&gt;" />
</File>

Open in new window


I can see layout work correctly, but how do I add my views to page?  Something like:

Footer: <View List="Lists/MyList" BaseViewID="2" Type="HTML" WebPartZoneID="wpz" WebPartOrder="4" ID="g_46113482_da36_45a5_bbac_e1e1771c19fa" />

Left column (would be another view):  <View List="Lists/MyList" BaseViewID="2" Type="HTML" WebPartZoneID="wpz" WebPartOrder="4" ID="g_46113482_da36_45a5_bbac_e1e1771c19fa" />

(http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/)
Avatar of tolppa

ASKER

Interesting, seems like I can inject
&lt;div class=&quot;ms-rtestate-read ms-rte-wpbox&quot; contentEditable=&quot;false&quot;&gt;&lt;div class=&quot;ms-rtestate-read 46113482-da36-45a5-bbac-e1e1771c19fa&quot; id=&quot;div_46113482-da36-45a5-bbac-e1e1771c19fa&quot;&gt;&lt;/div&gt;&lt;div style='display:none' id=&quot;vid_46113482-da36-45a5-bbac-e1e1771c19fa&quot;&gt;&lt;/div&gt;&lt;/div&gt;

Open in new window


to my layout.
Avatar of tolppa

ASKER

No problem wiht single view, but seems like I am not able to add multiple views to different columns (table cells). SharePoint designer allow this.