Checked a checkbox when a row is being selected

Checked a checkbox when a row is being selected

niontanionta Posts: 3Questions: 1Answers: 0

I have a checkbox in my table column, I want to checked the checkbox if my table row is being selected. how can I do that?

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946

    How are you selecting the row?

    This example uses the Select Extension with checkboxes:
    https://datatables.net/extensions/select/examples/initialisation/checkbox.html

    Kevin

  • niontanionta Posts: 3Questions: 1Answers: 0

    I want something like this:
    https://www.gyrocode.com/projects/jquery-datatables-checkboxes/
    also adding I am using inline editing.

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946

    Ok, you can use Gyrocode's checkboxes plugin. It uses the Select extension. Inline editing will work with Gyrocodes extension.

    Kevin

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946

    You will want to exclude the checkbox column from inline editing like this example:
    https://editor.datatables.net/examples/inline-editing/submitButton.html

    Kevin

  • niontanionta Posts: 3Questions: 1Answers: 0

    here is my code:
    `

    <

    script>
    $(document).ready(function()
    {

                var editor = new $.fn.dataTable.Editor( {
                    table: '#data_table',
                    idSrc:  'id',
                    fields: [
    
                        {name: 'id' },
                        {name: 'company_name' },
                        {name: 'status'  },
                        {name: 'created_at' },
                        {name: 'updated_at'  }
                        // etc
                    ]
                } );
                  $('#data_table').on( 'click', 'tbody td:not(:first-child, :nth-child(2), :nth-child(5), :nth-child(6))', function () {
    
                    editor.inline( this);
                     // select: true;
                } );
               client_table = $('#data_table').DataTable( {
                    // dom: "Bfrtip",
                    columns: [
                        { data: 'multi_id' },
                        { data: 'id' },
                        { data: 'company_name' , className: 'editable'},
                        { data: 'status' , className: 'editable'},
                        { data: 'created_at' },
                        { data: 'updated_at' }
    
                    ],
    
                    select: {
                       style: 'multi'
                    }
                } );
    
               } );`
    

    I want a function that, if I click on a column for edit, the full row will be selected and also I want a invisible checkbox for marking if the row is being selected, so basically if I click on the editable column the corresponding checkbox will the checked. I want this function for update all the edited rows by click on single update button, can you help me here, how I can edit m code for this? and thank u.

This discussion has been closed.