用combobox做显示, 当该字段值为空时, 理应显示空白,但是却显示的是默认为0的值, 或者值为0所对应的选项. 请问该如何解决~~~~~~~~~~~~~ 急~~~~~~~~~~~

解决方案 »

  1.   

    如果数据库值为null时  你后台返回的数据是什么 发一段后台返回的数组上来看看
    另外:把你的combox的定义部分也发上来
      

  2.   

    实际情况是,我导入一个对象,该对象某个字段展现方式为 combobox , 导入时,该字段为空.
    修改该对象时,弹出修改窗口,为 combobox 却显示的是0或者是0对应的选项文本.{
    xtype : 'combo',
    fieldLabel : '<span style="color: red; vertical-align: middle;">*</span> 业务类型',
    hiddenName : 'busnTypeID',
    triggerAction : 'all',
    displayField : 'busnType',
    valueField : 'busnTypeID',
    editable : false,
    store : new Ext.data.JsonStore({
    autoLoad : true,
    url : APPBASE
    + '/CaseLibraries.do?method=findCFGBusinessTypeversion',
    fields : ['busnTypeID', 'busnType']
    })
    }
      

  3.   

    把这种情况下后台往前台传的json发下
      

  4.   

    JSONObject.fromObject看了下json
    这个方法把所有值为NULL的字段全部初始化为0了...
    谷歌了一下据说这样处理:jsonConfig.registerDefaultValueProcessor(Integer.class,
    new DefaultValueProcessor() {
    public Object getDefaultValue(Class type) {
    return null;
    }
    });
    使其当为Integer类型时,数据库为NULL时还是返回NULL,
    但是好像测试了下没效果不知道哪里错了
      

  5.   

    在jsonConfig 注册defaultValueProcessor 
    // 设置Integer类型为空的默认值 json-lib默认是0
    jsonConfig.registerDefaultValueProcessor(Integer.class,
    new DefaultValueProcessor() {
    public Object getDefaultValue(Class type) {
    return null;
    }
    });这样转换时Integer类型如果为null转换还是null,不会被转为0 
    我加在静态块里面,重启服务后,还是没反映...仍然是返回0
      

  6.   

    解决了  JSONObject.fromObject(fb,jsonConfig) 
    此时应该将jsonConfig 配置进来.  立即生效....