我正在使用 jQueryEasyUI 数据网格视图:http: //www.jeasyui.com/extension/datagridview.php
在默认格式化程序中,我正在定义我的 textarea,它将成为我的 jHTMLArea:
detailFormatter: function(rowIndex, rowData){
var x = rowIndex + 1;
html = '<table>'+
' <tr>' +
' <td style="border:0">' +
' <textarea id="text_'+x+'" cols="125" rows="25">'+rowData.text+'</textarea>' +
' <button type="submit" class="btn btn-primary" onclick="save();">Save</button>'+
' <button type="submit" class="btn btn-info" onclick="discard();">Discard</button>'+
' </td>' +
' </tr>'+
'</table>';
$('#text_'+ x).htmlarea({
css: 'style/jHtmlArea.Editor.css',
toolbar: [
["bold", "italic", "underline"],
["p", "h3"],
["link", "unlink"]
]
});
$('#text_'+ x).hide();
现在,当我展开行以显示详细信息时,我加载了 jHTMLArea:
onExpandRow: function(rowIndex, rowData) {
var x = rowIndex + 1;
window.index = x;
window.gk_text = rowData.text;
setHTML(x, rowData.text);
}
和:
function setHTML(rel, text) {
var html = text;
html = html.replace(/\[/g, '<').replace(/\]/g, '>');
$('#text_'+ rel).htmlarea('html', html);
}
这是一个数据示例:
{"totals": 2,
"rows": [{ id: 0, prg_code: "ABC", state: "OL", text: "[h3]Important Information[/h3][p]This is a notice.[/p]"},
{ id: 0, prg_code: "DEF", state: "WB", text: "[h3]Important Information[/h3][p]This is a another notice.[/p]"}]
}
如您所见,我将工具栏按钮设置为仅显示:
["bold", "italic", "underline"],
["p", "h3"],
["link", "unlink"]
但是,当我展开该行时,编辑器具有所有默认按钮。
任何想法如何做到这一点并使编辑器100%适合编辑器区域?注意:保存和放弃按钮按预期工作。
哦,另一件事,当与 Bootstrap 结合使用时,Bootstrap .h?类覆盖 jHTMLArea 类并导致工具栏混乱。
还想获得带有选项 OL (val:0)、CR (val:1) 和 WB (val:2) 的类型的选择编辑器
小提琴:http: //jsfiddle.net/Mrbaseball34/qdt8t7jr/