Filter by “item_group” in child table “item”

I am trying to do some customisation in ERP Next Quotation Module,
Wherein Once the user select an Item Group only those items should be displayed which are under that Item group.

I have changed the Quotation Item doc type to Show Item group 1st and made it mandatory, and show in list view, grid view also i have umarked it as hidden and read only and then saved it.

In quoation item doctype I also have changed the Item code to be fetched from “item_group:item_code”

I have also added a custom script in quoation-item doc type as below
“frappe.ui.form.on(‘Quotation Item’, {
refresh(frm) {
cur_frm.add_fetch(‘item_group’,‘item’,‘item’);
}
})”

Now, When I select the item group, it still shows me all the items, not the items under that particular item group.

Any help on this will be highly appreciated.

You should try to apply custom script for child table, and you need to use filter and not fetch

solved via

frappe.ui.form.on("Quotation", "refresh", function(frm) {
frm.fields_dict['items'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
    var child = locals[cdt][cdn];
    //console.log(child);
    return {    
        filters:[
            ['Item', 'item_group', '=', child.item_groups]
        ]
    };
};

});