Infragistics控件对UltraWebGrid单元格编辑进行控制及样式设置

//代码出自:文山综合管理平台--绩效考核--员工考核--员工岗位价值系数评定
//页面:jx.web/JxEmployee/JxYgjzxsList.aspx
<thinker:ScrollPanel ID="ScrollPanel1" runat="server" Width="648px" Height="449px">
            <igtbl:UltraWebGrid ID="grdInfoList" runat="server" Height="200px" Width="325px">
                <DisplayLayout CellClickActionDefault="Edit">
                    <ClientSideEvents AfterCellUpdateHandler="AfterCellUpdateHandler" />
                </DisplayLayout>
                <Bands>
                    <igtbl:UltraGridBand>
                        <Columns>
                            <igtbl:UltraGridColumn BaseColumnName="EMP_ID" Width="60px" Key="EMP_ID" Hidden="true">
                                <Header Caption="员工ID">
                                    <RowLayoutColumnInfo OriginX="0" OriginY="0" SpanY="1" />
                                </Header>
                                <CellStyle HorizontalAlign="Center">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="EMP_NAME" Width="60px" Key="EMP_NAME">
                                <Header Caption="姓名">
                                    <RowLayoutColumnInfo OriginX="0" OriginY="0" SpanY="1" />
                                </Header>
                                <CellStyle HorizontalAlign="Center">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="DEPT_NAME" Width="80px" Key="DEPT_NAME">
                                <Header Caption="所在部门">
                                    <RowLayoutColumnInfo OriginX="0" OriginY="0" SpanY="1" />
                                </Header>
                                <CellStyle HorizontalAlign="Center">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="POST_NAME" Width="80px" Key="POST_NAME">
                                <Header Caption="岗位名称">
                                    <RowLayoutColumnInfo OriginX="0" OriginY="0" SpanY="1" />
                                </Header>
                                <CellStyle HorizontalAlign="Center">
                                </CellStyle>
                            </igtbl:UltraGridColumn>

                            <igtbl:UltraGridColumn BaseColumnName="GJYJZB" Width="170px" Key="GJYJZB"
                                EditorControlID="GJYJZB" NullText="20.00" AllowUpdate="Yes" Type="Custom">
                                <Header Caption="关键业绩指标完成情况(20分)">
                                    <RowLayoutColumnInfo OriginX="1" OriginY="0" />
                                </Header>
                                <CellStyle HorizontalAlign="Right" BackColor="#fbe7b6">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="GZLDX" Width="100px" Key="GZLDX" EditorControlID="GZLDX"
                                NullText="30.00" AllowUpdate="Yes" Type="Custom">
                                <Header Caption="工作量大小(30分)">
                                    <RowLayoutColumnInfo OriginX="1" OriginY="0" />
                                </Header>
                                <CellStyle HorizontalAlign="Right" BackColor="#fbe7b6">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="GZZLJXL" Width="130px" Key="GZZLJXL" EditorControlID="GZZLJXL"
                                NullText="20.00" AllowUpdate="Yes" Type="Custom">
                                <Header Caption="工作质量及效率(20分)">
                                    <RowLayoutColumnInfo OriginX="1" OriginY="0" />
                                </Header>
                                <CellStyle HorizontalAlign="Right" BackColor="#fbe7b6">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="ZXL" Width="90px" Key="ZXL" EditorControlID="ZXL"
                                NullText="10.00" AllowUpdate="Yes" Type="Custom">
                                <Header Caption="执行力(10分)">
                                    <RowLayoutColumnInfo OriginX="1" OriginY="0" />
                                </Header>
                                <CellStyle HorizontalAlign="Right" BackColor="#fbe7b6">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="TDXZ" Width="100px" Key="TDXZ" EditorControlID="TDXZ"
                                NullText="10.00" AllowUpdate="Yes" Type="Custom">
                                <Header Caption="团队协作(10分)">
                                    <RowLayoutColumnInfo OriginX="1" OriginY="0" />
                                </Header>
                                <CellStyle HorizontalAlign="Right" BackColor="#fbe7b6">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="BMGXD" Width="100px" Key="BMGXD" EditorControlID="BMGXD"
                                NullText="10.00" AllowUpdate="Yes" Type="Custom">
                                <Header Caption="部门贡献度(10分)">
                                    <RowLayoutColumnInfo OriginX="1" OriginY="0" />
                                </Header>
                                <CellStyle HorizontalAlign="Right" BackColor="#fbe7b6">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="PJDF" Width="35%" Key="PJDF" NullText="0.00" Format="#0.00">
                                <Header Caption="评价得分">
                                    <RowLayoutColumnInfo OriginX="1" OriginY="0" SpanY="1" />
                                </Header>
                                <CellStyle HorizontalAlign="Right">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="PDXS" Width="35%" Key="PDXS" EditorControlID="PDXS"
                                NullText="0.00" AllowUpdate="Yes" Type="Custom">
                                <Header Caption="评定系数">
                                    <RowLayoutColumnInfo OriginX="1" OriginY="0" />
                                </Header>
                                <CellStyle HorizontalAlign="Right" BackColor="#fbe7b6">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="STATE_NAME" Width="30%" Key="STATE_NAME">
                                <Header Caption="状态">
                                    <RowLayoutColumnInfo OriginX="0" OriginY="0" SpanY="1" />
                                </Header>
                                <CellStyle HorizontalAlign="Center">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="ID" Width="0px" Hidden="true" Key="ID">
                                <Header Caption="ID">
                                    <RowLayoutColumnInfo OriginX="0" OriginY="0" />
                                </Header>
                                <CellStyle HorizontalAlign="Center">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                            <igtbl:UltraGridColumn BaseColumnName="STATE" Width="0px" Hidden="true" Key="STATE">
                                <Header Caption="STATE">
                                    <RowLayoutColumnInfo OriginX="0" OriginY="0" />
                                </Header>
                                <CellStyle HorizontalAlign="Center">
                                </CellStyle>
                            </igtbl:UltraGridColumn>
                        </Columns>
                    </igtbl:UltraGridBand>
                </Bands>
            </igtbl:UltraWebGrid>
        </thinker:ScrollPanel>
        <thinker:ProcessBarDlg ID="ProcessBarDlg1" runat="server"></thinker:ProcessBarDlg>
        <input type="hidden" id="hidCycCode" name="hidCycCode" runat="server" />
        <input id="hidKpType" type="hidden" name="hidKpType" runat="server" />
        <igtxt:WebNumericEdit ID="GJYJZB" runat="server" Width="100px" CssClass="Input_Modify"
            DataMode="Decimal" MinDecimalPlaces="2" MinValue="0" MaxValue="20" NullText=""
            EnableViewState="False">
        </igtxt:WebNumericEdit>
        <igtxt:WebNumericEdit ID="GZLDX" runat="server" Width="100px" CssClass="Input_Modify"
            DataMode="Decimal" MinDecimalPlaces="2" MinValue="0" MaxValue="30" NullText=""
            EnableViewState="False">
        </igtxt:WebNumericEdit>
        <igtxt:WebNumericEdit ID="GZZLJXL" runat="server" Width="100px" CssClass="Input_Modify"
            DataMode="Decimal" MinDecimalPlaces="2" MinValue="0" MaxValue="20" NullText=""
            EnableViewState="False">
        </igtxt:WebNumericEdit>
        <igtxt:WebNumericEdit ID="ZXL" runat="server" Width="100px" CssClass="Input_Modify"
            DataMode="Decimal" MinDecimalPlaces="2" MinValue="0" MaxValue="10" NullText=""
            EnableViewState="False">
        </igtxt:WebNumericEdit>
        <igtxt:WebNumericEdit ID="TDXZ" runat="server" Width="100px" CssClass="Input_Modify"
            DataMode="Decimal" MinDecimalPlaces="2" MinValue="0" MaxValue="10" NullText=""
            EnableViewState="False">
        </igtxt:WebNumericEdit>
        <igtxt:WebNumericEdit ID="BMGXD" runat="server" Width="100px" CssClass="Input_Modify"
            DataMode="Decimal" MinDecimalPlaces="2" MinValue="0" MaxValue="10" NullText=""
            EnableViewState="False">
        </igtxt:WebNumericEdit>
        <igtxt:WebNumericEdit ID="PDXS" runat="server" Width="100px" CssClass="Input_Modify"
            DataMode="Decimal" MinDecimalPlaces="2" MinValue="0" MaxValue="10" NullText="1"
            EnableViewState="False">
        </igtxt:WebNumericEdit>

