您好,
非常抱歉,Spead JS没有提供原生的接口,支持 浮动对象调转的方法。
但是,可以使用addEventListener的方式,自定义实现。可以参考以下代码:
- $(document).ready(function() {
- var spread = new GcSpread.Sheets.Spread($("#ss").get(0), {
- sheetCount: 3
- });
- initSpread(spread);
-
- var activeSheet = spread.getActiveSheet();
-
- document.addEventListener("mousedown", function (event) {
- var spread = $("#ss").data("spread");
- var sheet = spread.getActiveSheet();
- var hitTestResult = sheet.hitTest(event.clientX, event.clientY);
- if (hitTestResult.floatingObjectHitInfo) {
- var floatingOjbect = hitTestResult.floatingObjectHitInfo.floatingObject;
- event.preventDefault();
- event.stopPropagation();
- window.location.href='http://gcdn.gcpowertools.com.cn/';
- }
- }, true);
- });
-
- function initSpread(spread) {
- var spreadNS = GcSpread.Sheets;
-
- var sheet = spread.getSheet(0);
- sheet.isPaintSuspended(true);
- var customFloatingObject = new spreadNS.CustomFloatingObject("f0");
- customFloatingObject.startRow(1);
- customFloatingObject.startColumn(1);
- customFloatingObject.endColumn(6);
- customFloatingObject.endRow(6);
- var div = document.createElement('div');
- div.innerHTML = "<span>SpreadJS support CustomFloatingObject.</span><div style='border: 1px dotted red; width: 80%; margin:auto;'><ul><li>I am list one.</li><li>I am list two.</li><li>I am list three.</li></ul></div>";
- $(div).css('background', 'gray');
- customFloatingObject.Content(div);
- sheet.addFloatingObject(customFloatingObject);
- sheet.isPaintSuspended(false);
- };
- </script>
复制代码 |