Editor form title

Editor form title

calacala Posts: 52Questions: 15Answers: 0

As in https://datatables.net/reference/button/create and https://datatables.net/reference/button/edit , I want to modify the title of the editor form.

If I use formTitle option, nor the custom string, nor the default title, is shown. To test the correctness of the function I've changed to formMessage. In this case it show the correct text under the default title.

There are some other parameter to be set in the case of the title?

Thank you.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,745Questions: 1Answers: 10,509 Site admin

    Hi,

    Sorry I haven't responding to this topic yet. It will be the first thing I do tomorrow morning!

    Allan

  • allanallan Posts: 63,745Questions: 1Answers: 10,509 Site admin
    edited September 2015

    Hi,

    Could you possibly show me the code they are are using please or ideally link to a test case? I've just tried the following and it appears to work as expected:

    { extend: "create", editor: editor, formTitle: 'My custom title' },
    

    Thanks,
    Allan

  • calacala Posts: 52Questions: 15Answers: 0
    edited September 2015

    Here you are:

    { 
        extend: 'create', 
        editor: editor,
        formTitle: function (  ) {
            var stringa= 'Creazione protocollo n° '+ (max_protocollo);
        max_protocollo++;
        //console.log(max_protocollo);
            return stringa;
        }
    },
    

    doesn't show anything, with formMessage option the text is shown.

    I've tried with your example... and yes, it works...

    Another question is it possible to add a class to a button? It has to be static, no worry about problem like "selected/not-selected".

    Thank you!

  • allanallan Posts: 63,745Questions: 1Answers: 10,509 Site admin
    Answer ✓

    Ah yes, sorry. There is a bug in Editor 1.5.1 where the form title is given as a function - it isn't executed at all.

    In the Editor code there is:

    if ( typeof opts.title === 'string' || typeof opts.message === 'function' ) {
    

    it should be changed to:

    if ( typeof opts.title === 'string' || typeof opts.title === 'function' ) {
    

    I've fixed it locally and it will be in 1.5.2. Thanks for letting me know about this.

    Another question is it possible to add a class to a button? It has to be static, no worry about problem like "selected/not-selected".

    Yes, you can define buttons using the formButtons option of the buttons which is passed through to buttons().

    Regards,
    Allan

  • calacala Posts: 52Questions: 15Answers: 0
    edited September 2015

    Perfect for the title, it works!

    for the button class I've added the "className" option to the definition of the button.
    Now it is something like:

    { 
        extend: 'create', 
        editor: editor,
        className: 'my-custom-class',
        formTitle: function ( ) {
            // Get the data for the row and use a property from it in the
            // form title
            var stringa= 'Creazione protocollo n° '+ (max_protocollo);
            max_protocollo++;
            //console.log(max_protocollo);
            return stringa;
        }
    },
    
  • allanallan Posts: 63,745Questions: 1Answers: 10,509 Site admin
    Answer ✓

    Ah I see - that button. In which case yes, that is the way to do it.

    Allan

This discussion has been closed.