如何在客户端计算RadGrid单元格值?
我有处于编辑模式的 telerik RadGrid。 每个单元格都包含 NumericTextBox。 是否可以根据同一行(客户端)中的其他单元格计算一个单元格。 例如,如果我有一行包含价格和商品等单元格,我希望每次更改时都计算总价,但在客户端,而不是到服务器端。 RadGrid 可以做到这一点吗?
I have telerik RadGrid which is in edit mode. Each cell contains NumericTextBox. Is it possible to calculate one cell based on other cells in the same row (on client side).
For example if I have a row which contains cells like price and item I want on every change to calculate total price but on client side, without going to server side. Is this possible with RadGrid?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
感谢您的所有回答,但我在这里找到了解决方案 telerik论坛。 我将把解决方案粘贴在这里,以防有人遇到同样的问题。
ASPX:
C#
JavaScript:
Thanks for all your answers but I found the solution here at telerik forum. I'll just paste the solution here in case that somebody get stuck on the same issue.
ASPX:
C#
JavaScript:
因为每个项目都在表行中,所以您可以使用 javascript 查找父项目,然后循环遍历所有输入以找到您要查找的项目? 如果你打算使用 jQuery,这应该是可能的,如果你想轻松区分文本框,你可以将 CssClass 应用于每个 TextBox?
Because each item is in a table row you could use javascript to find the parent item and then loop through all the inputs to find the ones you are looking for? If you are going to use jQuery this should be possible and if you wanted to distinguish the textboxes easily you could apply a CssClass to each TextBox?
查看来自 RadGrid 的 Telerik 网站上的演示 -> 应用场景部分使用数字文本框并说明您正在寻找的内容,伙计。
迪克
Check out the demo on the Telerik site from RadGrid -> Application scenarios section which uses numeric textboxes and illustrates what you are looking for, dude.
Dick
如果您也通过客户端绑定(最有可能通过 AJAX)获取数据,这是可能的。 如果是这样,您应该能够从网格的数据源属性中获取所有值。 如果绑定数据服务器端,它会变得更困难,因为当前网格在这种情况下不会构建客户端数据源。
It is possible provided you got the data through client side binding as well, most likely through AJAX. If so, you should be able to get all values from the datasource property of the grid. If you bind the data server side it gets harder because currently the grid does not build the client side datasource in this case.