Skip to main content

Deploying Custome XSLT in views

Sometimes it is nice to know how to use SharePoint Designer to create SharePoint elements. One such scenario is use of xslt to change style depending on a variable in a list example; set s color on the prices that are more than an amount on a list.
One thing is doing it in SharePoint designer on your local developer computer another is to translate that to a solution you can deploy.
In this example I’m using SharePoint designer to set a rule that says that if a price on an order list is higher than 600 the background color to be set to Red.

First I created the scenario in SharePoint Designer:
First create an Orders list as a Custom list and add a Column called price, make sure to have one test item. Then open the list in SharePoint Designer.








Here you can create the xslt by clicking on the All Items, then select a row in design view and select Conditional Formation. Do the formation that you need and save.






In code view look for the XSL tag and make a copy of the content of the xsl tagl.








Now open Visual studio and create a content type and a list definition. Then add a reference to the XSL folder under the layouts folder, create a folder with the project name and add a xslt file (I named mine *.xsl)








In the Shema.xml under one of the views replies the main.xsl with the path of the new xsl file. The path is relative to the XSL folder so in my case that is “DelpoyXSLT\CustomeXslt.xsl







Now test the solution.









Now you have made a custom xslt style in SharePoint Designer then deployed that into a view.

Comments

Popular posts from this blog

Getting the script folder in PowerShell

Today I needed to call another script file in the same folder as the main script. After a little searching on the web I found "$MyInvocation.MyCommand.Path". "$MyInvocation.MyCommand.Path" returns the path to the current script, With that I was able to get the current folder using Get-Item. This is my test scripts: ToRun.ps1: Write-Host $MyInvocation.MyCommand.Path $scriptDirectory  = (Get-Item $MyInvocation.MyCommand.Path).DirectoryName $scriptName = "HelloWorld.ps1" Write-Host calling $scriptName in $scriptDirectory & ($scriptDirectory + '\' + $scriptName) HelloWorld.ps1: Write-Host "Hello word" After running the script the output was: calling HelloWorld.ps1 in C:\scriptFun Hello word Simple but useful.

Using azure event gird with a function app

Introduction In this tutorial we will set up a simple azure event grid topic, with an function app as a subscriber to the topic. The function app will just log the messages, so we can se that it picked up the event. Setting things up First step is to create a resource group where we can add all the azure services we need az group create --name  myresourcegroup   --location norwayeast We need to set up a storage account that can be used bye the function app. az storage account create --name mystorageaccount --resource-group myresourcegroup --location eastus --sku Standard_LRS Now that we have a storage account we can make the function app. Here we will set it up to be able to run .Net 6 functions az functionapp create --name myFunctionApp --resource-group  myresourcegroup  --consumption-plan-location eastus --runtime dotnet --runtime-version 6.0 --functions-version 4 --storage-account  mystorageaccount...

Separate frontend 1: Trying to separate GUI layer and data business layer.

I have seen in some projects where I have been part of. The dependency injection is done in the presentation part of the application. That can be the API front or the GUI part like in a ASP.Net web application. The way this is done is to have some interfaces to separate the business from the data layers. Often by having the interfaces for them self in a separate project. Then the presentation layer references the business layer, interfaces and data layer, and connects it all together using dependency injection. This makes it easier to test, and change storage or parts of the application. As the injector can just inject new implementations of the interfaces.  But to me that feels like the presentation layer has two large responsibilities,  to present data and connect all the different parts together. What if you needed to change the presentation.  Then you would have to implement the injections also. You can't just switch out the presentation or add new ones. What if the o...