Is it possible to set the title of an Editor form dynamically?

Is it possible to set the title of an Editor form dynamically?

pansengtatpansengtat Posts: 66Questions: 26Answers: 1

Currently, the title of the Editor form can be changed directly using il8n as follows:

editor = new $.fn.dataTable.Editor({
            ajax: "myPage.php",
            table: "#myWebTable",
            fields: [
                {
                    label: "My field label: ",
                    name: "mySelectedTable.selectedColumn"
                }
            ],
    i18n: {
        edit: {
            title:  "This appears in the Editor title",
            submit: "Confirm"
        }
    }
});

However, if I wish to get data from a column and concatenate it to the Editor title, how do I do so?

i18n: {
    edit: {
        title:  "This appears in the Editor title " + "mySelectedTable.selectedColumn",
        submit: "Confirm"
    }
}

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Depending on your initialisation order you might need to use the open event and then the title() method to set the title.

    If you initialise Editor after the DataTable you could probably do the above (although to get the title use $( myTable.column( ... ).header() ).text() rather than giving it a string).

    Allan

  • pansengtatpansengtat Posts: 66Questions: 26Answers: 1

    This is what I churned out, hope this helps:

    editor.on('open', function () {
                    editor.title( 'Edit this entry: ' + editor.field('myMainTable.myTitleString').val() );
                });
    
This discussion has been closed.