when my selection caret is in a cell, I can retrieve some cell's informations in the SelectionCellFormat property like margins, but there is no information about cell's borders, where can I found it? |
Currently, document doesn’t provide border information’s on selection cell format. We are validating on this. We will update further details on this by March 13, 2020. |
Second question, programmatically I would like to loop in each cells of a selected table, is it possible to do that? the purpose is to insert an image in each cell. |
Currently, document editor doesn’t provide any API to navigate cells. Can you please share your usecase scenario in detail? This will be helpful for us to provide better solution at earliest. |
function moveCursorToCellStart(selection: Selection): Boolean {
if (selection.contextType.includes('Table')) {
selection.selectCell();
selection.select(selection.startOffset, selection.startOffset);
return true;
}
return false;
}
function moveCursorToCellEnd(selection: Selection): Boolean {
if (selection.contextType.includes('Table')) {
selection.selectCell();
selection.select(selection.endOffset, selection.endOffset);
return true;
}
return false;
}
function moveCursorToNextCellStart(selection: Selection): Boolean {
if (selection.contextType.includes('Table')) {
selection.selectCell();
selection.select(selection.endOffset, selection.endOffset); selection.moveToNextCharacter();
if (!selection.contextType.includes('Table')) {
selection.moveToPreviousCharacter();
return false;
}
return true;
}
return false;
}
function moveCursorToPreviousCellEnd(selection: Selection): Boolean {
if (selection.contextType.includes('Table')) {
selection.selectCell();
selection.select(selection.startOffset, selection.startOffset);
selection.moveToPreviousCharacter();
if (!selection.contextType.includes('Table')) {
selection.moveToNextCharacter();
return false;
}
return true;
}
return false;
} |
function onInsertTable(): void {
var rowCount = 3;
var columnCount = 3;
container.documentEditor.editor.insertTable(rowCount, columnCount);
for (var i = 0; i < rowCount * columnCount; i++) {
//Inserts the text to cursor position.
container.documentEditor.editor.insertText('Cell ' + (i + 1).toString());
if (i < rowCount * columnCount - 1) {
//Skips moving cursor to next cell when it reached the last cell.
var isNavigated = moveCursorToNextCellStart(container.documentEditor.selection);
if (!isNavigated) {
break;
}
}
}
} |
function onInsertTable(): void {
var rowCount = 3;
var columnCount = 3;
container.documentEditor.editor.insertTable(rowCount, columnCount);
for (var i = 0; i < rowCount * columnCount; i++) {
//Inserts the image to cursor position.
container.documentEditor.editor.insertImage("https://raw.githubusercontent.com/SyncfusionExamples/EJ2-Document-Editor-Web-Services/master/ASP.NET%20Core/appData.PNG", 150, 60);
if (i < rowCount * columnCount - 1) {
//Skips moving cursor to next cell when it reached the last cell.
var isNavigated = moveCursorToNextCellStart(container.documentEditor.selection);
if (!isNavigated) {
break;
}
}
}
} |