Cutom script for the problem

I am new in ERPNext I want custom script for filter by item group.as I have uploaded a picture I want the all the item codes of item group of consumable by creating the new rows.please suggest script to solve this.

cur_frm.fields_dict['items'].grid.get_field('item_code').get_query = function(doc) {
    return {
        filters: [[
            'Item', 'item_group', '=', doc.item_group
        ]]
    }
};

not working.tried this before.I want the all item codes of item group consumable in separate row.

frappe.ui.form.on("Quotation", "refresh", function(frm) {cur_frm.fields_dict['items'].grid.get_field('item_code').get_query = function(doc) {
        return {
            filters: [[
                'Item', 'item_group', '=', doc.item_group
            ]]
        }
    };
});

actually I think onchange event is required tofetch records