我正在試圖添加一個自定義的保存按鈕,在每個行的結尾處在可移動表中。 我使用handsontable包laravel 4如何在單元格中添加自定義按鈕?
按鈕顯示出來是這樣的:
<button>Save</button>
我正在試圖添加一個自定義的保存按鈕,在每個行的結尾處在可移動表中。 我使用handsontable包laravel 4如何在單元格中添加自定義按鈕?
按鈕顯示出來是這樣的:
<button>Save</button>
我找到了答案,以我自己的問題.. 我用「渲染」,在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
這應該被標記爲正確的答案。感謝分享! – Shimmy
嘗試使用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
謝謝。這是我使用的過程,因爲我想將自定義事件偵聽器添加到「值」。 –
你使用什麼代碼?你有什麼嘗試? – Laurence