Child Table Field data type change based on the adjacent selection field

Hi all,

I am using a child table in the parent doctype in which I have two fields in the child table one with select data type and another with blank field to store the relevant information. I am trying to change the datatype of the blank field to match the selection field.

Ex. If I choose Rent it must go with the float datatype. If I choose the size then it need to go for the option datatype.

Child Table Field:

Please assist.

Thanks for your guidance.

Regards,
Balram Singh

frappe.ui.form.on(‘YourParentDocType’, {
refresh: function(frm) {
// Assuming child table fieldname is ‘items’ and fields are ‘type’ and ‘value’
frm.fields_dict[‘items’].grid.on(‘grid-row-render’, function(doc) {
var row = locals[doc.doctype][doc.name];
var type = row.type; // Assuming ‘type’ is your select field

        // Determine data type based on the select field 'type'
        var data_type = (type === 'Rent') ? 'Float' : 'Data'; // Adjust as per your requirement
        
        // Assuming 'value' is the field you want to change data type dynamically
        frm.set_df_property('items', 'value', 'fieldtype', data_type);
    });
}

});

1 Like

you can refer this for set_df_property [Tutorial] set_df_property | Parent Table & Child Table | 2023

1 Like

Thanks Jeel I tried the steps u have provided unfortunately it is not giving the result which I am expecting could u please brief me.

I have parent doctype under the name “Branch Details” and child doctype as “Branch parameters” with two fields one with the all the field name in “select” datatype and another as “data” datatype.