找回密码
 立即注册

QQ登录

只需一步,快速开始

aisiwo

注册会员

8

主题

18

帖子

56

积分

注册会员

积分
56

活字格认证

aisiwo
注册会员   /  发表于:2016-3-23 11:01  /   查看:3433  /  回复:5
如下JSON [
                   { name: "Alice", age: 27, birthday: "1985/08/31", position: "PM" },
                   { name: "Aimee", age: 28, birthday: "1984/07/31", position: "TL" },
                   { name: "Charles", age: 29, birthday: "1983/03/31", position: "QC" },
                   { name: "Fred", age: 30, birthday: "1982/02/20", position: "DL" },
                   { name: "Angelia", age: 31, birthday: "1981/05/30", position: "QC" },
                   { name: "Peter", age: 32, birthday: "1980/11/08", position: "QC" }
               ];

在ComBox下拉中显示,指定Name列绑定到Value上,或者把一行数据返回也可以

5 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-3-23 13:55:38
沙发
重新组合下您的数据源。 把内容放到value中
[{ text: "Alice", value: { name: "Alice", age: 27, birthday: "1985/08/31", position: "PM" } },
{ text: "Aimee", value: { name: "Aimee", age: 28, birthday: "1985/08/31", position: "PM" } },

回复 使用道具 举报
aisiwo
注册会员   /  发表于:2016-3-24 09:42:24
板凳
spread js 中Combox好像不支持这种JSON数据
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-3-24 12:22:30
地板
关键是这一行  eComboBoxCellType.editorValueType( GcSpread.Sheets.EditorValueType.Value);

  1.         var items2 =
  2. [
  3.     {
  4.         "text": "Alice",
  5.         "value": {
  6.             "name": "Alice",
  7.             "age": 27,
  8.             "birthday": "1985/08/31",
  9.             "position": "PM"
  10.         }
  11.     },
  12.     {
  13.         "text": "Aimee",
  14.         "value": {
  15.             "name": "Aimee",
  16.             "age": 28,
  17.             "birthday": "1985/08/31",
  18.             "position": "PM"
  19.         }
  20.     }
  21. ];
  22.             
  23. var eComboBoxCellType = new GcSpread.Sheets.ComboBoxCellType().items(items2).editable(true);
  24.             eComboBoxCellType.editorValueType( GcSpread.Sheets.EditorValueType.Value);
  25. activeSheet.getCell(1, 3).cellType(eComboBoxCellType);
  26. activeSheet.setColumnWidth(3,120);

  27.     };
  28.     function Get(){
  29.            var activeSheet = spread.getActiveSheet();
  30.          alert( JSON.stringify( activeSheet.getCell(1,3).value()));
  31.     }
复制代码
回复 使用道具 举报
aisiwo
注册会员   /  发表于:2016-4-4 14:20:00
5#
QQ图片20160404141900.png
显示不出啦
    var items2 =
[
    {
        "text": "Alice",
        "value": {
            "name": "Alice",
            "age": 27,
            "birthday": "1985/08/31",
            "position": "PM"
        }
    },
    {
        "text": "Aimee",
        "value": {
            "name": "Aimee",
            "age": 28,
            "birthday": "1985/08/31",
            "position": "PM"
        }
    }
];
            
var eComboBoxCellType = new GcSpread.Sheets.ComboBoxCellType().items(items2).editable(true);
            eComboBoxCellType.editorValueType( GcSpread.Sheets.EditorValueType.Value);
activeSheet.getCell(1, 3).cellType(eComboBoxCellType);
activeSheet.setColumnWidth(3,120);

    };
    function Get(){
           var activeSheet = spread.getActiveSheet();
         alert( JSON.stringify( activeSheet.getCell(1,3).value()));
    }
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2016-4-5 10:59:02
6#
什么意思,什么显示不出来?
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部