# Advanced Layout

You can use the layout property to define advanced header and record layouts.
(In this case, the header property cannot be used.)

The layout property is defined by an object with the header and the body. Define an array of rows in each section, and define each element in a row.

When using the layout property, you can set colSpan and rowSpan for each definition element.

For example:

<div class="sample-layout demo-grid middle"></div>
1
const grid = new cheetahGrid.ListGrid({
  parentElement: document.querySelector(".sample-layout"),
  layout: {
    header: [
      // header line1
      [
        { caption: "ID", width: 100, rowSpan: 2 },
        { caption: "First Name", width: 200 },
        { caption: "Email", width: 250, rowSpan: 2 },
        { caption: "Birthday", width: 200, rowSpan: 2 },
      ],
      // header line2
      [{ caption: "Last Name" }],
    ],
    body: [
      // line1
      [
        { field: "personid", rowSpan: 2 },
        { field: "fname" },
        { field: "email", rowSpan: 2 },
        { field: getBirthday, rowSpan: 2 },
      ],
      // line2
      [{ field: "lname" }],
    ],
  },
  frozenColCount: 1,
});
grid.records = records;

function getBirthday(rec) {
  const dateTimeFormat = new Intl.DateTimeFormat("en-US", {
    year: "numeric",
    month: "numeric",
    day: "numeric",
  });
  return dateTimeFormat.format(rec.birthday);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Last Updated: 10/23/2024, 6:31:33 AM