Table field in dialog

I am using a table field in dialog , as below code

var add_template_variants = function(frm){
var data=;
var d = new frappe.ui.Dialog({
title: __(“Get Template Variants”),
fields: [{
fieldtype: ‘Link’,
label: __(‘Item’),
fieldname: ‘item’,
options: ‘Item’,
get_query: function() {
return {
filters: {
‘has_variants’: ‘1’
}
}
},
change: ()=> {

        }
    },
    {fieldtype: 'Button', label: __('Get Variants'), fieldname: 'get_variants',
        click: () =>{
            if (d.get_values().item){
                frappe.call({
                    method: "dimensions.dimensions_util.get_template_variants",
                    args: {
                        template: d.get_values().item
                    },
                    callback: function(res){
                        if (res && res.message){
                            //d.fields_dict.variants.grid.wrapper.find('.grid-remove-rows').hide(); 
                            for (var i = 0; i<res.message.length; i=i+1) {
                                d.fields_dict.variants.df.data.push(
                                    {
                                        'item': res.message[i]
                                    }
                                )
                                
                            }
                            d.fields_dict.variants.grid.refresh();
                        }
                    }
                })
            }
        }
    },
    {fieldtype:'Section Break', label: __('Batches')},
    {fieldname: 'variants', fieldtype: 'Table', label: __('Template Variants'),
        fields: [
            {fieldtype: 'Data', label: __('Item'), fieldname: 'item', in_list_view: 1, read_only: 0}
        ],
        data: [],
        get_data: function() {
            return data;
        },
        variants_remove: function() {
            console.log('removing');
        }
    }],

and I have 2 problems with it.
1- the table delete button always deletes the last row not the selected row(s).
2- the remove trigger is not working

i appreciate your support

1 Like