Style sheet per user in one MX application.

In a APP we are building I want to be able to select a stylesheet per user. This is necessary because we have one app, but it will be used by several companies. Each company has it’s own style of colors/ font / fontsize / logo. Is there a way to connect a CSS file per user in Mx?
2 answers

Sure there is.

But you'll need to write some custom javascript and include it in your index.html

Some pointers how I would do it:

First I would include a stylesheet place holder in the html file:

<link rel="stylesheet" id="customer_specific_style" href="">

Next I would add a javascript section containing something like:

var id = $("#customer_name").attr("text");
$("#customer_specific_style").attr("href", id + ".css");

In the Mendix page layout I would include the name of the customer (in a dataview) and give it an id of ' customer_name'.

The javascript code will look for the id 'customer_name' and the text value will be used for the name of the stylesheet (without the extension) .

An other method would be adding javascript code which calls a microflow and updates the stylesheet based on the return value of the microflow.


We have a similar configuration. Each customer is an organization, all data is tied to that entity. Including data security with XPath constraints so users only see data of the organization they belong to.

Each organization can have a logo. Just an entity that is a specialization of System.Image, displayed in the topleft using a snippet. The snippet has a dataview with a microflow as datasource to get the organization and the logo of the organization that the user belongs to.

Each organization can have a custom color setting too. We allow the custom color only; allowing the customer to adjust font and/or font size can introduce layout problems for example texts that wont fit anymore. If you really need it I suppose it should be possible too. But you will need to have in depth knowledge of the Mendix theme/style. Or, as in our case, have Mendix create a custom theme for you.

We have no CSS per customer as that would require a deploy of the model with each new customer. Instead, we use the FormatString widget to output the additional styling, which is stored in the database with the organization.