【发布时间】:2014-09-06 15:05:44
【问题描述】:
我正在尝试在 handsontable 的每一行末尾添加一个自定义保存按钮。 我在 laravel 4 中使用 handsontable 包。
按钮显示如下:
<button>Save</button>
【问题讨论】:
-
您使用的是什么代码?你试过什么?
标签: button handsontable
我正在尝试在 handsontable 的每一行末尾添加一个自定义保存按钮。 我在 laravel 4 中使用 handsontable 包。
按钮显示如下:
<button>Save</button>
【问题讨论】:
标签: button handsontable
尝试使用htmlRenderer
演示:http://docs.handsontable.com/0.19.0/demo-custom-renderers.html
var actionRenderer = function (instance, td, row, col, prop, value, cellProperties) {
var $button = $('<button>');
$button.html(value)
$(td).empty().append($button); //empty is needed because you are rendering to an existing cell
};
var $container = $("#example1");
$container.handsontable({
/*....*/
columns: [
/*....*/
{data: "action", renderer: actionRenderer}
]
});
为了获得更好的性能,渲染器可以用纯 JavaScript 编写
【讨论】:
我找到了我自己问题的答案.. 我在 handsontable 中使用“渲染器”将单元格渲染为 HTML
columns: [
{data: "unique_no"},
{data: "title"},
{data: "subject"},
{data: "year"},
{data: "duration"},
{data: "color"},
{data: "language"},
{data: "synopsis"},
{data: "director"},
{data: "basic_format"},
{data: "created_at"},
{data: "updated_at"},
{data: "action", renderer: "html",readOnly: true}
],
这是我找到它的地方http://handsontable.com/demo/renderers_html.html#dropdown
【讨论】:
您可以简单地执行此自定义渲染器。
columns: [
{ data: 'basicFormat', renderer: 'text'},
{ data: 'createdAt', renderer: 'text'},
{ data: 'updatedAt', renderer: 'text'},
{ data: 'action', renderer: 'html'},
]
【讨论】: