properties for new types IMG VIDEO AUDIO

properties for new types IMG VIDEO AUDIO

sharkowolfsharkowolf Posts: 21Questions: 9Answers: 0

Dear Allan,

Continuing the topic

https://datatables.net/forums/discussion/66776

put the question in a separate thread.

There is such a convenient dependent mechanism

editor_quest.dependent( 'quest_enable_img', function ( val ) {
            return val == 0?
                { hide: ['quest_img'] } :
                { show: ['quest_img'] };
        } );

I would like to use it for my new img video audio object types.

Where can I see how this is done correctly for typical objects?

    get: function ( conf ) {
        return $('button.selected', conf._input).attr('value');
    },
 
    set: function ( conf, val ) {
        $('button.selected', conf._input).removeClass( 'selected' );
        $('button.inputButton[value='+val+']', conf._input).addClass('selected');
    },
 
    enable: function ( conf ) {
        conf._enabled = true;
        $(conf._input).removeClass( 'disabled' );
    },
 
    disable: function ( conf ) {
        conf._enabled = false;
        $(conf._input).addClass( 'disabled' );
    }

Thanks!

With respect,
Andrey

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    There are a few examples scattered around the forum, such as this one here (which counts the number of characters typed in the name field), and this one here which sets the salary if an office is "XXX".

    I hope that gets you going, if not, can you be more specific about what you're trying to achieve,

    Colin

  • sharkowolfsharkowolf Posts: 21Questions: 9Answers: 0

    Good day,
    Colin,

    Thank you for quick answer. Of course, he is useful to me, but I would like to clarify a number of points that I could not find on the forum.

    In the above example, there is the format property.

    live.datatables.net/wefidiqe/1/edit

    {
         label: 'Start date:',
         name: 'start_date',
         type: 'datetime',
         format: 'YYYY/M/D'
    }
    

    First question:

    1. Can you see how the FORMAT property for TYPE: 'datetime' is formed at the module level for determining the datetime field type?

    2. Can I change the type of the field on the fly via editor.dependent? How can I do that? It will be rendered with a new property. Alternatively, I want to use type = text and type = textarea.

    I really hope for an answer. Thanks!

    With respect,
    Andrey

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    edited February 2021 Answer ✓
    1. the format property for datetime only needs to be set if you want to change the date format - this example here may help.

    2. You can't change the field type as such, but you can remove the field and re-add it again with the new type, and that can be done in the dependent() function. This example here from this thread is doing something similar (though in an event rather that dependent()),

    Colin

  • sharkowolfsharkowolf Posts: 21Questions: 9Answers: 0

    Colin,

    Thanks a lot for your answer. Answer number 2 is what you need.

    Thank you!

    With respect,
    Andrey

This discussion has been closed.