2017-05-26 72 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/

相關問題