如何将Checkbox添加到Kendo Grid的工具栏?

时间:2015-12-01 10:22:25

标签: javascript asp.net-mvc kendo-ui kendo-grid

我想在checkbox添加Toolbar of a Kendo Grid,但文档中没有配置或示例。那么,是否可以添加checkbox作为按钮?

<script>
    var grid = $("#grid").kendoGrid({
        toolbar: [
            { name: 'excel', text: 'Export to Excel' },
            { type: 'checkbox', text: 'Get full list', id: "cbFull" } //it does not work
        ]
    //code omitted for brevity
<script>

1 个答案:

答案 0 :(得分:1)

<script type="text/x-kendo-template" id="template">
   <div class="toolbar">
      <input type="button" id="exportExcel" value="Export Excel"/>
      <label class="list-label" for="list">Get full list:</label>
      <input type="checkbox" id="list" style="width: 75px"/>
   </div>
</script>

<script>
 $(document).ready(function() {
 var grid = $("#grid").kendoGrid({
 toolbar: kendo.template($("#template").html())
 //code omitted for brevity

 var excelButton = grid.find("#exportExcel")
 excelButton.on("click",function(){
     alert("Saving...");
     grid.data("kendoGrid").saveAsExcel();
  });
});
</script>

示例http://dojo.telerik.com/iFodO(导出实际上不像缺少的JSZip那样工作)