找回密码
 立即注册

QQ登录

只需一步,快速开始

jackeeyoung

初级会员

23

主题

55

帖子

355

积分

初级会员

积分
355
jackeeyoung
初级会员   /  发表于:2016-2-5 11:53  /   查看:5549  /  回复:4
SpreadJSDesigner如何设置为数字类型

4 个回复

倒序浏览
gw0506
超级版主   /  发表于:2016-2-5 12:18:00
沙发
Designer里面设置的仅仅是设置Format,输入数字的话,会用设置的格式来显示。

如果你要做NumberCellType,可以自定义一个单元格,实现2,3个接口就可以实现。不过不能通过Designer设置,除非改Designer的源码。

帮助文档中有详细介绍,还有示例代码。
SpreadJS Documentation > Developer's Guide > Managing the User Interface > Working with Cell Types > Setting a Custom Cell
回复 使用道具 举报
jackeeyoung
初级会员   /  发表于:2016-2-5 14:54:00
板凳
1.能否给一个number类型的实例
2.如果在代码里面怎么对cell进行Format成number
回复 使用道具 举报
jackeeyoung
初级会员   /  发表于:2016-2-5 14:54:00
地板
怎么写
回复 使用道具 举报
gw0506
超级版主   /  发表于:2016-2-5 18:01:00
5#
给你的文档里有自定义的办法,你根据实际需要实现几个接口就可以。
另外,有一个RadioCellType的例子,供你参考:
  1.         var spreadNS = GcSpread.Sheets;
  2.         $(document).ready(function ()
  3.         {
  4.             var spread = new GcSpread.Sheets.Spread(document.getElementById("ss"));
  5.             initSpread(spread);
  6.         });

  7.         function RadioCellType()
  8.         {
  9.         }
  10.         RadioCellType.prototype = new spreadNS.CustomCellType();

  11.         RadioCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options)
  12.         {
  13.             spreadNS.CustomCellType.prototype.paint.apply(this, [ctx, value, x, y, w, h, style, options]);
  14.         };

  15.         RadioCellType.prototype.createEditorElement = function ()
  16.         {
  17.             var div = document.createElement("div");
  18.             var $div = $(div);
  19.             $div.attr("gcUIElement", "gcEditingInput");
  20.             $div.css("background-color", "white");
  21.             $div.css("position", "absolute");
  22.             $div.css("overflow", "hidden");
  23.             $div.css("border", "2px #5292f7 solid");
  24.             var $input1 = $("<input type='radio' name='gender' value='male'/>Male<br>");
  25.             var $input2 = $("<input type='radio' name='gender' value='female'/>Female<br>");
  26.             $div.append($input1);
  27.             $div.append($input2);
  28.             return div;
  29.         };

  30.         RadioCellType.prototype.getEditorValue = function (editorContext)
  31.         {
  32.             if (editorContext &amp;&amp; editorContext.children.length === 4)
  33.             {
  34.                 var input1 = editorContext.children[0];

  35.                 var input2 = editorContext.children[2];

  36.                 if (input1.checked == true)
  37.                     return "male"

  38.                 if (input2.checked == true)
  39.                     return "female"
  40.             }
  41.         };

  42.         RadioCellType.prototype.setEditorValue = function (editorContext, value)
  43.         {
  44.             if (editorContext &amp;&amp; editorContext.children.length === 4)
  45.             {
  46.                 var input1 = editorContext.children[0];
  47.                 var input2 = editorContext.children[2];
  48.                 if (value == "male")
  49.                 {
  50.                     input1.setAttribute("checked", true)
  51.                 } else
  52.                 {
  53.                     input2.setAttribute("checked", true)
  54.                 }


  55.             }
  56.         };

  57.         RadioCellType.prototype.isEditingValueChanged = function (oldValue, newValue)
  58.         {
  59.             if (newValue != oldValue)
  60.             {
  61.                 return true;
  62.             }
  63.             return false;
  64.         };

  65.         RadioCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect)
  66.         {
  67.             if (editorContext)
  68.             {
  69.                 $(editorContext).width(cellRect.width);
  70.                 $(editorContext).height(100);
  71.             }
  72.         };
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部