QlikView for Developers Cookbook
上QQ阅读APP看书,第一时间看更新

Using the design menus to custom format a cell

There are two design menus that can appear when you right-click an object on the layout. They are:

  • Order: This is applicable to all objects, and this menu has a submenu that allows you to adjust the Layer of an object.
  • Custom Format Cells: This is applicable only to the three grid objects (Table Box, Straight Table, and Pivot Table), and this menu allows you to apply your own custom color, border, and font options to a cell.

These menu items do not appear by default. There are two ways of making them available. You can either turn on the Design Grid option (from the View menu), or you can turn them on by changing your User Preferences, which we will do in this recipe.

Getting ready

Load the following script:

Load * Inline [
  Country, Sales, Costs
  USA, 1203, 1043
  UK, 987, 995
  France, 1118, 1022
  Germany, 876, 754
];

How to do it…

Use the following steps to custom format a cell in the table:

  1. Create a straight table with Country as dimension and add the following three expressions:
  2. Click on Finish to save the chart.
  3. From the Settings menu, select User Preferences and click on the Design tab.
  4. Click on the Always Show Design Menu Items option and click on OK.
  5. Right-click on one of the Total Margin values for a country (for example, 160 for USA) and select Custom Format Cell from the menu.
  6. Click on the Background Color button and change the Base Color, Fixed to an RGB value of 245, 245, and 245. Set the Apply change to option to Current Expression and click on OK.
  7. Right-click on the total value for Total Margin (in this case, 370) and select Custom Format Cell. Set the Text Size to 120 % and turn on the Italic checkbox. Click on OK to make the change.
  8. Similarly, right-click on one of the countries (for example, Germany) and select Custom Format Cell. Turn on the Bold option and click on OK:
  9. Edit the properties of the chart and go to the Style tab. Note that the Current Style is set to [Custom].

How it works…

This is quite simple, turning on the option in the User Preferences allows us to see the menu and that then allows us to make custom format changes to our tabular chart.

There's more…

If you change the Current Style option in the chart properties to one of the preset styles, it will remove all your custom settings.