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

Editing Cells #20

Closed
crberube opened this issue Jan 23, 2021 · 6 comments
Closed

Editing Cells #20

crberube opened this issue Jan 23, 2021 · 6 comments
Assignees

Comments

@crberube
Copy link

After following the initial setup steps under the HTML/CSS Prerequisites and the code from the using section of the README, I am not able to enter the editing mode by clicking on a cell. In the DOM the portal element is not changing.

Is there something that I need to enable in order to allow for the editing UI when clicking on a cell? I am using an EditableGridCell. If I set allowOverlay to true I do get an editable box which appears to work as expected.

@jassmith
Copy link
Contributor

Can you show me your code?

@jassmith jassmith self-assigned this Jan 24, 2021
@crberube
Copy link
Author

Sure. I was trying to get a feel for things by following the example code in the repo.

Main body looks as follows:

<body>
...
<div id="portal" />
</body

I have set the columns as follows:

 const columns: GridColumn[] = [
        { title: 'Number', width: 100 },
        { title: 'Square', width: 100 },
    ]

defined the data editor container:

 <DataEditorContainer width={500} height={300}>
            <DataEditor
                getCellContent={getData}
                columns={columns}
                rows={1000}
            />
        </DataEditorContainer>

and the getData function:

function getData([col, row]: readonly [
    number,
    number
]): EditableGridCell {
    let n: number
    if (col === 0) {
        n = row
    } else if (col === 1) {
        n = row * row
    } else {
        throw new Error('This should not happen')
    }
    return {
        kind: GridCellKind.Number,
        data: n,
        displayData: n.toString(),
        allowOverlay: false,
    }
}

I am able to select cells fine, but the <input> elements do not appear. When changing allowOverlay to true I am able to edit in the overlay input box but the value in the cell does not change.

@jassmith
Copy link
Contributor

Oh okay yes, sorry I thought your question was something else.

Set allowOverlay to true for cells you want to be editable. Then hook up the onCellEdited callback in your DataEditor and make sure your cells content gets updated correctly.

@crberube
Copy link
Author

Great thank you for the clarification.

Should the overlay be placed directly over the cell being edited by default? I am seeing behavior where it opens a few cells above such as in #17 (but on desktop). I do not see this behavior on desktop when using the demo.

@jassmith
Copy link
Contributor

Can you check and make sure your portal is positioned at 0,0? Maybe the portal is somehow being offset?

@jassmith
Copy link
Contributor

Also just a working example I could look at would be very helpful

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

No branches or pull requests

2 participants