I have a splunk table where there are few columns having dropdown (eg ddcol1, ddcol2 ) and at last there is a column having button(submit)
The functionality of the button is to mark all the dropdowns with a default value(ok)
I have written the below js , but the dropdown doesnt update on click of the button
require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {
// Add dropdown to table
var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
canRender: function(cell) {
return _(["ddcol1","ddcol2","submit"]).contains(cell.field);
},
render: function($td, cell) {
console.log(cell.field);
if (cell.field == "ddcol1" || cell.field == "ddcol2") {
if(cell.value == "dd") {
var strHtmlInput = `
<select>
<option value="ok">ok</option>
<option value="not ok">Not Ok</option>
</select>
`;
$td.append(strHtmlInput).on("change", function(e) {
console.log(e.target.value)
});
}
else {
$td.append(cell.value);
}
}
if (cell.field == "submit"){
console.log(cell.field);
var strHtmlInput1=`<input type='button' class='table-button' value='All Ok'></input>`;
$td.append(strHtmlInput1);
}
}
});
$(document).on("click",".table-button",function(){
console.log("clicked");
console.log($(this).parents("tr").find("td[data-cell-index='6'").find(":selected").text());
$(this).parents("tr").find("td[data-cell-index='6']").find(":selected").value="ok";
console.log('selected');
console.log($(this).parents("tr").find("td[data-cell-index='6'").find(":selected").text());
});
var sh = mvc.Components.get("tbl1");
if (typeof(sh) != "undefined") {
sh.getVisualization(function(tableView) {
// Add custom cell renderer and force re-render
tableView.table.addCellRenderer(new CustomRangeRenderer());
tableView.table.render();
});
}
});
@niketn @kamlesh_vaghela
... View more