javascript - Verify values in combo box exist or don't exist? -
how can verify items listed in combo box? example want check if combo box have "item1" "item2" "item3". how output options out , check?
here's how excess combobox:
ext.componentquery.query('combobox[name=boxname]')[0];
just access store of box , interrogate it. example:
var store = ext.componentquery.query('combobox[name=boxname]')[0].getstore(); console.log(store.getbyid('item1'));
if item1
not there result null
.
update:
based on conditions lets say, want able validate combo box has "item1" , "item2", not more or less.
given variable target
contains want in combo, can verify combo way:
var target = ['item1', 'item2'], combo = ext.componentquery.query('combobox[name=boxname]')[0], check = function(combo, target) { var store = combo.getstore(); if (target.length !== store.gettotalcount()) { return false; } var result = true; store.each(function(item){ if (!ext.array.contains(target, item.getid())) { result = false; return false; } }); return result; }; console.log(check(combo, target));
the method check
return true
if combo contains want, or false
otherwise.
Comments
Post a Comment