You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also configure the appearance of a card using the [`cardTemplate`](/api/config/booking-cardTemplate) property. If both `cardTemplate` and `cardShape` are applied, `cardTemplate` will override the `cardShape` settings.
74
+
:::
75
+
76
+
**Related articles:**
77
+
78
+
-[Defining the structure of cards](/guides/configuration/#defining-the-structure-of-cards)
description: You can learn about the cardTemplate config in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
5
+
---
6
+
7
+
# cardTemplate
8
+
9
+
### Description
10
+
11
+
@short: Optional. Allows applying a template to a card's left block
12
+
13
+
The property specifies the HTML structure and layout of each card's block (the left side of each card). It means you can manage which fields are displayed, how they are arranged, and how they look.
14
+
15
+
:::info
16
+
You can also specify which fields to display using the [`cardShape`](/api/config/booking-cardshape) property
17
+
:::
18
+
19
+
### Usage
20
+
21
+
~~~jsx {}
22
+
cardTemplate?: (item:obj) => string;
23
+
~~~
24
+
25
+
### Parameters
26
+
27
+
`cardTemplate` expects a function that takes a `card` object as input and returns a string of HTML that defines how the card should look.
28
+
29
+
### Example
30
+
31
+
In the example below we create a function that takes the card object and returns HTML for a card (that includes a preview image (card.preview), category (card.category), title (card.title), and price (card.price)). You need to create your own HTML template to be applied to a card. Pass the function into the Booking configuration by assigning the function to the `cardTemplate` property.
You can also control which fields to display in the information block of the Booking dialog using the [`infoTemplate`](/api/config/booking-infotemplate) property. But if both properties are applied, `infoTemplate` will override the `infoShape` settings.
68
+
:::
69
+
70
+
**Related articles:**
71
+
72
+
-[Configuring the Booking dialog](/guides/configuration/#configuring-the-booking-dialog)
description: You can learn about the infoTemplate config in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
5
+
---
6
+
7
+
# infoTemplate
8
+
9
+
### Description
10
+
11
+
@short: Optional. Allows applying a template to the information block in the Booking dialog
12
+
13
+
### Usage
14
+
15
+
~~~jsx {}
16
+
infoTemplate?: (item:obj, slot:obj) => string;
17
+
~~~
18
+
19
+
### Parameters
20
+
21
+
`infoTemplate` takes the `card` item object and selected `slot` object as input and returns a string of HTML.
22
+
23
+
24
+
### Example
25
+
26
+
In the example below, we define the `customInfoTemplate` function that will generate the custom HTML for the information block. This function will receive the `selectedItem` (card) and the `formattedDate` (slot) as input parameters. The function returns div containers representing the information block for a selected booking item, including an image, price, category, title, and formatted date. We also assign our custom function to `infoTemplate`.
You can also control which fields to display in the information block of the Booking dialog using the [`infoShape`](/api/config/booking-infoshape) property. But if both properties are applied, `infoTemplate` will override the `infoShape` settings.
65
+
:::
66
+
67
+
**Related articles:**
68
+
69
+
-[Configuring the Booking dialog](/guides/configuration/#configuring-the-booking-dialog)
Copy file name to clipboardExpand all lines: docs/guides/configuration.md
+146-2Lines changed: 146 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,13 @@ To load data, add data to the [`data`](/api/config/booking-data) array. See all
12
12
13
13
## Defining the structure of cards
14
14
15
-
You can configure what information all cards will display on their left side using the [`cardShape`](/api/config/booking-cardshape) property.
15
+
You can configure what information all cards will display on their left side using the [`cardShape`](/api/config/booking-cardshape) property or the [`cardTemplate`](/api/config/booking-cardtemplate) property, which also allows customizing the appearance of each card's block.
16
16
17
-
On the left side of a card the following data fields are displayed by default:
17
+
:::info
18
+
Both properties allow you to control which fields to display in a card's left-hand block. But `cardTemplate` also helps tailor the appearance of each card and control how the fields are arranged. If both are applied, `cardTemplate` will override the `cardShape` settings.
19
+
:::
20
+
21
+
On the left side of each card the following data fields are displayed by default:
18
22
- preview: card image
19
23
- review: rating information with the number of rating stars (out of five) and the number of reviews
20
24
- category: the subtitle of a card
@@ -65,6 +69,66 @@ new booking.Booking("#root", {
65
69
Please, see an example in the [snippet tool](https://snippet.dhtmlx.com/6mxd7918)
66
70
:::
67
71
72
+
To apply a template to each card (the left-hand block), use the [`cardTemplate`](/api/config/booking-cardtemplate) property.
73
+
74
+
First, create a function that takes a card object and returns a string of HTML. In the example, `cardPreviewTemplate` returns HTML for a card that includes a preview image (card.preview), category (card.category), title (card.title), and price (card.price). To add new fields to a card, modify the template string. In the example below, we add `<div class="">` blocks inside the `cardPreviewTemplate` function.
If you want add some look and feel to your card, you should add styles to your CSS:
109
+
110
+
~~~css
111
+
.custom-preview {
112
+
display: flex;
113
+
width: 100%;
114
+
height: 100%;
115
+
gap: 30px;
116
+
}
117
+
118
+
.preview-left {
119
+
width: auto;
120
+
display: flex;
121
+
flex-direction: column;
122
+
gap: 4px;
123
+
}
124
+
// other styles
125
+
~~~
126
+
127
+
TBD!!!
128
+
:::info
129
+
Please, see an example in the [snippet tool](https://snippet.dhtmlx.com)
130
+
:::
131
+
68
132
## Filling cards with slots
69
133
70
134
Aslot is atime unit available for booking. Available slots for cards are displayed for the next five days starting from the current day or from the start date from the filter.
@@ -364,6 +428,86 @@ new booking.Booking("#root", {
364
428
Please, see an example in the [snippet tool](https://snippet.dhtmlx.com/pd6wp1xc)
365
429
:::
366
430
431
+
You can also apply a template using the [`infoTemplate`](/config/booking-infotemplate) property that allows managing the fields in the information block of the Booking dialog. Both [`infoTemplate`](/config/booking-infotemplate) and [`infoShape`](/api/config/booking-infoshape) properties allow you to define which fields to display. But `infoTemplate` also helps tailor the appearance of the information block. If both are applied, `infoTemplate` will override the `infoShape` settings.
432
+
433
+
To apply a template, first, you need to define the function that will generate the custom HTML for the information block. This function will receive the card and slot objects as input parameters, which are `selectedItem` (card) and `formattedDate` (slot) in the example below. To add more fields, add `<div class="">` blocks inside the `customInfoTemplate` function:
0 commit comments