Dashboards & Visualizations

How to delete a rendered SplunkJS view?

bhawkins1
Communicator

Hi,

I have (for example) a ChartView created with const v = new ChartView({}).render();.

How can I delete/un-render v?

Regards,

0 Karma

Rocket66
Communicator

try:

splunkjs.mvc.Components.getInstance(id).remove();

where id is the object (eg. panel-id), you want to remove ...

example: splunkjs.mvc.Components.getInstance("element1").remove();

kalyangoutham
New Member

The remove function works fine. Can i recreate the chartview object that can be viewed upon creating it again with the same id:

require([
"splunkjs/mvc/tableview",
"splunkjs/mvc/chartview",
"splunkjs/mvc/searchmanager",
"splunkjs/mvc",
"splunkjs/mvc/postprocessmanager",
"splunkjs/mvc/dropdownview",
"splunkjs/mvc/multidropdownview",,
"splunkjs/mvc/textinputview",
"underscore",
"splunkjs/mvc/simplexml/ready!"
], function(
TableView,
ChartView,
SearchManager,
mvc,
PostProcessManager,
DropdownView,
MultiDropdownView,
TextInputView,
_
) {var chart = new ChartView ({
id: “element1”,
managerid: “managerid”,
wrap: true,
rowNumbers: false,
el: $("#elname")
}, {tokens: true}).render();})

When I try to recreate the ChartView component object on remove(), I am unable to view the chart on the Dashboard.
The above command ensures that the object is once again created and rendered.
Can you please suggest a way to recreate the removed Component that cab be viewed on the Dashboard

0 Karma
Get Updates on the Splunk Community!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...