2017-05-26 76 views
0

我试图在ExtJS中组单选按钮,而不使用相同的name配置。这可能吗?这是我的代码:使用不同的名称分组ExtJS单选按钮以不同的名称保存在数据库中

items: 
    [ 
     { 
      xtype: 'radio', 
      name: 'is_self_employed', 
      boxLabel: 'Self Employed:' 
     }, 
     { 
      xtype: 'radio', 
      name: 'is_voluntary', 
      boxLabel: 'Voluntary:' 
     }, 
     { 
      xtype: 'radio', 
      name: 'is_ofw', 
      boxLabel: 'OFW:' 
     }, 
     { 
      xtype: 'radio', 
      name: 'is_non_working_spouse', 
      boxLabel: 'Non Working Spouse:' 
     }, 
     { 
      xtype: 'radio', 
      name: 'is_farmer_or_fisherman', 
      boxLabel: 'Farmer or Fisherman:' 
     } 

    ] 
+2

的名称必须是相同的,如果你希望他们作为一个群体。使用'inputValue'来指定值。 –

回答

1
你想

单选按钮?

单选按钮按其名称分组,除非您执行一些JS代码来修复您破坏的内容,否则它们将会破坏它们的功能。

0

最好的方法是为所有收音机设置相同的名称并为每个收音机设置不同的inputValue。

另一种可能的实现方式是在启用其他单选按钮时手动取消选中其他单选按钮。

listeners: { 
    change: function(rd, value) { 
     if (value) { 
      var radios = rd.up("form").query("radio"); 
      Ext.each(radios, function(r) { 
      if (r != rd) 
       r.setValue(false); 
      }); 
     } 
    } 
    } 

小提琴:http://jsfiddle.net/gilsha/s48FD/51/

相关问题