asdf_enel_hak
asdf_enel_hak

Reputation: 7650

How to pass parameter to kendo template

I have this code:

var columns = [];

$.each(actions, function (idx, action) {
    actionColumn = { 
        template: '#if (selfActions[i].name === "' + action.name + '"){ # <input type="checkbox" /> some text   # } # '
    }   
    columns.push(actionColumn);
});

 $("#myId").kendoTreeList({
    //...
    columns: columns
});

And I want to convert to template such as:

<script id="rowLeaveTemplate" type="text/x-kendo-tmpl">
        if (selfActions[i].name === '???action.name???' ){#
            <input type="checkbox" />  some text
        # }  # 
</script>

How can I pass parameter action.name to template to replace '???action.name???'

Upvotes: 1

Views: 7900

Answers (1)

Gene R
Gene R

Reputation: 3744

Something like this:

actionColumn = { 
    template: function(dataItem) {
        return kendo.template($("#rowLeaveTemplate").html())({ actionName:action.name });
    }
}

and kendo template itself:

<script id="rowLeaveTemplate" type="text/x-kendo-template">
    # if (selfActions[i].name === actionName ){#
        <input type="checkbox" />  some text
    # }  # 
</script>

Upvotes: 4

Related Questions