以上代码为页面表单,效果如下图:

Infragistics控件对UltraWebGrid单元格编辑进行控制及样式设置_第1张图片

<igtxt:WebNumericEdit  数值类型:

<igtxt:WebNumericEdit ID="ZXL (对应列名)" runat="server" Width="100px" CssClass="Input_Modify"
            DataMode="Decimal" MinDecimalPlaces="2" MinValue="(最小值)" MaxValue="(最大值)" NullText="(值为null时显示文本/值)"
            EnableViewState="False">
 </igtxt:WebNumericEdit>
       

<igtxt:webcurrencyedit   金额类型 :
<igtxt:webcurrencyedit id="wceMoney" runat="server" CssClass="inputcss" Width="136px" ValueText="0" Nullable="False"></igtxt:webcurrencyedit>(元)


<igtxt:WebDateTimeEdit></igtxt:WebDateTimeEdit> 日期手工输入


提交后设置Grid样式 后台代码:

 //事件注册
protected override void InitEventHandler()             
        {
            base.InitEventHandler();
            grdInfoList.InitializeRow += grdInfoList_InitializeRow;  
            //this.UltraWebToolbar1.ButtonClicked += UltraWebToolbar1_ButtonClicked;
        }
//响应代码
private void grdInfoList_InitializeRow(object sender, RowEventArgs e)
        {
            if (e.Row.Cells.FromKey("STATE").Value != null &&
                e.Row.Cells.FromKey("STATE").Value.ToString() != "")
            {
                Submit state = (Submit)Convert.ToInt32(e.Row.Cells.FromKey("STATE").Value);
                e.Row.Cells.FromKey("STATE_NAME").Value = EnumEx.GetEnumText(state);

                //已提交的禁止编辑
                if (state == Submit.Submit)
                {
                    e.Row.Cells.FromKey("GJYJZB").AllowEditing = AllowEditing.No;
                    e.Row.Cells.FromKey("GZLDX").AllowEditing = AllowEditing.No;
                    e.Row.Cells.FromKey("GZZLJXL").AllowEditing = AllowEditing.No;
                    e.Row.Cells.FromKey("ZXL").AllowEditing = AllowEditing.No;
                    e.Row.Cells.FromKey("TDXZ").AllowEditing = AllowEditing.No;
                    e.Row.Cells.FromKey("BMGXD").AllowEditing = AllowEditing.No;
                    e.Row.Cells.FromKey("PDXS").AllowEditing = AllowEditing.No;


                    //颜色Red,Green,Blue
                    int r = 192;
                    int g = 192;
                    int b = 192;

                    e.Row.Cells.FromKey("GJYJZB").Style.BackColor = Color.FromArgb(r, g, b);
                    e.Row.Cells.FromKey("GZLDX").Style.BackColor = Color.FromArgb(r, g, b);
                    e.Row.Cells.FromKey("GZZLJXL").Style.BackColor = Color.FromArgb(r, g, b);
                    e.Row.Cells.FromKey("ZXL").Style.BackColor = Color.FromArgb(r, g, b);
                    e.Row.Cells.FromKey("TDXZ").Style.BackColor = Color.FromArgb(r, g, b);
                    e.Row.Cells.FromKey("BMGXD").Style.BackColor = Color.FromArgb(r, g, b);
                    e.Row.Cells.FromKey("PDXS").Style.BackColor = Color.FromArgb(r, g, b);
                }
            }
        }

