it is a big question since long time and now I am facing it....
I have to add list view web part through CAML to publish page.
I have used the code:
<View List="0GeneralInformationandReports" RowLimit="5" FreeForm="TRUE"
BaseViewID="0"
RecurrenceRowset="TRUE"
WebPartZoneID="bottomLeft_LeftZone"
WebPartOrder="1">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title">0 - General Information and Reports</property>
<property name="AllowConnect" type="bool">True</property>
<property name="AllowClose" type="bool">False</property>
<property name="Height" type="unit">215px</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</View>
and it is rendering fine with the list view on the page. But i have to add more control to the web part like show only limited columns and top 5 modified by date ascending. This is not working using the tag as there are no other ways I can add sorting, view fields etc...
please help.
I have tried that and still it is not working. This is my list view in schema.xml.
<View DisplayName="" BaseViewID="0" Type="HTML" MobileView="TRUE" ImageUrl="/_layouts/images/dlicon.png" Hidden="TRUE" XslLink="main.xsl"
WebPartZoneID="bottomLeft_LeftZone" WebPartOrder="0">
<XslLink>main.xsl</XslLink>
<Query />
<ViewFields>
<FieldRef Name="DocIcon" />
<FieldRef Name="LinkFilenameNoMenu" />
</ViewFields>
<RowLimit>5</RowLimit>
<Aggregations Value="Off" />
</View>
</Views>
Still it is showing the same fields... No ideas how to get to it... I have referenced BaseView="0" in the of my elements.xml. Still no luck.
To do that, you'll probably have to define a new View in your List Definition, and then use BaseViewID to specify the new view by that ID.
Related
I'm trying to add some provisioning function to my SPfx WebPart Project on SharePoint Online. The Problem is that as soon as I put the feature information to my package-solution.json the configured lists deploy properly but I can't add the WebPart itself on a Sitepage.
I'm working with Visual Studio Code on a SPfx WebPart Project for SharePoint Online. I already deployed a variety of WebParts an Extensions within our Companys' tenant but I'm pretty new to the thing with features and assets.
My WebPart needs two specific lists which it should deploy by itself when added to the site contents per [New] -> [App].
Therefore I added an elements.xml and two schema-*.xml files to my project and modified the package-solution.json to include them as a feature.
Since then the Lists a deployed properly to the SiteCollection or SubSite where I add the App.
BUT(!) the WebPart itself doesn't show up when editing a SitePage and adding WebParts. Its not even in the popup where you select the WebPart you want.
There are no Install Errors when adding the App too the SiteCollection and the WebPart works well when the feature information is deleted from the package-solution.json.
And here I am, having no clue what's wrong and needing your help.
package-solution.json
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "sp-bookingtool-admin",
"id": "30d57d62-8319-4b29-b0f9-***********",
"version": "2.0.0.6",
"features": [
{
"title": "sp-bookingtool-admin-features",
"description": "asset-deployment-webpart-client-side-solution",
"id": "523fe887-ced5-4036-b564-***********",
"version": "2.0.0.6",
"assets": {
"elementManifests": [
"elements.xml"
],
"elementFiles": [
"schema-sessions.xml",
"schema-courses.xml"
]
}
}
]
},
"paths": {
"zippedPackage": "solution/sp-bookingtool-admin.sppkg"
}
}
elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance
CustomSchema="schema-sessions.xml"
FeatureId="00bfea71-de22-43b2-a848-***********"
Title="BookingTool-Sessions"
Description="BookingTool-Sessions"
TemplateType="100"
Url="Lists/BookingToolSessions">
</ListInstance>
<ListInstance
CustomSchema="schema-courses.xml"
FeatureId="00bfea71-de22-43b2-a848-***********"
Title="BookingTool-Courses"
Description="BookingTool-Courses"
TemplateType="100"
Url="Lists/BookingToolCourses">
</ListInstance>
</Elements>
1 of two schema.xml
<List xmlns:ows="Microsoft SharePoint" Title="BookingTool-Courses" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/BookingToolCourses" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<Fields>
<Field ID="{1e513910-8092-45f7-b996-***********}" Name="Text_1" Type="Text" DisplayName="Text_1" Group="" Required="TRUE"/>
<Field ID="{d82721d4-0b3c-48cf-9a24-***********}" Name="Text_2" Type="Text" DisplayName="Text_2" Group="" Required="TRUE"/>
</Fields>
<Views>
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Standard" />
<ViewFields>
<FieldRef Name="LinkTitle"></FieldRef>
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="LinkTitle" />
</OrderBy>
</Query>
</View>
</Views>
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
</MetaData>
</List>
Thanks to a collegue I found the error by myself.
Against my expectation the "FeatureID" in the ListInstances is NOT a GUID of the developed feature BUT the ID of the Listtemplate you use depending of the "TemplateType".
<ListInstance
CustomSchema="schema-sessions.xml"
FeatureId="00bfea71-de22-43b2-a848-c05709900100"
Title="BookingTool-Sessions"
Description="BookingTool-Sessions"
TemplateType="100"
Url="Lists/BookingToolSessions">
</ListInstance>
00bfea71-de22-43b2-a848-c05709900100 is the ID for Custom Lists and
100 is the Templatetype for that List.
Following is a sample of the metadata that is returned by my odata endpoint. I am using the endpoint w/ Microsoft Excel Power Query. All is working OK, except that I want to change the displayed name of "MyTable" below to something else, like say "My Cool Table".
I have tried adding annotations, but anytime I add annotations, Excel throws a cryptic error that says my metadata is invalid.
The question is, given the OData XML metadata below, what do I need to add so that the name of the table that is displayed is "My Cool Table" instead of "MyTable".
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
<edmx:DataServices xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" m:MaxDataServiceVersion="4.0" m:DataServiceVersion="4.0">
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="MyOData">
<EntityType Name="MyTable">
<Key>
<PropertyRef Name="myid" />
</Key>
<Property Name="myid" Type="Edm.String" Nullable="false" />
<Property Name="Anotherfield" Type="Edm.String" />
</EntityType>
<EntityContainer Name="DefaultContainer">
<EntitySet Name="MyTable" EntityType="MyOData.MyTable" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
I have added a content type in my custom orchard recipe but when I try to create an instance of that content type within the recipe nothing happens.
Declaration:
<Metadata>
<Types>
<Speedbump ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" TypeIndexing.Indexes="Search">
<TitlePart />
<BodyPart />
<CommonPart />
</Speedbump>
</Types>
<Parts>
<BodyPart BodyPartSettings.FlavorDefault="html" />
</Parts>
</Metadata>
Creation:
<Command>
Speedbump create /Slug:"valid-url" /Title:"Valid URL" /Path:"valid-url" /Homepage:false /Publish:true /UseWelcomeText:false
</Command>
Any ideas as to why this isn't working? I can go into the site after it is created and my speedbump type is defined and creatable but the instance that should have been created by the recipe doesn't exist. Thank you.
This isn't how you create content items in recipes. You add xml in the <Data> tag like so:
<Data>
<Speedbump Id="" Status="Published">
<BodyPart Text="Hello this needs to be encoded" />
<CommonPart Owner="/User.UserName=admin" CreatedUtc="2014-09-05T16:09:13Z" PublishedUtc="2014-09-05T16:15:43Z" ModifiedUtc="2014-09-05T16:15:43Z" />
<TitlePart Title="My Page" />
</Speedbump>
</Data>
For any custom parts, you will need to implement Import and Export functions in your driver method. Check core modules for good examples
I am developing a class where I wish to databind the attributes of a class to a dataset.
I have managed to get the following to work in the following simplified version of my class:
<class name="myclass">
<dataset name="attSettings"><settings>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</settings></dataset>
<attribute name="default_applyshadow" type="boolean" value="$once{(this.attSettings.getPointer()).xpathQuery('settings/property[#name="applyshadow"]/#defaultvalue')}" />
</class>
However, this syntax is very cumbersome and does not feel right so I am wondering if there is a better way to do this.
This doesn't answer your question but explains why you cannot use a local dataset in your situation. When you have a local dataset in a class, the dataset can only be addressed in children of the class, e.g.:
<canvas debug="true">
<class name="myclass">
<dataset name="myds">
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<text datapath="local:classroot.myds:/root/property[#name='applyshadow']/#defaultvalue" />
</class>
<myclass />
</canvas>
The <text> element can access the dataset of the parent class by prepending local: to the datapath value. If you don't select a name for your dataset, OpenLaszlo will automatically use the name localdata for the dataset. Datasets using that name can be addressed by omitting the dataset name in the datapath/xpath value, e.g.
<class name="myclass">
<dataset>
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<text datapath="local:classroot:/root/property[#name='applyshadow']/#defaultvalue" />
</class>
Note that the datapath does not have a name and that the datapath used for the <text> component is now local:classroot:/root/..., while local:classroot.localdata:/root/... would work as well.
I don't understand the design decision which makes it impossible to allow the use a local dataset in the datapath of a class containing that dataset, but maybe there were some technical reasons (initialization order, etc.) for it.
I figured out the proper syntax to do what I wanted:
<dataset name="myclass_settings">
<root>
<property name="applyshadow" defaultvalue="false" type="boolean" />
</root>
</dataset>
<class name="myclass" datapath="myclass_settings:/root">
<attribute name="default_applyshadow" type="boolean" value=$path{'property[#name="applyshadow"]/#defaultvalue'}" />
</class>
The $path{} constraint is used on the class attribute to link the value to the dataset via a relative xpath query. I also had to move the dataset outside of the class to get it to work.
I'm trying to format a field in a BDC (Business Data Catalog) definition, in SharePoint, with a thousand separator.
It doesn't appear to be possible in the BDC XML definition, and only possible through the SharePoint Designer(!). The fields I've got at present are System.Decimal, so it displays as 12345.98, but I'm wanting it to display as 12,345.98.
Do you know if it can be achieved through the BDC XML Definition ?
<Parameter Direction="Return" Name="#ContactTotals">
<TypeDescriptor TypeName="System.Data.IDataReader, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" IsCollection="true" Name="Reader">
<TypeDescriptors>
<TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Record">
<TypeDescriptors>
<TypeDescriptor TypeName="System.Int32" IdentifierName="dim_claims_key" Name="dim_claims_key" />
<TypeDescriptor TypeName="System.Decimal" Name="total_outstanding" DefaultDisplayName="Total Outstanding (USD)" />
<TypeDescriptor TypeName="System.Decimal" Name="total_paid" DefaultDisplayName="Total Paid (USD)" />
<TypeDescriptor TypeName="System.Decimal" Name="total_incurred" DefaultDisplayName="Total Incurred (USD)" />
</TypeDescriptors>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</Parameter>
</Parameters>
Cheers
Nick
XML is a meta-language not intended to format or present information, it describes and stores other vocabularies. That in mind, the answer is: No, you cannot achieve what you asked using XML only.
A recommended way would be to use the XSLT <xsl:decimal-format /> element in the BDC List View or BDC Item View webpart you are using. If you are consuming the data trough other ways you can easily format the output during rendering.
Say you have this portion of code displaying your decimal type:
<xsl:value-of select="$ColName_0" />
You need to encapsulate it with something like (based on the sample in the link):
<xsl:value-of select="format-number($ColName_0, '#.###,00', 'euro')"/>
You can find the XSLT for the webpart in the Modify Shared WebPart menu, or, as you said, using SharePoint Designer.
Seems possible to define Complex Formatting at TypeDescriptor elements. As I don't have an environment to properly test this solution, following definitions seems to be valid and addresses your particular scenario:
<Parameter Direction="Return" Name="#ContactTotals">
<TypeDescriptor TypeName="System.Data.IDataReader, ..."
IsCollection="true" Name="Reader">
<!-- note this -->
<Properties>
<Property Name="ComplexFormatting"
Type="System.String" />
</Properties>
<TypeDescriptors>
<TypeDescriptor TypeName="System.Data.IDataRecord, ..." Name="Record">
<TypeDescriptors>
<TypeDescriptor TypeName="System.Int32"
IdentifierName="dim_claims_key"
Name="dim_claims_key" />
<TypeDescriptor TypeName="System.Decimal"
Name="total_outstanding"
DefaultDisplayName="Total Outstanding (USD)" />
<!-- note this -->
<Properties>
<Property Name="FormatString"
Type="System.String">{0:#.###,00}</Property>
</Properties>
</TypeDescriptor>
...
</TypeDescriptors>
</TypeDescriptor>
</TypeDescriptors>
</TypeDescriptor>
</Parameter>
</Parameters>
Note as warned in MSDN documentation, "ComplexFormatting is slow". Maybe is better to stick with F.Aquino answer