Kendo UI:footertemplate中的总和

时间:2013-03-26 08:43:02

标签: sum kendo-ui footer kendo-grid

我正在尝试让我的footerTemplate使用Kendo UI网格。我想在表格的页脚中得到'hours_worked'的总和。我从Kendo UI示例中尝试了几个选项,但它对我不起作用。我做错了什么?

$(document).ready(function() {
  $("#grid").kendoGrid({
    dataSource: {
      transport: 
        read: {
          url: "mods/hours/data/get_hours.php?id=<?php echo $volunteer_id; ?>",
          dataType: "json"
        }
      },
      schema: {
        model: {
          fields: {
            hours_id: { type: "number" },
            volunteer_first_name: { type: "string" },
            volunteer_last_name: { type: "string" },
            hours_date: { type: "date" },
            location_name: { type: "string" },
            work_type_name: { type: "string" },
            volunteer_id: { type: "number" },
            hours_worked: { type: "number" }
          }
        }
      },
      aggregate:[{ field:"hours_worked", aggregate:"sum" }],
      pageSize: 10
    },
    height: 350,
    filterable: true,
    sortable: true,
    pageable: true,
    selectable:true,
    columns: [
      {
        title:"Naam",
        template:"#=volunteer_last_name#, #=volunteer_first_name#",
      },{
        title:"Locatie",
        field:"location_name",
      },{
        title:"Werkzaamheden",
        field:"work_type_name",
      },{
        title:"Uren",
        field:"hours_worked",
        footerTemplate:"Sum: #=sum#",
      },{
        title:"Datum",
        field:"hours_date",
      },{
        width:"200px",
        title:"Opties",
        filterable: false,
        template:"<a href='?p=edit_reported_hours&id=#=volunteer_id#&hours_id=#=hours_id#' class='k-button'>Bewerken</a> <a href='?p=manage_reported_hours&o=delete&id=#=volunteer_id#&hours_id=#=hours_id#' class='k-button'>Delete</a>"
      },
    ]
  });
});
</script>

1 个答案:

答案 0 :(得分:1)

transport之后添加一个大括号,它会起作用。

transport: {
    read: {
       url: "mods/hours/data/get_hours.php?id=<?php echo $volunteer_id; ?>",
       dataType: "json"
    }
},

请在此处查看:http://jsfiddle.net/OnaBai/bWS7C/