2013-03-26 2 views
0

나는 footerTemplate을 검도 UI 그리드와 함께 사용하려고합니다. 나는 테이블의 꼬리말에 'hours_worked'의 합을 얻고 싶습니다. 검도 UI 예제에서 몇 가지 옵션을 시도했지만 저에게는 효과가 없습니다. 뭐가 잘못 됐니?검도 UI : footeremplate의 합

$(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> 
+0

, 그것은'number'해야한다. – OnaBai

+0

빠른 답변 주셔서 감사합니다하지만 해결되지 않습니다 ... 바닥 글 템플릿이 표시되지 않습니다. – zxcvb

답변

1

transport 뒤에 중괄호를 추가하면 작동합니다.

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

는 여기를 참조하십시오 http://jsfiddle.net/OnaBai/bWS7C/ 당신은 hours_worked``로 hours_worked``의 유형을 정의

+0

감사합니다. 이제 테이블에 꼬리말이 있습니다. 이제 합계가 작동하지 않습니다. 내 데이터베이스의 시간은 '4.50 '처럼 형성됩니다. '.'때문에이 형식이 작동하지 않을 수 있습니까? ','을 사용해야합니까? – zxcvb

+0

일종의. 그들은 소수로 분리 할 수있는 숫자로 분석 할 필요가 있습니다 ** 그러나 ** 현지화에 해당하는'cultures/kendo.culture.XX-YY.min.js'를 포함 시키려면' 문화를 설정하기위한 kendo.culture ("XX-YY"). 이것이 불가능하다면 (다른 것을 깨뜨린다면)'DataSource'에서'parse' 함수를 사용하는 것이 좋습니다. 이러한 방법으로 도움이 필요하면 알려주십시오. – OnaBai

+0

당신의 도움에 Thnaks! – zxcvb