zoukankan      html  css  js  c++  java
  • JqueryGridview模板列求和

    gridview中模板列TextBox求和赋值给一个TextBox(txt总维修金额)

    html:

    <Chsoft:SmartGridView ID="gv设备_外协维修合同明细" runat="server" Width="100%" IsShowIndexColumn="true" DataKeyNames="外协维修合同明细ID" AllowPaging="false"
    IsShowExcelLinkButton
    ="false" IsSinglePageDataMode="False"
    UnExportColumns
    ="操作">
    <Columns>
    <asp:TemplateField HeaderText="材料费用">
    <ItemStyle HorizontalAlign="Right" Width="80px" />
    <ItemTemplate>
    <Chsoft:SmartNumericTextBox ID="txt材料费用" DecimalSeparator="Dot" IsAllowDecimals="true"
    Width
    ="60px" runat="server" MaxLength="10" CssClass="class材料费用" IsAllowNegative="false"></Chsoft:SmartNumericTextBox>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="人工费用">
    <ItemStyle HorizontalAlign="Right" Width="80px" />
    <ItemTemplate>
    <Chsoft:SmartNumericTextBox ID="txt人工费用" DecimalSeparator="Dot" IsAllowDecimals="true"
    Width
    ="60px" runat="server" MaxLength="10" CssClass="class人工费用" IsAllowNegative="false"></Chsoft:SmartNumericTextBox>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </Chsoft:SmartGridView>

    JsCode:

    <script language="javascript" type="text/javascript">
    Sys.Application.add_load(function () {
    var classDiscount = $("#<%=gv设备_外协维修合同明细.ClientID %>").contents().find(".class材料费用");
    classDiscount.keyup(function () {
    ChangeText($(this));
    });
    var classDiscount = $("#<%=gv设备_外协维修合同明细.ClientID %>").contents().find(".class人工费用");
    classDiscount.keyup(function () {
    ChangeText($(this));
    });
    function ChangeText(target) {
    var txt总维修金额 = $("#<%=txt总维修金额.ClientID %>");
    if (target.val() != "0") {
    var con = $("#<% =gv设备_外协维修合同明细.ClientID %> :text");
    var count = 0;
    for (var i = 0; i < con.length; i++) {
    count = Number(count) + Number(con[i].value);
    }
    txt总维修金额.val(count);
    }
    }
    });
    </script>
  • 相关阅读:
    Chapter 2 JavaScript Basic
    第一感觉:依赖注入读书笔记之一(草稿版)
    JQuery IN ACTION读书笔记之一: JQuery选择器
    使用Razor
    非侵入式Ajax
    QT定制有标题的扁平化下拉框控件
    JavaScript之this,new,delete,call,apply
    实例解析C++虚表
    Python解析生成XML-ElementTree VS minidom
    从Python传递JSON到JavaScript
  • 原文地址:https://www.cnblogs.com/shenyixin/p/2305458.html
Copyright © 2011-2022 走看看