Inline editing

Inline editing

bobhassansterbobhassanster Posts: 16Questions: 5Answers: 1

Link to test case: http://docs.ensaf.ac.ma/test/test.php
Description of problem: In inline editing the input text is working but The select input is not working and it's working in normal edit. Many Thanks for your Help.
Editor php:

Editor::inst( $db, 'testTable', array('year', 'nature', 'user'))
    ->fields(
        Field::inst( 'testTable.user')
            ->options( Options::inst()
                ->table( 'user' )
                ->value( 'user_id' )
                ->label( array('first_name', 'last_name') )
                 ->render( function ( $row ) {
                    return strtoupper($row['first_name'].' '.$row['last_name']);
                } ) 
            )
            ->validator( Validate::dbValues() ),
        Field::inst( 'user.first_name' )
            ->set(false),
        Field::inst( 'user.last_name' )
            ->set(false),
        Field::inst( 'testTable.note' )
            ->setFormatter( Format::ifEmpty( null ) ),
    )
    ->leftJoin( 'user', 'user.user_id', '=', 'testTable.user' )
    ->process( $_POST )
    ->json();

Replies

  • bobhassansterbobhassanster Posts: 16Questions: 5Answers: 1

    Editor Script:

    var test_table = $('.dt-test-table'), dt_test;
    editor = new $.fn.dataTable.Editor( {
        ajax: "scripts/php/editorTest.php",
        table: test_table,
        fields: [ {
            label: "Name",
            name: "testTable.user",
            type: "select"
        },
        { label: "Note",    name: "testTable.note" }
        ]
    } );
    
    // Activate an bubble edit on click of a table cell
    $('.dt-test-table').on( 'click', 'tbody td:not(:first-child)', function (e) {
        editor.inline( this, {
            onBlur: 'submit'
        } );
    } );
    
    dt_test = test_table.DataTable({
        ajax: "scripts/php/editorTest.php",
        columns: [
            { defaultContent: "",
                data: "user",
                render: function ( data, type, row ) { var name = data.first_name +' '+ data.last_name; return name.toUpperCase(); },
                editField: "testTable.user"
            },
            { data: "testTable.note" }
        ],
        select: {
            style: 'single',
            selector: 'td:first-child'
        },
        buttons: [
            { extend: 'edit',   editor: editor, className: 'btn btn-primary' }
        ]
    });
    
  • bobhassansterbobhassanster Posts: 16Questions: 5Answers: 1

    I realized that it's not working just for the first column if i change the position it works, do you know why?

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Your selector to trigger inline editing is tbody td:not(:first-child). So it is explicitly excluding the first cell in each row (i.e. the first column).

    Just use tbody td if you want to be able to click on all cells in the table to trigger inline editing.

    Allan

  • bobhassansterbobhassanster Posts: 16Questions: 5Answers: 1

    Thanks!

Sign In or Register to comment.