standalone#Collections Deletan question

standalone#Collections Deletan question

sharkowolfsharkowolf Posts: 21Questions: 9Answers: 0
edited January 2021 in Free community support

Good day,
I will immediately warn you that I have been dealing with the problem continuously for the 4th day and unsuccessfully. I apologize if the question seems silly.

My task is painfully simple. On page load, fill in multiple INPUT LABEL CHECKBOX based on one row in the database. Then, when working with these elements on the fly using DataTables, make changes to the database. To do this, I studied and use the following examples from the links:

https://editor.datatables.net/manual/standalone#Collections

https://editor.datatables.net/examples/standalone/simple.html

my code at standalone.php

<?php

//include( "../lib/DataTables.php" );

//use
//  DataTables\Editor,
//  DataTables\Editor\Field,
//  DataTables\Editor\Format,
//  DataTables\Editor\Mjoin,
//  DataTables\Editor\Options,
//  DataTables\Editor\Upload,
//  DataTables\Editor\Validate,
//  DataTables\Editor\ValidateOptions;

echo json_encode( array(
    "data" => array( $_POST['data']['keyless'] )
) );

//Editor::inst( $db, 'quiz', 'quiz_id' )
//   ->fields(
//         Field::inst( 'quiz_id' ),
//         Field::inst( 'quiz_name' ),
//         Field::inst( 'quiz_pass' ),
//         Field::inst( 'quiz_type' )
//        )
//    ->where( 'quiz_id', '1949' , '=' )
//   ->process( $_POST )
//   ->json();

my code at *.HTML


<div class="panel" data-editor-id-test="row_1949"> <dl> <dt> <dd data-editor-field="quiz_type">63</dd> <dd data-editor-field="quiz_pass">53</dd> <dd data-editor-field="quiz_name">43</dd> </dt> </dl> </div>

my code at в HEAD SCRIPTS

var editor2; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {
    editor2 = new $.fn.dataTable.Editor( {
        ajax: "../../controllers/standalone.php",
        fields: [     {
                label:"quiz_type",
                name: "quiz_type",
            },{
                label:"quiz_pass",
                name: "quiz_pass",
            },{
                label:"quiz_name",
                name: "quiz_name",
            }
            ]
    } );
 
    $('[data-editor-field]').on( 'click', function (e) {
        editor2.inline( this, {
            buttons: '_basic'
        } );
    } );
} );

It is impossible to solve any of the problems that may be))
1. When loading the page, I do not understand how to fill the field values ​​with the data of a specific database row.
2. When I remove the data-editor-id then standalone returns a normal value, but nothing happens in the database. If you comment out json_encode and uncomment Editor :: inst, then the entries begin to appear, but only by 1 field and it is necessary not with editing, but creating a new database line.
3. If I set data-editor-id = "row_1949" in the div, then the following construction appears in the request: data [row_1949] [quiz_name]: 43231234
action: edit, but standalone itself returns null.
4. Additionally, if you click on edit and process the 'Click'event; then again it is no longer active on any element.
5. Is it possible not to use the Update button, but to manage the cell change event?

Please do not kick hard with your feet - I can not master the elemental mechanism.

With respect,
Andrei

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin
    Answer ✓

    Hi Andrei,

    All good questions! Could you send me a link to your page so I can take a direct look at it and debug it please? If you don't want to make the link public, send it to me directly as a PM by clicking my forum user name above and then "Send message".

    Also, could you change data-editor-id-test to be data-editor-id and uncomment the PHP, also removing the echo json_encode line?

    Many thanks,
    Allan

This discussion has been closed.