[解决]使用JavaScript计算网格列 [英] [Solved] Calculating grid columns using javascript

查看:55
本文介绍了[解决]使用JavaScript计算网格列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码通过javascript计算网格列值.
它工作正常,但问题是它没有计算网格的最后一列.
如果有人可以在此问题上为我提供帮助,我将不胜感激.
我的代码:

I am using the code below to calculate grid column values using javascript.
It is working fine, but the problem is it wasn''t calculating the last column of the grid.
I''d appreciate it if anyone couuld help me in this issue.
My code:

Private Sub GD_Prod_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles GD_Prod.ItemCreated
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item(), GridDataItem)
        For Each item In GD_Prod.Items
            Dim txtbox1 As TextBox = DirectCast(item.FindControl("TxtSTUPort"), TextBox)
            Dim txtbox2 As TextBox = DirectCast(item.FindControl("TxtAAPort"), TextBox)
            Dim txtbox3 As TextBox = DirectCast(item.FindControl("STD_NUM_OF_SERVING"), TextBox)
            txtbox1.Attributes.Add("onblur", "show('" & txtbox1.ClientID & "','" & txtbox2.ClientID & "','" & txtbox3.ClientID & "');")
            txtbox2.Attributes.Add("onblur", "show('" & txtbox1.ClientID & "','" & txtbox2.ClientID & "','" & txtbox3.ClientID & "');")
            txtbox3.Attributes.Add("readonly", "readonly")
        Next
    End If
End Sub




Javascript代码:




Javascript code:

function show(TxtSTUPort, TxtAAPort, STD_NUM_OF_SERVING) {
    var TxtSTUPort = document.getElementById(TxtSTUPort);
    var TxtAAPort = document.getElementById(TxtAAPort);
    var STD_NUM_OF_SERVING = document.getElementById(STD_NUM_OF_SERVING);
    STD_NUM_OF_SERVING.value = parseInt(TxtSTUPort.value) + parseInt(TxtAAPort.value);
    if (!parseInt(STD_NUM_OF_SERVING.value)) {
        STD_NUM_OF_SERVING.value = '0';
    }
    // function is broken there is no closing brace to finish
    // the function and there seems to be some stuff missing



更新:
由OP自己解决.



UPDATE:
Solved by OP himself. Posted as an answer.

推荐答案

问题已解决.

代替使用

如果TypeOf e.Item是GridDataItem,则
昏暗的项目为GridDataItem = DirectCast(e.Item(),GridDataItem)

我将代码替换为

对于GD_Prod.Items中的每个项目作为GridDataItem
Issue is resolved.

Instead using

If TypeOf e.Item Is GridDataItem Then
Dim item As GridDataItem = DirectCast(e.Item(), GridDataItem)

I replace code with

For Each item As GridDataItem In GD_Prod.Items


这篇关于[解决]使用JavaScript计算网格列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