Show Hide QueryType options

Hi,

I want to hide options from Query Type Dropdown, If I select part from grid then only (Current and Release should be visible).

So for that I tried this way: 

Code in ItemsGrid.html file, I call a function inside initMenu() function.

below is my code: 

function dr_showHideQueryType(itemTypeName){

Current = getChoiceItemName(0);
Latest = getChoiceItemName(1);
Released = getChoiceItemName(2);
Effective = getChoiceItemName(3);

var opts = [];
opts[Current] = false;
opts[Released] = false;
opts[Latest] = false;
opts[Effective] = false;

if(itemTypeName === "Part"){
opts[Current] = true;
opts[Released] = true;
}
else{
opts[Current] = true;
opts[Released] = true;
opts[Latest] = true;
opts[Effective] = true;
}
for (opt in opts) {
if (!opts[opt]) {
removeChoiceItem(opt);
}
}
}
function getChoiceItemName(id) {
var tbi = searchbar.getActiveToolbar().getItem("query_type");
var tbi_id = tbi.getItem(id);
return tbi_id;
}
function removeChoiceItem(name) {
if (name == undefined) {
return;
}
var query_type_tbi = searchbar.getActiveToolbar().getItem("query_type");
try {
query_type_tbi.remove(name);
}
catch (e) { }
}

But not able to achieve the expected behaviour, is anything i'm missing.

Regards,

Maddy.