restrict options in combobox (First come first served entry booking)

restrict options in combobox (First come first served entry booking)

agiladminagiladmin Posts: 7Questions: 5Answers: 0
edited August 2016 in DataTables 1.10

I am trying to use the restricting option to use inline editing only for specific fields as described here. Now I want to even further restrict the input by allowing only one option or empty field in a combobox. Is that possible?

It should be a foreign key field but allowing only one entry (in the example his own name logged in the system). If there is already one option selected it should not be possible to select his own name any more since already someone else booked the entry. I hope you can follow me. Its a first come first served booking system. If the field is empty you can book your own name in, if not it is locked. How can I apply that to datatables? Is there an example which has similiar behaviour?

Answers

  • allanallan Posts: 61,762Questions: 1Answers: 10,111 Site admin

    What combo box library are you using? You would probably need to refer to their documentation for that.

    Allan

  • agiladminagiladmin Posts: 7Questions: 5Answers: 0
    edited September 2016

    The solution to the problem I found through the help of Allan via message. First of all I meant the standard select box and not the combobox. Here is the solution to just let the user edit if his/her name is shown in the select via the Session variable or the select is empty.

            $('#table_feintragen').on( 'click', 'tbody td:nth-child(9)', function (e) {
                var table = $('#table_feintragen').DataTable();
    
                <?php if(isset($_SESSION['gf_nr'])){?>
                if(table.cell( this ).data() == '<?php echo($_SESSION['gname']); ?>' || 
                        table.cell( this ).data() == null){
                    editorFeintragen.inline( this , {
                        buttons: { label: '&gt;', fn: function () { this.submit(); } }
                    } );
                }
                <?php } ?>
        
            } );
    

    To minimize the options to one I just used the where filter to the options list as described here https://editor.datatables.net/manual/php/joins#Options

This discussion has been closed.