Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render other components inside data-grid cells #484

Open
guiherzog opened this issue May 17, 2023 · 3 comments
Open

Render other components inside data-grid cells #484

guiherzog opened this issue May 17, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@guiherzog
Copy link

Feature request

I want to render a vscode-link component inside the cell of a data-grid? Is that possible? It currently show [object HTMLElement] for me.
image

Expected behavior

It renders the vscode-link tag.

Current behavior

It stringifies the element.

@guiherzog guiherzog added the enhancement New feature or request label May 17, 2023
@hawkticehurst
Copy link
Member

Hmmm 🧐 I want to say this should be possible, but this behavior would be stemming from FAST since they are responsible for the underlying implementation of the data grid base component.

Regardless, happy to do some snooping around the FAST code base and bubble up this question to the FAST folks if needed!

@hawkticehurst
Copy link
Member

Oh actually just so I have the full context, what does the code you have look like?

@guiherzog
Copy link
Author

Hi, sorry for the delay, I was OOO for a while.

So, if I try to create it through a static HTM, it works fine. I can render links, buttons, checkboxes inside of it. As seen on this example:
Screenshot 2023-07-14 at 13 07 54

Source Code:

<vscode-data-grid aria-label="Source Paths">
  <vscode-data-grid-row row-type="header">
    <vscode-data-grid-cell cell-type="columnheader" grid-column="1">Actions</vscode-data-grid-cell>
    <vscode-data-grid-cell cell-type="columnheader" grid-column="2">Source</vscode-data-grid-cell>
  </vscode-data-grid-row>
  <vscode-data-grid-row>
    <vscode-data-grid-cell grid-column="1"><vscode-checkbox>Select</vscode-checkbox></vscode-data-grid-cell>
    <vscode-data-grid-cell grid-column="2"><vscode-link href="">View</vscode-link></vscode-data-grid-cell>
  </vscode-data-grid-row>
  <vscode-data-grid-row>
    <vscode-data-grid-cell grid-column="1"><vscode-checkbox>Select</vscode-checkbox></vscode-data-grid-cell>
    <vscode-data-grid-cell grid-column="2"><vscode-link href="">View</vscode-link></vscode-data-grid-cell>
  </vscode-data-grid-row>
  <vscode-data-grid-row>
    <vscode-data-grid-cell grid-column="1"><vscode-checkbox>Select</vscode-checkbox></vscode-data-grid-cell>
    <vscode-data-grid-cell grid-column="2"><vscode-link href="">View</vscode-link></vscode-data-grid-cell>
  </vscode-data-grid-row>
</vscode-data-grid>

But if I try to dynamically create them and insert to the dataGrid.rowsData, it doesn't work, which is not surprising, but I am not sure how this should be done.
If I have this:

const checkbox = document.createElement('vscode-checkbox');
checkbox.textContent = 'Test';

const checkbox2 = new Checkbox();
checkbox2.textContent = 'Test 2';

document.body.append(checkbox, checkbox2);

document.getElementById('my-grid').rowsData = [
  { item1: 'value 1-2', item2: checkbox2 },
  { item1: 'value 1-3', item2: checkbox },
];

I get this:
Screenshot 2023-07-14 at 14 07 52

See this live example

I may be creating those elements in the wrong way, so I'd appreciate any advice if that's the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants