找回密码
 立即注册

QQ登录

只需一步,快速开始

usst

注册会员

18

主题

48

帖子

134

积分

注册会员

积分
134

活字格认证元老葡萄

[已处理] 右击功能实现

usst
注册会员   /  发表于:2016-3-23 10:43  /   查看:4785  /  回复:9
https://yunpan.cn/cYIiZ2yfyFTXJ  访问密码 ba7f,这是demo的链接

9 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-3-23 11:00:05
沙发
请问有什么问题需要解决?
回复 使用道具 举报
usst
注册会员   /  发表于:2016-3-23 21:26:45
板凳
dexteryao 发表于 2016-3-23 11:00
请问有什么问题需要解决?

我的右击复制粘贴不能实现
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-3-25 11:19:12
地板
您好,很抱歉回复晚了。因为spread的id可以能会变,所有建议写成如下方式
  1.     <script>

  2.         function CopyCell() {
  3.              var spread1 = document.getElementById("<%=FpSpread1.ClientID %>");

  4.             spread1.CopyLikeExcel();
  5.         }
  6.         function PasteCell() {
  7.              var spread1 = document.getElementById("<%=FpSpread1.ClientID %>");

  8.             spread1.PasteLikeExcel();
  9.         }
  10.         function CutCell() {
  11.              var spread1 = document.getElementById("<%=FpSpread1.ClientID %>");

  12.             spread1.CutLikeExcel();
  13.         }

  14.     </script>
复制代码
回复 使用道具 举报
usst
注册会员   /  发表于:2016-3-28 07:11:39
5#
dexteryao 发表于 2016-3-25 11:19
您好,很抱歉回复晚了。因为spread的id可以能会变,所有建议写成如下方式

写成这样也是不可以的 ,希望您能看下我写的例子,复制粘贴功能都不能实现
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-3-28 09:11:32
6#
我就是直接在你demo上改的。
Test.zip (47.33 KB, 下载次数: 150)
回复 使用道具 举报
usst
注册会员   /  发表于:2016-3-28 20:19:09
7#
dexteryao 发表于 2016-3-28 09:11
我就是直接在你demo上改的。

您在那些地方做了修改
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-3-29 09:18:04
8#
usst 发表于 2016-3-28 20:19
您在那些地方做了修改

你Master里也有段 和页面里重复了,得删掉
  1. <script>
  2.                 function CopyCell() {
  3.                     FpSpread1.CopyLikeExcel();
  4.                 }
  5.                 function PasteCell() {
  6.                     FpSpread1.PasteLikeExcel();
  7.                 }
  8.                 function CutCell() {
  9.                     FpSpread1.CutLikeExcel();
  10.                 }

  11.             </script>
复制代码
回复 使用道具 举报
usst
注册会员   /  发表于:2016-3-29 14:42:35
9#
麻烦您把右击实现粘贴的功能实现的步骤,写个文档给我。还有是不是表格比较大时,这个不好实现?
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-3-29 17:14:25
10#
粘贴复制功能和表格大小没有关系。

步骤
1. 后台设置
  1. FpSpread1.EnableContextMenu = true;
复制代码

2,添加右键菜单
  1.   <ContextMenus>
  2.                     <FarPoint:ContextMenu Type="Viewport" ShowDefaultContextMenu="True">
  3.                         <Items>
  4.                             <FarPoint:MenuItem Enabled="True" Text="Copy" OnClientClick="CopyCell"></FarPoint:MenuItem>
  5.                             <FarPoint:MenuItem Enabled="True" Text="Paste" OnClientClick="PasteCell"></FarPoint:MenuItem>
  6.                             <FarPoint:MenuItem Enabled="True" Text="Cut" OnClientClick="CutCell"></FarPoint:MenuItem>
  7.                         </Items>
  8.                     </FarPoint:ContextMenu>
  9.                 </ContextMenus>
复制代码

3.添加js代码
  1.     <script>
  2.         function CopyCell() {
  3.             var spread1 = document.getElementById("<%=FpSpread1.ClientID %>");

  4.             spread1.CopyLikeExcel();
  5.         }
  6.         function PasteCell() {
  7.             var spread1 = document.getElementById("<%=FpSpread1.ClientID %>");

  8.             spread1.PasteLikeExcel();
  9.         }
  10.         function CutCell() {
  11.             var spread1 = document.getElementById("<%=FpSpread1.ClientID %>");

  12.             spread1.CutLikeExcel();
  13.         }
  14.     </script>
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部