找回密码
 立即注册

QQ登录

只需一步,快速开始

iamcunwei

论坛元老

12

主题

40

帖子

7440

积分

论坛元老

积分
7440

活字格认证

iamcunwei
论坛元老   /  发表于:2014-5-5 16:04  /   查看:7245  /  回复:5
如题,我后台绑定了数据源到c1gridview(非wijmo),想通过鼠标在单元格上双击弹出窗体并且取得点击单元格的内容,点击不同单元格获取相应的单元格内容(不是指定某列单元格内容string str = e.Row.Cells[3].Text;)。我使用了以下js取单元格内容,怎么取不出来呢,请高手赐教

evt = window.event ? window.event.srcElement : e.target;
if (evt.tagName != "TD") { evt = evt.parentNode; }
if (evt.tagName != "TD") return; c = evt.cellIndex;
if (evt.tagName != "TR") { evt = evt.parentNode; } r = evt.rowIndex;
alert(" 点击的行数是:" + r + " 列数:" + c)
var gdview = document.getElementById("<%=C1GridView1.ClientID %>");
alert(gdview.rows(r).cells(c).value); //弹出指定行单元格的值

5 个回复

倒序浏览
roger.wang
社区贡献组   /  发表于:2014-5-5 17:23:00
沙发
回复 1楼iamcunwei的帖子

  1. function Button1_onclick() {
  2.             var cell = $(&quot;#C1GridView2&quot;).c1gridview(&quot;currentCell&quot;);
  3.             cell.value(&quot;123&quot;);

  4.             var data = $(&quot;#C1GridView2&quot;).c1gridview(&quot;data&quot;);  //获得全部的单元格
  5.             data[2][2] = &quot;333&quot;;  //指定2,2单元格数据为333
  6.             //cell.column().readOnly = false;
  7.             $(&quot;#C1GridView2&quot;).c1gridview({ allowEditing: true });
  8.             $(&quot;#C1GridView2&quot;).c1gridview(&quot;beginEdit&quot;);
  9.             $(&quot;#C1GridView2&quot;).c1gridview(&quot;endEdit&quot;);
  10.         }
复制代码


C1GridView的前端(JS),同Wijimo; 更多信息,请参考wijimo API:
http://helpcentral.componentone. ... ntsidereference.htm
http://wijmo.com/docs/wijmo/#Wij ... Info~tableCell.html
http://wijmo.com/docs/wijmo/#UpdateDatainWijgrid.html
回复 使用道具 举报
iamcunwei
论坛元老   /  发表于:2014-5-6 17:38:00
板凳
请老师给个工程例子吧,我还是不太明白。我的c1gridview放在母板页里的updatepanel里的。是不是取id的时候用"<%=C1GridView1.ClientID %>"
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-5-7 09:12:00
地板
回复 3楼iamcunwei的帖子

请问,2#的代码尝试过了吗?

  1. var data = $(&quot;#C1GridView2&quot;).c1gridview(&quot;data&quot;);  //获得全部的单元格
复制代码

这个是获取C1GriView单元格的,用JQuery的方法获取。
回复 使用道具 举报
iamcunwei
论坛元老   /  发表于:2014-5-8 08:30:00
5#
找到了一个办法就是通过后台C1GridView1_RowDataBound来给单元格添加弹出窗体事件取出单元格的值
for (int i = 0; i &lt; C1GridView1.Columns.Count; i++)
{
str = e.Row.Cells[2].Text + &quot;$&quot; + e.Row.Cells[3].Text + &quot;$&quot; + e.Row.Cells[n].Text;
e.Row.Cells[n].Attributes.Add(&quot;OnDblClick&quot;, &quot;ShowDialog('&quot; + Server.UrlEncode(str) + &quot;')&quot;);
}
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-5-8 09:24:00
6#
回复 5楼iamcunwei的帖子

谢谢您的分享  
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部