Editor - getting id of row from within fixedColumn

Editor - getting id of row from within fixedColumn

sitesurfersitesurfer Posts: 34Questions: 9Answers: 0
edited January 2016 in Editor

I have a fixed column (left and right) with an edit button in the right column. I also have inline edting - which works 100%.

All is well and the click on the button is fired but shows an empty modal rather than with fields in. I suspect that this is due to the way fixed columns work.

The 'create' button works 100% - so editor is configured fine.

Question: How to correctly obtain the row to edit from an edit link in a fixedColumn.

Debugger: http://debug.datatables.net/awemar

Code for the Editor:

editorBDM = new $.fn.dataTable.Editor( {
        ajax: "/site_mods/bd/bd_fulllist_server.php",
        table: "#bdmlist_1",
        fields: [ {
                label: "Agent Company Name:",
                name: "agents.ag_name"
            }, {
                label: "Telephone Number:",
                name: "agents.ag_tel"
            }, {
                label: "Primary Contact Name:",
                name: "agents.ag_primary_contact"
            }, {
                label: "Email Address:",
                name: "agents.ag_email"
            }, {
                label: "Agent Town:",
                name: "agents.ag_town"
            }, {
                label: "Agent County:",
                name: "agents.ag_county"
            }, {
                label: "Existing Notes:",
                name: "agents.ag_notes"
            }, {
                label: "Record Status:",
                name: "agents.ag_status"
            }, {
                label: "BDM Responsible:",
                name: "agents.ag_bdm"
            }, {
                label: "Agents Website:",
                name: "agents.ag_website"
            }
        ]
    } );

The event:

// Edit record
    $('#bdmlist_1').on('click', 'a.editor_edit', function (e) {
        e.preventDefault();

        console.log($(this).closest('tr'));
        editorBDM.edit( $(this).closest('tr'), {
            title: 'Edit record',
            buttons: 'Update'
        } );
    } );

The Inline activation: (which works 100%)

// Activate an inline edit on click of a table cell
    $('#bdmlist_1').on( 'click', 'tbody td:not(:last-child)', function (e) {
        editorBDM.inline(this,{
            onBlur: 'submit'
        });
    } );

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    To use FixedColumns with Editor you would need to use the fixedColumns().rowIndex() method to get the row index. You can then use that index to pass on to the edit() or inline() method to trigger editing.

    Allan

  • sitesurfersitesurfer Posts: 34Questions: 9Answers: 0

    Hi Allan

    Success!

    I placed the following code in the click event function, which just for the sake of completeness I paste here.

    // Edit record
        $('#bdmlist_1').on('click', 'a.editor_edit', function (e) {
             e.preventDefault();
             editorBDM.edit( tableBDM.fixedColumns().rowIndex(this.closest('tr')), {
                title: 'Edit record',
                buttons: 'Update'
            } );
        } );
    

    Thanks for the syntax highlighting guidance on my utter fail at copy/paste :)

This discussion has been closed.