// Button click event function
assignPanel() {
// Local data is used here, you can replace it with the data returned from server
this.panels = [
{ "sizeX": 1, "sizeY": 1, "row": 0, "col": 0, content: '<div class="content">0</div>' },
{ "sizeX": 3, "sizeY": 2, "row": 0, "col": 1, content: '<div class="content">1</div>' },
{ "sizeX": 1, "sizeY": 1, "row": 0, "col": 4, content: '<div class="content">2</div>' },
{ "sizeX": 1, "sizeY": 1, "row": 1, "col": 0, content: '<div class="content">3</div>' },
{ "sizeX": 1, "sizeY": 1, "row": 1, "col": 4, content: '<div class="content">4</div>' },
];
// Assign the panels data to the dashboard layout’s panel property
this.dashboardObject.panels = this.panels;
} |
addPanel() {
// Local data is used here, you can replace it with the data returned from server
let panel: PanelModel[] = [{
id: 'panel_0' + this.count.toString(), 'sizeX': 1, 'sizeY': 1, 'row': 0, 'col': 0,
content: '<div class="content">0' + this.count.toString() + '</div>'
}];
this.dashboardObject.addPanel(panel[0]);
// Here count is used simply for calculating the total panels dynamically added
this.count++;
} |
this.panels = [
{ "id": ’panel_0’, "sizeX": 1, "sizeY": 1, "row": 0, "col": 0, content: '<div class="content">0</div>' },
] |
let panels: PanelModel[] = this.dashboardObject.panels;
while (i < panels.length) {
// Check panels using its id
if (this.dashboardObject.panels[i].id === "panel_0") {
// Update the panel data
panels[i] = [{ id: "panel_0", "sizeX": 1, "sizeY": 1, "row": 0, "col": 0, content: '<div class="content">01</div>' }]
break;
}
i++;
}
this.dashboardObject.panels = panels; |