How to add a custom button inside a cell in handsontable mode?

I am trying to add a custom save button at the end of each line in handsontable mode. I am using a handsontable package in laravel 4.

The button is displayed as follows:

enter image description here

<button>Save</button>
+4
source share
2 answers

I found the answer to my question. I used the "visualizer" in handsontable mode to make a cell in 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}

                  ],

Here I found it http://handsontable.com/demo/renderers_html.html#dropdown

+4
source

Try using htmlRenderer

Demo: 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

+7

Source: https://habr.com/ru/post/1548590/


All Articles