我正在handsontable.js
使用jquery
最新版本。我想添加新功能以添加到 handontalbecontextMenu
bold
和normal text
. 我已将这两个菜单选项添加到contextMenu
. 但是我怎样才能使所有选定cell
的文本粗体和正常。
这是我的 handsontable 的 jquery 代码:
$("#A_tabledata").handsontable({
data: data,
startRows: 1,
startCols: 2,
minRows: 1,
minCols: 2,
maxRows: 400,
maxCols: 200,
rowHeaders: false,
colHeaders: false,
minSpareRows: 1,
minSpareCols: 1,
mergeCells: true,
cells: function (row, col, prop) {
var cellProperties = {};
cellProperties.renderer = "defaultRenderer"; //uses lookup map
return cellProperties;
},
contextMenu: {
callback: function(key, options) {
if(key == 'bold'){
//Return index of the currently selected cells as an array [startRow, startCol, endRow, endCol]
var sel = this.getSelected() ;
var boldValues = ''; //How can i get cell value?
// How can i set value back to in the cell?
}
if(key == 'normalText'){
//Return index of the currently selected cells as an array [startRow, startCol, endRow, endCol]
var sel = this.getSelected();
var normalValues = ''; //How can i get cell value?
// How can i set value back to in the cell?
}
},
items: {
"row_above": {},
"row_below": {},
"col_left": {},
"col_right": {},
"hsep2": "---------",
"remove_row": {name:'Remove row(s)'},
"remove_col": {name:'Remove columns(s)'},
"hsep3": "---------",
"alignment" : {},
"mergeCells" : {},
"hsep4": "---------",
"undo": {},
"redo": {},
"hsep5": "---------",
"bold": {"name": "Bold"},
"normalText": {"name": "Normal Text"}
}
},
cell: <?php echo $metadata; ?>,
mergeCells: <?php echo $metadata; ?>
});
更新
有关我想要的更多信息,我在此处添加图像:
在此图像中,您可以看到蓝色区域。当我从上下文菜单中单击“粗体”时,我希望所有这些单元格都是粗体。当我从上下文菜单中单击“普通文本”时恢复正常。
我如何获得单元格值?如何将值设置回单元格中?
我在许多论坛和帖子中搜索过,但没有得到答案:
提前致谢。