Icon in grid table

i have a child table, there is 2 column, one column is for remark, another column i have to have a icon which indicate when there is remark text existed. i see field have icon, how can i use it and make script for this purpose?

For the first part of the question, make sure the icon field in your child table has “In List View” enabled. This will allow you to see the field and pick one of the available icons.

For the second part of the question, to automate this you can create a client script

frappe.ui.form.on('Doctype', { //replace with your doctype name
    before_save: function(frm) {
        var table = frm.fields_dict['remarks']; //use the fieldname of your table
        var row = table.grid.get_data();
        for (let i = 0; i < row.length; i++){
            if (row[i].remark){ //replace with a fieldname within your child table and/or condition
              row[i].icon = "solid-warning" //replace with your prefered icon

This will automatically place an icon of your choice (currently a :warning:) once the condition is passed; the remark field of the childtable has any data.

Please note that this will apply to all remark rows in your child table everytime the document is saved and will automatically replace any blank or manually chosen icon for a certain remark. So you might want to set the icon field as read-only.

Alternatively, you can pass a condition to the if statement to permit your employees to manually enter different icons for different remarks (and not getting replaced)

if (row[i].remark && !row[i].icon)
1 Like