ext的radiogroup和checkgroup的setvalues

radiogroup和checkgroup重写的方法,实现了setvalues

 1Ext.override(Ext.form.CheckboxGroup, {
 2  getNames: function() {
 3    var n = [];
 4
 5    this.items.each(function(item) {
 6      if (item.getValue()) {
 7        n.push(item.getName());
 8      }

 9    }
);
10
11    return n;
12  }
,
13
14  getValues: function() {
15    var v = [];
16
17    this.items.each(function(item) {
18      if (item.getValue()) {
19        v.push(item.getRawValue());
20      }

21    }
);
22
23    return v;
24  }
,
25
26  setValues: function(v) {
27    var r = new RegExp('(' + v.join('|'+ ')');
28
29    this.items.each(function(item) {
30      item.setValue(r.test(item.getRawValue()));
31    }
);
32  }

33}
);
34
35Ext.override(Ext.form.RadioGroup, {
36  getName: function() {
37    return this.items.first().getName();
38  }
,
39
40  getValue: function() {
41    var v;
42
43    this.items.each(function(item) {
44      v = item.getRawValue();
45      return !item.getValue();
46    }
);
47
48    return v;
49  }
,
50
51  setValue: function(v) {
52    this.items.each(function(item) {
53      item.setValue(item.getRawValue() == v);
54    }
);
55  }

56}
);

posted on 2009-02-20 16:07  房客  阅读(1808)  评论(0编辑  收藏  举报

导航