提交后结果展示:
Infragistics控件对UltraWebGrid单元格编辑进行控制及样式设置_第2张图片


外加提交后后台隐藏“保存”和“提交”按钮:

//隐藏保存和提交按钮
                    UltraWebToolbar1.Items.FromKeyButton("btnSave").Visible = false;
                    UltraWebToolbar1.Items.FromKeyButton("btnSend").Visible = false;



点击输入后,几个评分指标分数自动汇总到得分列:

表单第04行注册了事件,JS代码实现如下

function AfterCellUpdateHandler(gridName, itemName) {
                var grid = igtbl_getGridById(gridName);
                var row = igtbl_getRowById(itemName);
                var cell = igtbl_getCellById(itemName);
                var GJYJZB = row.getCellFromKey("GJYJZB").getValue();
                var GZLDX = row.getCellFromKey("GZLDX").getValue();
                var GZZLJXL = row.getCellFromKey("GZZLJXL").getValue();
                var ZXL = row.getCellFromKey("ZXL").getValue();
                var TDXZ = row.getCellFromKey("TDXZ").getValue();
                var BMGXD = row.getCellFromKey("BMGXD").getValue();
               
                var PJDF = eval(GJYJZB) + eval(GZLDX) + eval(GZZLJXL) + eval(ZXL) + eval(TDXZ) + eval(BMGXD);

                row.getCellFromKey("PJDF").setValue(PJDF);
        }


你可能感兴趣的:(Infragistics)