Skip to content
New issue

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

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

Already on GitHub? # to your account

Add editCell to gridPro #3354

Closed
wants to merge 13 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PR -> comment #1
  • Loading branch information
roastedcpu committed Feb 7, 2022
commit 44efee134618fe5ab1a7f738c036d478765ac6ae
11 changes: 10 additions & 1 deletion packages/grid-pro/src/vaadin-grid-pro-inline-editing-mixin.d.ts
Original file line number Diff line number Diff line change
@@ -40,5 +40,14 @@ export declare class InlineEditingMixinClass {

protected _switchEditCell(e: KeyboardEvent): void;

public editCell(row: Number, col: Number, userOriginated: Boolean): void;
/**
* Triggers the editor for a given (row,col)
* row can be either a number (element index) or an object
* with the property 'key' = index+1 (e.g. {key: 1} is equivalent to pass it 0)
* column can be either a number (element index) or a string (columnId)
* @param {number|object} row
* @param {number|string} col
* @public
*/
editCell(row: number|object, col: number|string): void;
}
11 changes: 3 additions & 8 deletions packages/grid-pro/src/vaadin-grid-pro-inline-editing-mixin.js
Original file line number Diff line number Diff line change
@@ -456,16 +456,11 @@ export const InlineEditingMixin = (superClass) =>
}

/**
* @param {Number | String} row
* @param {Number | String} col
* @param {Boolean} userOriginated
* @param {number|object} row
* @param {number|string} col
* @public
*/
editCell(row, col, userOriginated) {
if (userOriginated && this.hasAttribute('disabled')) {
throw new Error('Grid is disabled.');
}

editCell(row, col) {
const columns = this._getColumns().filter((col) => !col.hidden);

let colIdx = -1;
19 changes: 4 additions & 15 deletions packages/grid-pro/test/edit-column-renderer.test.js
Original file line number Diff line number Diff line change
@@ -317,17 +317,6 @@ describe('edit column renderer', () => {
flushGrid(grid);
});

it('enter edit mode programatically should fail for user originated call when grid is disabled', () => {
grid.setAttribute('disabled', true);
expect(() => {
grid.editCell(10, 10, true);
}).to.throw(Error, 'Grid is disabled.');

expect(() => {
grid.editCell(0, 0, false);
}).to.not.throw(Error, 'Grid is disabled.');
});

it('enter edit mode programatically should fail for non-existing indexes', () => {
expect(() => {
grid.editCell(0, 10, false);
@@ -376,28 +365,28 @@ describe('edit column renderer', () => {
}).to.throw(Error, 'Column is not editable');
});

it('enter edit mode programatically (x,y) should call _startEdit', () => {
it('enter edit mode programatically (x,y) should show the editor', () => {
const cell = getContainerCell(grid.$.items, 0, 0);
grid.editCell(0, 0, false);
const editor = getCellEditor(cell);
expect(editor).to.be.ok;
});

it('enter edit mode programatically (x,colId) should call _startEdit', () => {
it('enter edit mode programatically (x,colId) should show the editor', () => {
const cell = getContainerCell(grid.$.items, 0, 0);
grid.editCell(0, 'name', false);
const editor = getCellEditor(cell);
expect(editor).to.be.ok;
});

it('enter edit mode programatically (rowKey,y) should call _startEdit', () => {
it('enter edit mode programatically (rowKey,y) should show the editor', () => {
const cell = getContainerCell(grid.$.items, 0, 0);
grid.editCell({ key: 1 }, 0, false);
const editor = getCellEditor(cell);
expect(editor).to.be.ok;
});

it('enter edit mode programatically (rowKey,colId) should call _startEdit', () => {
it('enter edit mode programatically (rowKey,colId) should show the editor', () => {
const cell = getContainerCell(grid.$.items, 0, 0);
grid.editCell({ key: 1 }, 'name', false);
const editor = getCellEditor(cell);