Get Row Data from Field Formatter

I am trying to make a field formatter that allows user to change the value of a cell directly from Kibana Discovery.
To do that, I need to make a request to Elasticsearch to update that cell, but I need the _id to do that.
Is there an easy way to get the id of the row? It's also nice to get other cells in the row, but not required.

From my understanding, after a field formatter is registered, Kibana simply calls the _convert function and takes the returned string.

What I have been trying is having the _convert method return a hardcoded onChange, such as:

return `<select onChange="myCustFunc(this)">
    ...
</select>`

and then defining a hack that defines window.myCustFunc, uses angular.element(e).scope() to get the scope, and then sends ajax request to a hapijs endpoint defined in the plugin.

However, the .scope() function on works with debug info on, which would not be good for production.

So, my question is: Is there a good way to get the data of the row/elasticsearch id of the cell from a field formatter? (ex: returning an angular element instead of a string)

Thanks in advance!

The arguments passed to the _convert function are rawValue, field, and hit. So you should be able to access hit._id. Hope that helps!

That was exactly what I was looking for!

Thanks.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.