Retrieve value from standalone radio button

Retrieve value from standalone radio button

anotherlawanotherlaw Posts: 7Questions: 4Answers: 0

Hi,

I'm going crazy trying to figure out how to interact with a standalone bubble radio button.

When the user clicks on column 1; I want a bubble local 'radio' form appears that allows the user to view (and change) the status of the record.

    editor2 = new $.fn.dataTable.Editor( {
        fields: [ {
                label: "Record Status",
                name: "record_status",
                type:  'radio',
                    options: [
                        { label: 'Competing',  value: 'CP' },
                        { label: 'Hors Concors',  value: 'HC' },
                        { label: 'No Show',  value: 'NS' }
                ]
            }   
        ]
    });

This displays the form just fine and I can interact with it as a user .... but I'd like to be able to
a) set the current status (set selected).
b) read the new state when a user clicks "Update"

It is probably important to note that there are no corresponding fields within the datatable ... rather the status of a record is computed based on condition for a number of 'real' field values.

I had expected to be able to use dependent() to be able to do the latter - but nothing seems to fire

    editor2.dependent('record_status', function ( val, data, callback ) {
        console.log('Fired');
    });

Any advice would be very much welcomed.

Answers

  • anotherlawanotherlaw Posts: 7Questions: 4Answers: 0

    Ok; looks like it was as simple as adding the 'table' definition back into editor constructor.... which seems contradictory to the documentation ... but hey, I'll take it.

    editor2 = new $.fn.dataTable.Editor( {
            table: "#example",
            fields: [ {...
    

    The 'dependent' event now fires and I'm able to use

    editor2.field('record_status').val()
    

    to get the current value.

    Setting the initial value is catered for by

        editor2.on( 'open', function ( e, type ) {
            editor2.field('record_status').val('CP');
        } );
    
This discussion has been closed.