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.

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.
settingsThe properties of the view. See the methods below to get and set values.
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.
settings.get( property )Returns the value of property for the current component.
settings.set( propertyvalue )Sets the value of property to the specified value for the current component.

Example

require([
    "splunkjs/mvc/datatemplateview",
    "splunkjs/mvc/simplexml/ready!"
], function(DataTemplateView) {

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

});