Conditionally show a child table column in list view

Hello All,

How to conditionally show or hide a column in child table, please find the below example from routing.js ( erpnext )

frappe.ui.form.on(“Routing”, {

refresh: function (frm) {
	frm.trigger("display_sequence_id_column");
},

onload: function (frm) {
	frm.trigger("display_sequence_id_column");
},

display_sequence_id_column: function (frm) {
	let show = true;
	frm.fields_dict.operations.grid.update_docfield_property("sequence_id", "in_list_view", show ? 1 : 0);
},

}

currently frm.fields_dict.operations.grid.update_docfield_property(“sequence_id”, “in_list_view”, 1); works only after manually clicking this “reset to default” else it does not work.

let show = true; // in my scenario this is based on a value from a checkbox field.
based on the selection without resetting columns how can we dynamically show or hide columns of child table based on the checkbox value?


Thanks in adv.

frappe.ui.form.on(‘Delivery Note’, {
refresh: function(frm) {
item_reorder(frm)
}
});

function item_reorder(frm) {
const custom_type = frm.doc.custom_type;
const child_table = frm.doc.doctype + " Item"
let sub_assembly_list_view = {};
sub_assembly_list_view[child_table] = [
{
“fieldname”: “item_code”,
“columns”: 2
},
{
“fieldname”: “warehouse”,
“columns”: 3
},
{
“fieldname”: “item_name”,
“columns”: 1
},
{
“fieldname”: “qty”,
“columns”: 1
},
{
“fieldname”: “custom_qty_per_pack”,
“columns”: 2
},

]
frappe.model.user_settings.save(frm.doctype, "GridView", sub_assembly_list_view).then((r) => {
    frappe.model.user_settings[frm.doctype] = r.message || r;
    frappe.after_ajax(() => {
        frm.fields_dict.items.grid.reset_grid();
        frm.fields_dict.items.grid.refresh();
    });
    frm.refresh_fields("items")
});

}