use json data in editor title ?

use json data in editor title ?

crush123crush123 Posts: 417Questions: 126Answers: 18
edited October 2015 in Editor

i have an instance of editor, where, depending on the data, i want to change of the title on edit to something appropriate

i have managed to do this with a static value like so...

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

    editor_2
        .title( 'Return Item ?' )
        .message ( 'Check the box to return the item back into stock')
        .buttons( [
        'Confirm',
        { label: 'Cancel', fn: function () { this.close(); } }
        ] )
        .edit( $(this).closest('tr') );
} );

but can't customise it further

for the title, i tried

.title( 'return item'+ editor_2.field('tblorderdetails.DetailItemID').val() )

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Your best bet is to pass the title option (and actually message and buttons) in using the form-options property that you can pass into edit().

    That is a good way of doing it, as otherwise the edit() method will trigger the display using the default options. It also removes any possibility of async issues if you happen to use inline editing, either now or in future.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    edited October 2015

    Ok, I think I got it

         editor_2.on('open', function () {
         var edittitle
         var editmessage
         var PPID = editor_2.field('tblorderdetails.PatronPaymentID').val()
         if (PPID.length > 0) {
             edittitle = "xxx";
             editmessage = "yyy";
         } else {
             edittitle = "aaa";
             editmessage = "bbb";
         }
    
        editor_2
            .title(edittitle )
            .message (editmessage)
            .buttons( [
              'Confirm',
              { label: 'Cancel', fn: function () { this.close(); } }
            ] )
     });
    

    This appears to work great, so long as the field tblorderdetails.PatronPaymentID is in my editor instance, and is not set to hidden.(or display)

    However, I don't want to see the field in the editor, but setting its type to hidden or display will not load any title or message

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    Reason it didn't work was I was checking for an empty string, so the null returned was throwing an error, (so I assume when the field was visible, then the value wasn't null ?)

    anyway i changed

    if (PPID.length > 0) {
    

    to

    if (PPID !== null) {
    
This discussion has been closed.