Java脚本循环DataGrid中的所有页面 [英] Java Script to loop all Pages in DataGrid

查看:61
本文介绍了Java脚本循环DataGrid中的所有页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人;



代码:

Dear All;

Code:

var grid = document.getElementById("<%= grdActivity.ClientID%>");
var inputs = grid.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
     if (inputs[i].name.indexOf("txtGridAmount") > 1) {
        if (inputs[i].value != "") {
           totalAmount = totalAmount + parseFloat(inputs[i].value);
        }
      }





我正在循环我的数据网格并添加一个Amount列并通过使用获得结果以上编码完美...但我有一些问题...



现在我得到了数据网格的正确循环和求和值。但我给了5行的datagrid一个pageindex。所以,一旦我进入第6行,我的脚本只添加当前页面行..



现在我需要在datagrid的所有页面中循环一列。



请指导我..提前致谢.. :-)等待你的回复



谢谢&安培;问候,

Ganesh。



I''m looping my datagrid and adding one Amount column and getting result by using the above codings Perfectly... But I have some problem with this ..

Now I''m getting the correct looped and summed value of the datagrid. But I have given a pageindex to datagrid with 5 rows. So once i''m entering 6th row my script only adding the current page row..

Now i need to loop one column in all the pages of datagrid..

Please guide me.. Thanks in advance .. :-) Waiting for your reply

Thanks & Regards,
Ganesh.

推荐答案

理想情况下,你不应该在javascript中这样做。为什么不使用gridview页脚显示摘要信息。查看此链接 http://msdn.microsoft.com/en-us/library/bb310552.aspx [ ^ ]



问候

Pawan
Ideally you should not be doing it in javascript. Why don''t you use the gridview footer to display summary information. check this linkt out http://msdn.microsoft.com/en-us/library/bb310552.aspx[^]

Regards
Pawan


问题

问题是当您在 DataGrid 中定义 PageIndex 时,每页的行数将在HTML客户端中呈现-b。



所以,你永远不会得到 DataGrid 中的所有行。



解决方案

你需要遍历 DataSource ,从中你得到了数据。

它可能是 DataTable DataSet

因为在绑定数据时,它会检索所有行,但是当你给出 PageIndex 时,它只显示定义的行数。



所以,在JavaScript中捕获 DataTable 并尝试循环。

参考 - 如果设置网格的分页属性,如何循环遍历网格中的所有项目 [ ^ ]



但是我找到了一些他们做过相同的链接就像你一样。

请检查他们到底做了什么。

1. 使用javascript循环遍历分页gridview的所有行 [ ^ ]。

2. 在javascript中循环数据网格? [ ^ ]。



谢谢......
Problem
The problem is when you have PageIndex defined in DataGrid, then the number of rows per page will be rendered in HTML client-side.

So, you will never get all the rows in the DataGrid.

Solution
You need to loop through the DataSource, from which you get the data.
It may be DataTable or DataSet.
Because at the time of Binding the data, it retrieves all the rows, but when you give PageIndex, it only shows the defined number of rows.

So, catch the DataTable in JavaScript and try to loop through that.
Refer - How to loop through all items in the grid when paging property for grid is set[^] for this concept.

But I found some links where they have done the same way as you did.
Please check what they are doing exactly.
1. Use javascript to loop through all rows of a paging gridview[^].
2. Loop through datagrid in javascript?[^].

Thanks...


这篇关于Java脚本循环DataGrid中的所有页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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