找回密码
 立即注册

QQ登录

只需一步,快速开始

cgh_chen

初级会员

47

主题

182

帖子

471

积分

初级会员

积分
471

活字格认证微信认证勋章

cgh_chen
初级会员   /  发表于:2016-5-2 15:13  /   查看:3140  /  回复:3
根据文档,知道无法通过直接在JSON中设置cell的tag,是否有考虑支持?什么版本支持
Adding a Tag to a Cell


Collapse All
SpreadJS Documentation > Developer's Guide > Managing Data > Adding a Tag to a Cell

You can use a tag to store data in a cell, column, row, or sheet. Tags can store any type of data and are not visible to the user.
You can remove tags with the clear method. Tags can be cut, copied, pasted, or moved.
If the tag type is a string, then the tag can be searched. Tags are supported with undo and redo. Basic tags are supported when importing or exporting to JSON files. Custom tags are not supported when importing or exporting to JSON files.
Adding tags can also cause the CellChanged, ColumnChanged, or RowChanged event to occur.
Using CodeThe following code adds a tag to a cell with the setTag method.
JavaScriptCopy Code
activeSheet.setTag(1,1,"test");
alert(activeSheet.getTag(1,1,GcSpread.Sheets.SheetArea.viewport));




3 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-5-3 11:10:58
沙发
本帖最后由 dexteryao 于 2016-5-3 11:13 编辑

Tags are supported with undo and redo. Basic tags are supported when importing or exporting to JSON files.

使用 activeSheet.getCell(0,0).tag({abc:111})设置的tag是可以超出json并导入的。
custom tags 的序列号参考
http://sphelp.grapecity.com/webh ... #serialization.html
回复 使用道具 举报
cgh_chen
初级会员   /  发表于:2016-5-3 11:22:11
板凳
谢谢!
//Custom tag
        function MyTag(name, age) {
            this.name = name;
            this.age = age;
            this.typeName = "MyTag";
        }
        MyTag.prototype.toJSON = function () {
            var settings = {};
            settings.name = this.name;
            settings.age = this.age;
            settings.typeName = this.typeName;
            return settings;
        };
        MyTag.prototype.fromJSON = function (settings) {
            this.name = settings.name;
            this.age = settings.age;
            this.typeName = settings.typeName;
        };
        $(function () {
var spread1 = new GcSpread.Sheets.Spread($("#ss").get(0),{sheetCount:3});
            var sheet1 = spread1.getActiveSheet();
            sheet1.tag(new MyTag("Ivy", 24));
            sheet1.setTag(0, 0, new MyTag("Yang", 25));
            $("#btn1").click(function () {
                //Serialize ss to ss1.
                var jsonStr = JSON.stringify(spread1.toJSON());
               
var spread2 = new GcSpread.Sheets.Spread($("#ss1").get(0),{sheetCount:3});
                spread2.fromJSON(JSON.parse(jsonStr));
                var sheet2 = spread2.getActiveSheet();
                alert("Tag of sheet:" + JSON.stringify(sheet2.tag()));
                alert("Tag of Cell[0,0]: " + JSON.stringify(sheet2.getTag(0, 0)));
            });
        });
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-5-3 12:19:52
地板
不客气
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部