mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-13 01:54:52 +08:00
R=jacktfranklin@chromium.org Bug: 1187573 Change-Id: If6067534c72445c00878b1a90e3fd99abfb09d87 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2826291 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import * as DataGrid from '../../data_grid/data_grid.js';
|
|
import * as ComponentHelpers from '../../helpers/helpers.js';
|
|
|
|
await ComponentHelpers.ComponentServerSetup.setup();
|
|
|
|
const component = new DataGrid.DataGrid.DataGrid();
|
|
|
|
component.data = {
|
|
columns: [
|
|
{id: 'key', title: 'Key', widthWeighting: 1, visible: true, hideable: false},
|
|
{id: 'value', title: 'Value', widthWeighting: 1, visible: true, hideable: false},
|
|
],
|
|
rows: [{cells: [{columnId: 'key', value: 'foo', title: 'foo'}, {columnId: 'value', value: 'bar', title: 'bar'}]}],
|
|
activeSort: null,
|
|
};
|
|
|
|
document.getElementById('container')?.appendChild(component);
|
|
|
|
document.querySelector('#add')?.addEventListener('click', (event: Event) => {
|
|
event.preventDefault();
|
|
|
|
const key = Math.floor(Math.random() * 10);
|
|
const value = Math.floor(Math.random() * 10);
|
|
const randomDataRow = {
|
|
cells: [
|
|
{columnId: 'key', value: `Key: ${key}`, title: `Key: ${key}`},
|
|
{columnId: 'value', value: `Value: ${value}`, title: `Value: ${value}`},
|
|
],
|
|
};
|
|
|
|
component.data = {
|
|
...component.data,
|
|
rows: [...component.data.rows, randomDataRow],
|
|
};
|
|
});
|