|
1 | 1 | --- |
2 | | -description: Configuring count cards in Umbraco UI Builder, the backoffice UI builder for Umbraco. |
| 2 | +description: Learn how to configure count cards in Umbraco UI Builder. |
3 | 3 | --- |
4 | 4 |
|
5 | 5 | # Count Cards |
6 | 6 |
|
7 | | -Count cards allow you to define cards directly against the [collection](../collections/overview.md) configuration, providing a basic **where clause** to use in a count SQL statement. These work perfectly for basic data visualizations based on counts of entities in a collection. |
| 7 | +Count cards allow you to define cards directly against the [Collection](../collections/overview.md) configuration, providing a basic **where clause** to use in a count SQL statement. These work perfectly for basic data visualizations based on counts of entities in a collection. |
8 | 8 |
|
9 | | -If you need to do more than a basic count, you'll want to take a look at the [custom cards](custom-cards.md) documentation. |
| 9 | +If you need to do more than a basic count, see the [Custom Cards](custom-cards.md) article. |
10 | 10 |
|
11 | | -## Adding a count card to a collection |
| 11 | +## Adding a Count Card to a Collection |
12 | 12 |
|
13 | | -Cards allow you to display basic summaries of key information that may be useful to the editor. |
| 13 | +Count cards display basic summaries of key information that may be useful to the editor. |
14 | 14 |
|
15 | | -### **AddCard(string name, Lambda whereClauseExpression, Lambda cardConfig = null) : CardConfigBuilder** |
| 15 | +### Using the `AddCard()` Method |
16 | 16 |
|
17 | | -Adds a card with the given name and **where clause** filter expression. Expression must be a `boolean` expression. |
| 17 | +Adds a count card with the specified name and a where clause filter expression. The filter expression must be a `boolean` value. |
| 18 | + |
| 19 | +#### Method Syntax |
| 20 | + |
| 21 | +```cs |
| 22 | +AddCard(string name, Lambda whereClauseExpression, Lambda cardConfig = null) : CardConfigBuilder |
| 23 | +``` |
| 24 | + |
| 25 | +#### Example |
18 | 26 |
|
19 | 27 | ````csharp |
20 | | -// Example |
21 | 28 | collectionConfig.AddCard("Older than 30", p => p.Age > 30, cardConfig => { |
22 | 29 | ... |
23 | 30 | }); |
24 | 31 | ```` |
25 | 32 |
|
26 | | -### **AddCard(string name, string icon, Lambda whereClauseExpression, Lambda cardConfig = null) : CardConfigBuilder** |
| 33 | +### Using the `AddCard()` Method with Icon |
| 34 | + |
| 35 | +Adds a count card with the specified name, an icon, and a where clause filter expression. The filter expression must be a `boolean` value. |
27 | 36 |
|
28 | | -Adds a card with the given name + icon and **where clause** filter expression. Expression must be a `boolean` expression. |
| 37 | +#### Method Syntax |
| 38 | + |
| 39 | +```cs |
| 40 | +AddCard(string name, string icon, Lambda whereClauseExpression, Lambda cardConfig = null) : CardConfigBuilder |
| 41 | +``` |
| 42 | + |
| 43 | +#### Example |
29 | 44 |
|
30 | 45 | ````csharp |
31 | | -// Example |
32 | 46 | collectionConfig.AddCard("Older than 30", "icon-umb-users", p => p.Age > 30, cardConfig => { |
33 | 47 | ... |
34 | 48 | }); |
35 | 49 | ```` |
36 | 50 |
|
37 | | -### Change the color of a count card |
| 51 | +### Change the Color of a Count Card |
| 52 | + |
| 53 | +#### Using the `SetColor()` Method |
| 54 | + |
| 55 | +Sets the color for the count card. |
38 | 56 |
|
39 | | -#### **SetColor(string color) : CardConfigBuilder** |
| 57 | +#### Method Syntax |
40 | 58 |
|
41 | | -Sets the color of the card. |
| 59 | +```cs |
| 60 | +SetColor(string color) : CardConfigBuilder |
| 61 | +``` |
| 62 | + |
| 63 | +#### Example |
42 | 64 |
|
43 | 65 | ````csharp |
44 | | -// Example |
45 | 66 | cardConfig.SetColor("blue"); |
46 | 67 | ```` |
47 | 68 |
|
48 | | -### Add a suffix to a count value |
| 69 | +### Add a Suffix to a Count Value |
| 70 | + |
| 71 | +#### Using the `SetSuffix()` Method |
| 72 | + |
| 73 | +Sets a suffix to be displayed alongside the card value.d |
| 74 | + |
| 75 | +#### Method Syntax |
49 | 76 |
|
50 | | -#### **SetSuffix(string suffix) : CardConfigBuilder** |
| 77 | +```cs |
| 78 | +SetSuffix(string suffix) : CardConfigBuilder |
| 79 | +``` |
51 | 80 |
|
52 | | -Sets the suffix of the card value. |
| 81 | +#### Example |
53 | 82 |
|
54 | 83 | ````csharp |
55 | | -// Example |
56 | 84 | cardConfig.SetSuffix("years"); |
57 | 85 | ```` |
58 | 86 |
|
59 | | -### Formatting the value of a count |
| 87 | +### Formatting the Value of a Count |
| 88 | + |
| 89 | +#### Using the `SetFormat()` Method |
| 90 | + |
| 91 | +Sets a custom format for the card's value. |
| 92 | + |
| 93 | +#### Method Syntax |
60 | 94 |
|
61 | | -#### **SetFormat(Lambda formatExpression) : CardConfigBuilder** |
| 95 | +```cs |
| 96 | +SetFormat(Lambda formatExpression) : CardConfigBuilder |
| 97 | +``` |
62 | 98 |
|
63 | | -Sets the format expression for the card. |
| 99 | +#### Example |
64 | 100 |
|
65 | 101 | ````csharp |
66 | | -// Example |
67 | 102 | cardConfig.SetFormat((v) => $"{v}%"); |
68 | 103 | ```` |
0 commit comments