GithubHelp home page GithubHelp logo

Comments (8)

hetal1110 avatar hetal1110 commented on May 17, 2024

Is there any way to get selected rows in Datatable?

But how to get row Ids, that is selected?

What is the Event to capture selected rows?

Thanks in Advance…

from datatable.

sanjay-hercules avatar sanjay-hercules commented on May 17, 2024

@hetal1110 you can get selected rows of report having checkbox as mentioned below:


		onload: function() {
                       // add a button to report
			frappe.query_report.page.add_inner_button(__("Get Selected"), function() {
				var selected_rows = [];
				$('.dt-scrollable').find(":input[type=checkbox]").each((idx, row) => {
					if(row.checked){
						console.log("*** selected row id : " + idx);
						selected_rows.push(frappe.query_report.data[idx]);
					}
				});
			});
		},

from datatable.

AndyOverLord avatar AndyOverLord commented on May 17, 2024

Hi @melBoh, thank you very much. I think it's working real well as I have used it to enabled a feature of editing inline and update it in the database. I wonder why it's still not merged to the repository.

If I make the changes on my own, how to prevent the changes be override with next frappe version updates.

from datatable.

kevinpthorne avatar kevinpthorne commented on May 17, 2024

why this is still open? Can a PR be made for this?

from datatable.

kevinpthorne avatar kevinpthorne commented on May 17, 2024

Actually, I found using the setValue function when setting the datatable's getEditor return object provided the same functionality.

For example (using Frappe Controls)

	getEditor: function(colIndex, rowIndex, value, parent, column, row, data) {
            // colIndex, rowIndex of the cell being edited
            // value: value of cell before edit
            // parent: edit container (use this to append your own custom control)
            // column: the column object of editing cell
            // row: the row of editing cell
            // data: array of all rows

            const control = frappe.ui.form.make_control({
                parent: parent,
                df: {
                    label: '',
                    fieldname: doctype,
                    fieldtype: 'Link',
                    options: doctype
                },
                render_input: true,
                only_input: true,
            });

            let oldValue = '';

            return {
                // called when cell is being edited
                initValue(value) {
                    control.input.focus();
                    control.input.value = value;
                    oldValue = value;
                },
                // called when cell value is set
                setValue(newValue) {
                    // ----------- Do whatever is needed here.
                    control.input.value = newValue;
                },
                // value to show in cell
                getValue() {
                    return control.input.value;
                }
            }
        }

from datatable.

azharumar avatar azharumar commented on May 17, 2024

I've hit a strange roadblock.

Inline editing works in Report Builder, but calculated fields are not possible.
Calculated fields are possible in script editor, but inline editing is not possible.

from datatable.

kevinpthorne avatar kevinpthorne commented on May 17, 2024

I've hit a strange roadblock.

Inline editing works in Report Builder, but calculated fields are not possible.
Calculated fields are possible in script editor, but inline editing is not possible.

Editing a calculated field goes against their purpose. I would make it whatever type it should be and do the calculation manually. Alternatively, you can make a hidden calculation field and copy the value over to the editable field.

from datatable.

azharumar avatar azharumar commented on May 17, 2024

I've hit a strange roadblock.
Inline editing works in Report Builder, but calculated fields are not possible.
Calculated fields are possible in script editor, but inline editing is not possible.

Editing a calculated field goes against their purpose. I would make it whatever type it should be and do the calculation manually. Alternatively, you can make a hidden calculation field and copy the value over to the editable field.

Obviously! I wouldn't want a calculated field to be editable. Instead, I have a report where both type of columns are needed - one for calculated and another for inline editing.

from datatable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.