Datatable Inline Editing & Other Options

Hi everyone,

I’m writing a custom script report on v11 which I believe is using Frappe’s very own datatable. I understand that it supports lots of options, including inline editing. May I know where should i indicate those options? I tried doing it at the columns code block but can’t make it work.

Below are my codes.

Python file

from __future__ import unicode_literals
import frappe

def execute(filters=None):
	columns = get_columns(filters)
	data = get_data(filters, columns)
	
	return columns, data

def get_columns(filters):
	columns = [{
		"fieldname": "supplier_name",
		"label": "Supplier Name",
		"fieldtype": "Link",
		"options": "Rebate Supplier",
		"width":150
	},
	{
		"fieldname": "franchisee_name",
		"label": "Franchisee Name",
		"fieldtype": "Link",
		"options": "Rebate Franchisee",
		"width":150
	},
	{
		"fieldname": "year",
		"label": "Year",
		"fieldtype": "Data",
		"width":45
	},
	{
		"fieldname": "cy_jan_transaction",
		"label": "Jan",
		"fieldtype": "Float",
		"editable": "true",
		"resizable": "false",
		"width":50
	}
	]

	return columns

def get_data(filters, columns):
	data = []

	data = frappe.get_all(
		'Rebate Supplier Transaction', 
		filters={}, 
		fields=[
			'supplier_name',
			'franchisee_name',
			'year',
			'cy_jan_transaction'
			]
		)

	return data

Javascript file

frappe.query_reports["Rebate Report"] = {
	"filters": [
		{
			"fieldname":"supplier_name",
			"label":"Supplier Name",
			"fieldtype":"Link",
			"options":"Rebate Supplier"
		},
	]
}

I would like the field “cy_jan_transaction” be editable.

Appreciate your guidance. Thank you.

Does anyone know how to enable datatable inline editing?

Thank you.

Hi everyone,

Does anyone know how to enable inline editing for datatable in Erpnext v11 when creating custom reports? Or maybe we can’t in the first place?

Any help greatly appreciated.

Inline Editing is enabled by default in DataTable. In Reports, inline editing is disabled. If you want to enable, you have to set the option editable: true for each column.

Refer to this documentation on inline editing:

1 Like

Hi @netchampfaris,

Thanks for the reply. I have actually indicated editable: true.

If you look in my codes in first post, this is what I have specified:

{
		"fieldname": "cy_jan_transaction",
		"label": "Jan",
		"fieldtype": "Float",
		"editable": "true",
		"resizable": "false",
		"width":50
	}

Still doesn’t work in my script report.

    {
		"fieldname": "cy_jan_transaction",
		"label": "Jan",
		"fieldtype": "Float",
		"editable": true,
		"resizable": false,
		"width":50
	}

Don’t use quotes around boolean values

Hi @netchampfaris,

Thanks for the guidance. I have indicated

“editable”: True

but I still can’t do inline editing on the datatable in my script report. Is there additional codes i have to add in to the JSON or PY file?

Hi everyone,

Has anyone been able to enable inline editing for their new Frappe datatable / datagrid in erpnext v11?

JS is case sensitive. Try "editable": true.

1 Like

Hi @VamYip,

I tried that but was returned with this error,

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 61, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1007, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 489, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/query_report.py", line 174, in run
    result = generate_report_result(report, filters, user)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/query_report.py", line 65, in generate_report_result
    res = frappe.get_attr(method_name)(frappe._dict(filters))
  File "/home/frappe/frappe-bench/apps/rebate_tracker/rebate_tracker/rebate_tracker/report/rebate_supplier_transaction_view_script/rebate_supplier_transaction_view_script.py", line 8, in execute
    columns = get_columns(filters)
  File "/home/frappe/frappe-bench/apps/rebate_tracker/rebate_tracker/rebate_tracker/report/rebate_supplier_transaction_view_script/rebate_supplier_transaction_view_script.py", line 44, in get_columns
    "editable": true,
NameError: global name 'true' is not defined 

I may be wrong but I’m guessing this might not be the issue. Because if you look at my following code, the False for “resizeable” do work, just that the True for “editable” does not work.

{
	"fieldname": "cy_jan_transaction",
	"label": "Jan",
	"fieldtype": "Float",
	"editable": True,
	"resizable": False,
	"width":50
},

Note: The code above is in a py file, not js file.

I’m starting to think Frappe datatable is not fully compatible with ERPNext v11 yet. Couldn’t get inline editing to work.

Hi,
I’m on this issue too. I think I’m on something
in report js:

frappe.query_reports["report name"] = {
    "filters": [],
    after_datatable_render: function (datatable_obj) {
        $(datatable_obj.wrapper).find(".dt-row-0").find('input[type=checkbox]').click();
    },
    get_datatable_options(options) {

        options.columns.forEach(function(column, i) {
            if(column.id == "qty") {
                column.editable = true
            }
        });
        return Object.assign(options, {
            checkboxColumn: true,
            events: {
                onCheckRow: function (data) {
                    console.log("click");
                },
            }
        });
    }
};

It needs to be refined, but the editable field is appearing :smile:

Did you manage to make inline editing work properly?

Sorry I didn’t reply earlier. I’m still working on it, and will post it as soon as i’m done, but sadly I currently doing it on my free time (which is scarce :sweat_smile:)

Hi !
I posted my solution on the datatable github, if you want to take a look at it
https://github.com/frappe/datatable/issues/59