DataTemplateView

The DataTemplate view

Description

The DataTemplate view is a generic view that provides developers with the ability to display an underscore.js template and fill it out with the results of an associated search manager.

Documentation

Library path

Properties

Name

Default value

Description

id Required. The unique ID for this control.
data"preview"The type of data to retrieve from the search results
results | preview | events | summary | timeline ).
manageridnullThe ID of the search manager to bind this view to.
messagesfalseIndicates whether to display messages.
template""The template to render. You can specify the Underscore template inline as a string, or programmatically. For examples, see the Splunk Web Framework Toolkit.
templateName""The CSS ID of the template to render. This ID should refer to an ID that is within a <script> tag. For examples, see the Splunk Web Framework Toolkit.

Methods

Name

Description

renderDraws the view to the screen. Called only when you create the view manually in JavaScript.

Example (Django tag) (using template tags)

{% dataview id="mydataview" managerid="example-search" template="<%= results[0].count %>" %}

Example (JavaScript)

<script>
    var deps = [
        "splunkjs/ready!",
        "splunkjs/mvc/dataview"
    ];
    require(deps, function(mvc) {
        var DataView = require("splunkjs/mvc/dataview");

        // Instantiate components
        new DataView({
            id: "example-data",
            managerid: "example-search",
            template: "<%= results[0].count %>",
            el: $("#mydataview")
        }).render();

    });
</script>