国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > php开源 > 综合技术 > Coolite 计算单列总值的解决方案

Coolite 计算单列总值的解决方案

来源:程序员人生   发布时间:2013-12-10 03:59:16 阅读次数:3399次
使用GroupingSummaryColumn方式:
注意几点:
1,如果在自定义 CustomSummaryType="totalTimes", 要在
base.scmanager.Listeners.DocumentReady.Handler = "Ext.grid.GroupSummary.Calculations['totalTimes'] = totalTimes";
2,自定义SummarType后,只能使用<Renderer Fn="">
不可以使用Handler (它们有冲突)

<script type="text/javascript">
function getWorkTime(startTime, endTime, dTime) {
try {
var b1 = parseInt(startTime.split(":")[0], 10) * 60 + parseInt(startTime.split(":")[1], 10);
var b2 = parseInt(endTime.split(":")[0], 10) * 60 + parseInt(endTime.split(":")[1], 10);
var b3 = parseInt(dTime.split(":")[0], 10) * 60 + parseInt(dTime.split(":")[1], 10);
var s = Math.abs((b2 - b1 - b3) % 60);
if (s < 10) {
s = "0" + s;
}
var elapsed = Math.abs(parseInt((b2 - b1 - b3) / 60, 10)) + ":" + s;
return elapsed;

} catch (e) {
return '0:00';
}
}
var totalTimes = function(v, record, field) {
return Addtime(v, getWorkTime(record.data.StartTime, record.data.EndTime, record.data.BreakDuration));
//return Addtime(v,"0:00");
}
// function totalTimes(v, record) {
// var gw=getWorkTime(record.data.StartTime, record.data.EndTime, record.data.BreakDuration);
//// var dt = new Date();
//// dt = Date.parseDate(v, "h:i:s");
//// if (dt) {
//// return Addtime(v, gw);
//// }
// return Addtime(v, gw);
// //return Addtime(dt, '0:15');
// }
function getTimevalue(time) {
if (time)
return parseInt(time.split(":")[0], 10) * 60 + parseInt(time.split(":")[1], 10);
else
return 0;
}
function Addtime(t1, t2) {
var tv = getTimevalue(t1) + getTimevalue(t2);
var s = Math.abs((tv) % 60);
if (s < 10) {
s = "0" + s;
}
return Math.abs(parseInt((tv) / 60, 10)) + ":" + s;
}
//24网(LieHuo92.Net)教52
var timeRenderer = function(value, meta, r) {
return getWorkTime(r.data.StartTime, r.data.EndTime, r.data.BreakDuration);
}
</script>

<ext:GridPanel ID="GridPanel1" runat="server" Frame="true" StoreID="Store1" StripeRows="true"
Title="Time Summary" AutoExpandColumn="WorkCategoryName" Collapsible="true" AnimCollapse="false"
Icon="ApplicationViewColumns" TrackMouseOver="false" AutoWidth="true" AutoHeight="true"
ClicksToEdit="0">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:GroupingSummaryColumn ColumnID="WorkCategoryName" Header="Category" Sortable="true"
DataIndex="WorkCategoryName" Hideable="false" SummaryType="Count">
<SummaryRenderer Handler="return ((value === 0 || value > 1) ? '(' + value +' Records)' : '(1 Record)');" />
</ext:GroupingSummaryColumn>
<ext:Column ColumnID="EmployeeName" Header="Employee" Sortable="true" DataIndex="EmployeeName"
Width="20" />
<ext:GroupingSummaryColumn ColumnID="RecordDate" Width="25" Header="Date" Sortable="true"
DataIndex="RecordDate">
<Renderer Format="Date" FormatArgs="'m/d/Y'" />
</ext:GroupingSummaryColumn>
<ext:GroupingSummaryColumn Width="20" ColumnID="StartTime" Header="Start Time" Sortable="true"
DataIndex="StartTime">
</ext:GroupingSummaryColumn>
<ext:GroupingSummaryColumn Width="20" ColumnID="EndTime" Header="End Time" Sortable="true"
DataIndex="EndTime" >
</ext:GroupingSummaryColumn>
<ext:GroupingSummaryColumn Width="20" ColumnID="BreakDuration" Header="Break Duration"
Sortable="false" Groupable="false" DataIndex="BreakDuration">
</ext:GroupingSummaryColumn>
<ext:GroupingSummaryColumn Width="20" ColumnID="NetDuration" DataIndex="TimeID"
Header="Total" Sortable="false" CustomSummaryType="totalTimes" Groupable="false">
<Renderer Fn="timeRenderer" />
<SummaryRenderer Handler="return totalTimes(value,record);" />
</ext:GroupingSummaryColumn>
</Columns>
</ColumnModel>
<View>
<ext:GroupingView ID="GroupingView1" runat="server" ForceFit="true" ShowGroupName="false"
EnableNoGroups="true" HideGroupedColumn="true" />
</View>
<Plugins>
<ext:GroupingSummary ID="GroupingSummary1" runat="server" />
</Plugins>
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生