0

I'm working with the Frappe Framework, and I've already made a dialogbox insertDialog with a table named questions in it, and the table has a column qno inside it. I want the qno field to be populated with the current index whenever a new row is made.

I've tried 3 ways:

  • Adding a default attribute to qno field - Nothing I put in the default attribute seem to come up
  • Changing the get_data function, so that whenever a new row is added, and the get_data function is called, it would return the preprocessed data array - The table still functioned but the contents didn't get updated.
  • Defining the attribute outside the dialogbox definition
insertDialog.fields_dict['questions'].grid.get_field('qno').default = data.length + 1;

(Again, it didn't make any changes in the table)

I'm trying to see if I can customize the adding the new row function, but I can't find anywhere how to do it or which function to call for that.

Here is the current code

let insertDialog = new frappe.ui.Dialog({
        title: 'Please enter the required details',
        fields: [
                {
                    label: `Questions`,
                    fieldname: `questions`,
                    fieldtype: 'Table',
                    data: data,
                    get_data: () => {
                         return data;
                    },
                    fields: [
                        {
                            label: `Q. No.`,
                            fieldname: 'qno',
                            fieldtype: 'Int',
                            in_list_view: 1,

                        }
                  ]
            }
Sagar Darekar
  • 982
  • 9
  • 14

0 Answers0