Java脚本循环DataGrid中的所有页面 [英] Java Script to loop all Pages in 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 havePageIndex
defined inDataGrid
, then the number of rows per page will be rendered in HTML client-side.
So, you will never get all the rows in theDataGrid
.
Solution
You need to loop through theDataSource
, from which you get the data.
It may beDataTable
orDataSet
.
Because at the time of Binding the data, it retrieves all the rows, but when you givePageIndex
, it only shows the defined number of rows.
So, catch theDataTable
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屋!