<ext:Grid ID="EMCGrid" Title="暗室类测试项目详细配置" ShowBorder="true" ShowHeader="true" DataKeyNames="ObjectAID,ObjectAID"
AllowCellEditing="true" ClicksToEdit="1"
runat="server" ForceFit="true" BoxConfigAlign="Stretch" Hidden="true" OnPreRowDataBound="EMCGrid_PreRowDataBound"
OnRowCommand="EMCGrid_RowCommand">
<Columns>
<ext:RenderCheckField DataField="Selected" HeaderText="" Width="50" />
<ext:RowNumberField EnablePagingNumber="true" Width="50" HeaderText="序号"/>
<ext:BoundField DataField="TestItem" HeaderText="测试项目" ExpandUnusedSpace="true"/>
<ext:BoundField DataField="ObjectName" HeaderText="测试频段" ExpandUnusedSpace="true"/>
<ext:BoundField ColumnID="EMCNumA" DataField="NumA" HeaderText="测试典型值(min)" Width="120" />
<ext:BoundField ColumnID="EMCNumB" DataField="NumB" HeaderText="组网典型值(min)" Width="120" />
<ext:RenderField ColumnID="EMCNum1" DataField="Num1" HeaderText="配置数" FieldType="Int" ExpandUnusedSpace="true"
RendererFunction="renderNum1">
<Editor>
<ext:NumberBox runat="server" MinValue="0" Required="true"/>
</Editor>
</ext:RenderField>
<ext:RenderField ColumnID="EMCNum2" DataField="Num2" HeaderText="电压数" FieldType="Int" ExpandUnusedSpace="true">
<Editor>
<ext:NumberBox runat="server" MinValue="0"/>
</Editor>
</ext:RenderField>
<ext:BoundField Width="120" ColumnID="EMCNum3" DataField="Num3" HeaderText="测试时长(min)"/>
<ext:BoundField Width="120" ColumnID="EMCNum4" DataField="Num4" HeaderText="组网时长(min)"/>
<ext:BoundField Width="120" ColumnID="EMCNum5" DataField="Num5" HeaderText="总时长(min)"/>
</Columns>
<Listeners>
<ext:Listener Event="edit" Handler="onEMCGridAfterEdit"/>
</Listeners>
</ext:Grid>
function renderNum1(value, params) {
var me = this, columnId = params.column.id, rowIdx = params.rowIdx, colIdx = params.colIdx, rowId = params.record.getId();
if (params.record.data["EMCTestItem"] == "RE" || params.record.data["EMCTestItem"] == "RS" || params.record.data["EMCTestItem"] == "prestest") {
if (params.record.data["EMCNum1"] < 1) {
me.f_updateCellValue(rowId, 'EMCNum1', 1);
var fEMCNum1 = me.f_getCellValue(rowId, 'EMCNum1');
var fEMCNum2 = me.f_getCellValue(rowId, 'EMCNum2');
var fEMCNumA = me.f_getCellValue(rowId, 'EMCNumA');
var fEMCNumB = me.f_getCellValue(rowId, 'EMCNumB');
me.f_updateCellValue(rowId, 'EMCNum3', fEMCNumA * fEMCNum1 * fEMCNum2);
me.f_updateCellValue(rowId, 'EMCNum4', fEMCNumB * fEMCNum1);
me.f_updateCellValue(rowId, 'EMCNum5', fEMCNumA * fEMCNum1 * fEMCNum2 + fEMCNumB * fEMCNum1);
value = 1;
}
}
return value;
}
<script src="../res/js/jquery.min.js" type="text/javascript"></script>
<script src="../res/autocomplete/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript">
var EMCgridClientID = '<%= EMCGrid.ClientID %>';
F.ready(function () {
var EMCgrid = F(EMCgridClientID);
onSpecialKey(EMCgrid);
});
</script>
<script src="../js/EditGrid.js" type="text/javascript"></script>
<script src="../js/ystep.js" type="text/javascript"></script>
<script type="text/javascript">
// 注意:专业版中改事件名为:afteredit,开源版中为:edit
function onEMCGridAfterEdit(editor, params) {
var me = this, columnId = params.column.id, rowIdx = params.rowIdx, colIdx = params.colIdx, rowId = params.record.getId();
var store = me.getStore();
Ext.suspendLayouts();
me.suspendEvents();
if (columnId === 'EMCNum1' || columnId === 'EMCNum2') {
var fEMCNum1 = me.f_getCellValue(rowId, 'EMCNum1');
var fEMCNum2 = me.f_getCellValue(rowId, 'EMCNum2');
var fEMCNumA = me.f_getCellValue(rowId, 'EMCNumA');
var fEMCNumB = me.f_getCellValue(rowId, 'EMCNumB');
me.f_updateCellValue(rowId, 'EMCNum3', fEMCNumA * fEMCNum1 * fEMCNum2);
me.f_updateCellValue(rowId, 'EMCNum4', fEMCNumB * fEMCNum1);
me.f_updateCellValue(rowId, 'EMCNum5', fEMCNumA * fEMCNum1 * fEMCNum2 + fEMCNumB * fEMCNum1);
}
me.resumeEvents();
Ext.resumeLayouts(true);
//说明编辑的行不是最后一行,回车后进入下一行
if (rowIdx < store.getCount() && editor.lastKey == 13) {
var NextRowId = parseInt(rowIdx) + 1;
me.f_cellEditing.startEdit(NextRowId, 1);
}
editor.lastKey = 0;
}
</script>