zoukankan      html  css  js  c++  java
  • Grid的编辑事件

    <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>

  • 相关阅读:
    Luogu P4205 [NOI2005]智慧珠游戏
    Luogu P3321 [SDOI2015]序列统计
    Luogu P2056 [ZJOI2007]捉迷藏
    Luogu P5168 xtq玩魔塔
    2019年一月刷题列表
    [转载]我们都是行走在镜面边缘的人
    [武汉加油] CF830C Bamboo Partition
    [武汉加油] [NOI Online 提高组]最小环
    [武汉加油] luogu P6178 【模板】Matrix-Tree 定理
    [武汉加油] bzoj 5099: [POI2018]Pionek 几何+双指针
  • 原文地址:https://www.cnblogs.com/sanshengshitouhua/p/14428191.html
Copyright © 2011-2022 走看看