0

我有这个代码:

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
});

我想转换为模板,例如:

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

如何将参数传递action.name给模板以替换'???action.name???'

4

1 回答 1

3

像这样的东西:

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

和剑道模板本身:

<script id="rowLeaveTemplate" type="text/x-kendo-template">
    # if (selfActions[i].name === actionName ){#
        <input type="checkbox" />  some text
    # }  # 
</script>
于 2015-12-20T09:49:02.447 回答