Can I do this with inline edit ??

Can I do this with inline edit ??

rob morningrob morning Posts: 30Questions: 7Answers: 1

I'm using datatables with bootstrap (jic) and looking at edit .. I had a table with two checkboxes on each row which when changed correctly updated server via ajax .. The code for this shown below and worked well ..

     editor.edit($(this).closest('tr'), false)
                        .set('endOfDay', $(this).prop('checked') ? true : false)
                        .submit();
            }).
            on('change', 'input.editor-closed', function () {
                editor.edit($(this).closest('tr'), false)
                        .set('closedSlot', $(this).prop('checked') ? true : false)
                        .submit();
            })

I now have a new requirement where I want to allow inline editing of another field in the row and currently use submitOnBlur as shown ..

      on( 'click', 'tbody td:not(:first-child)', function (e) {
        editor.inline( this,{
            submitOnBlur: true
        } );

This correctly updates server via ajax but now it is possible to change checkboxes WITHOUT there content being transferred to the server unless the user leaves the cell .. I tried changing the checkboxes and replaced 'submit()' with 'blur()' but I couldn't get it to send changes to server.. Is it possible to do this with edit ? Also (supplementary question) , can I restrict which columns are editable in the datatable ? TIA ..

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,840Questions: 1Answers: 10,134 Site admin
    edited July 2015 Answer ✓

    can I restrict which columns are editable in the datatable ?

    Yes. You already have with the selector used:

    'tbody td:not(:first-child)'
    

    So td cells which are not the first child (i.e. the first column) are activating inline editing. If you want to exclude other columns the selector needs to be modified. One of the easiest options is to use the columns.className option to assign a class (editable for example) to the columns you want to be editable and then use:

    'tbody td.editable'
    

    as the selector.

    Allan

  • rob morningrob morning Posts: 30Questions: 7Answers: 1
    edited July 2015

    Thanks ! Have you any advice with my other problem (in the same question) relating to when updates are triggered ?

  • rob morningrob morning Posts: 30Questions: 7Answers: 1
    edited July 2015

    It's okay , this seems to have to have sorted my submission problem as well .. Thanks again

This discussion has been closed.