Skip to main content

DHTMLX Booking. Dialog info fields example

Live example​

After a slot is picked, the booking dialog repeats who and what the reservation is for. infoShape decides which of those fields the dialog carries. This demo switches off preview and price, so the block keeps the category, the name, and the address.

const widget = new booking.Booking("#root", {
	start: buildToday(),
    infoShape:{
        preview: false,
	    price: false,
    },
    data: dataset,
});

widget.setConfirmHandler(function(event){
    const { confirm } = event;
    setTimeout(() => {
        Math.random() < 0.5 ? confirm.error() : confirm.done();
    }, 1000);
});
<!-- component container -->
<div id="root" style="height:100%"></div>

<!-- dataset -->

<script>
function buildToday(){const params = new URLSearchParams(typeof location !== 'undefined' ? location.search : '');const fixed = params.get('fixedDate') || (typeof window !== 'undefined' && window.FIXED_DATE);return fixed ? new Date(fixed) : new Date();}

	const dataset = [
      {
        id: "ee828b5d-a034-420c-889b-978840015d6a",
        title: "Natalie Tyson",
        category: "Therapist",
        subtitle: "2 years of experience",
        details: "Cleveland Clinic\n9500 Euclid Ave",
        preview: "https://snippet.dhtmlx.com/codebase/data/booking/01/img/01.jpg",
        price: "$35",
        review: {
            stars: 4,
            count: 120,
        },
        slots: [
            {
                from: 9,
                to: 20,
                days: [1, 2, 3, 4, 5],
            },
            {
                from: 10,
                to: 18,
                days: [6, 0],
            },
        ],
    },
      {
        id: "5c9b64ad-1830-4e5b-a5f9-8acea10706df",
        title: "James Anderson",
        category: "Allergist",
        subtitle: "3 years of experience",
        details: "UCLA Medical Center\n57 Westwood Plaza",
        preview: "https://snippet.dhtmlx.com/codebase/data/booking/01/img/11.jpg",
        price: "$30",
        review: {
            stars: 4,
            count: 64,
        },
        slotSize: 45,
        slotGap: 10,
        slots: [
            {
                from: "9:15",
                to: 17,
                days: [1, 2, 3, 4, 5],
            },
        ],
    },
      // ... 44 more items (see Live Editor for full data)
    ];

function getDate(addDays, hoursValue = 0, minutesValue = 0) {
	const date = buildToday();
	const secondsValue = 0; // round to minutes
	const msValue = 0;

	date.setDate(date.getDate() + addDays);
	date.setHours(hoursValue, minutesValue, secondsValue, msValue);

	return date.getTime();
}
</script>

Use case​

The dialog is the last screen before a commitment. It should carry what the person is about to check and nothing else. In an internal tool the price often belongs to a different system. A preview image of a meeting room adds nothing once the room is chosen. What people reread here is the address and the name, which is what this configuration leaves in place. A shorter block also helps on a phone, where the form matters more than the preview above it.

How to do this in your app​

  • Pass the object: infoShape: { preview: false, price: false } removes those two fields from the dialog.
  • Use the five keys: preview, category, title, price, and details, all of which are on by default.
  • Name only what changes: keys you leave out keep showing, so a single false is a complete configuration.
  • Optional, rebuild the block: infoTemplate replaces it with your own HTML, as in the dialog info template demo.

Good to know​

  • The rating and the subtitle never reach the dialog: infoShape has no key for review or subtitle, so those two live on the card only.
  • The card and the dialog are configured apart: cardShape and infoShape take separate objects, so a field can stay on the card and disappear from the dialog.
  • A template overrides the shape: when infoTemplate is also set, it decides the content of the block and infoShape no longer applies.
  • The booked time always stays: the block prints the selected range as a start time, an end time, and a date. infoShape has no key for that line.

FAQ​

How do you hide the preview image in a booking confirmation dialog?​

Set infoShape to an object with preview: false. The rest of the fields keep their defaults, so nothing else changes.

What does the booking dialog show by default?​

The preview image, the category, the title, the price, and the details of the selected card, plus the booked time range, next to the form the visitor fills in.

Can a field be visible on the card but hidden in the dialog?​

Yes. cardShape controls the card list and infoShape controls the dialog, and neither one reads the other.

API reference​

Additional resources​