Standalone - edit on load

Standalone - edit on load

belubelu Posts: 38Questions: 14Answers: 0

Hi,
I have a table with only one row. There will never be more rows, because it is just a table for settings.
I would like to use the standalone mode with inline or bubble editing.
My goal is, that on page-load the fields are prefilled with the values from row_1 and can be edited.

What do I do wrong? Thanks in advance!


<div class="panel" data-editor-id="row_1"> <dl> <dt>Jahresstatistik:</dt> <dd> <span data-editor-field="c_settings.dashboard_show_hours_year_statistics"></span> </dd> <dt>Nicht exp anzeigen:</dt> <dd data-editor-field="c_settings.dashboard_show_total_hours_not_exported"></dd> <dt>Office:</dt> </dl> </div> </div> <!-- Grid Row Main --> <?php include 'templates/footer.php'; ?> <script> var editor; (function($){ $(document).ready(function() { editor = new $.fn.dataTable.Editor( { ajax: "datatables_php/ajax.be_settings_hours.php", onFieldError: 'focus', fields: [ { label: "Dashboard Jahresstatistik:", name: "c_settings.dashboard_show_hours_year_statistics", type: 'radio', options: [ { label: 'Ja', value: '1' }, { label: 'Nein', value: '0' } ] }, { label: "Dashboard nicht exportierte Stunden", name: "c_settings.dashboard_show_total_hours_not_exported", type: 'radio', options: [ { label: 'Ja', value: '1' }, { label: 'Nein', value: '0' } ] }, ] } ); // EO Editor Instanzierung $('[data-editor-field]').on( 'click', function (e) { editor.inline( 'row_1' ); } ); editor.field('c_settings.dashboard_show_hours_year_statistics').input().addClass('form-check-input'); editor.field('c_settings.dashboard_show_total_hours_not_exported').input().addClass('form-check-input'); } ); // EO Doc ready }(jQuery)); // </script>

Answers

  • belubelu Posts: 38Questions: 14Answers: 0

    I forgot to post the editor - php:

    // Build our Editor instance and process the data coming from _POST
    $editor = Editor::inst($db, 'client_settings as c_settings', 'id');
    $editor->where('id', 1, '=');
    
    // Wenn in der Taballe my_clients der Datatables Debug Mode eingeschaltet ist
    if(Settings::getDebugModeDatatables()){
        $editor->debug(true);
    }
    
    // client_id - wird nicht angezeigt, macht aber vieles einfacher, wenn vorhanden
    $editor->fields(Field::inst('c_settings.id')
        ->set(Field::SET_NONE) // weder beim neu erzeugen, noch beim Update schreiben - wird ja auf DB Ebene automatisch vergeben
    );
    
    $editor->fields(Field::inst('c_settings.dashboard_show_hours_year_statistics')
    ->set(Field::SET_EDIT)
    );
    
    
    $editor->fields(Field::inst('c_settings.dashboard_show_total_hours_not_exported')
        ->set(Field::SET_EDIT)
    );
    
    
    // Ausführen & JSON String
    $editor->process( $_POST );
    $editor->json();
    
  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    What do I do wrong? Thanks in advance!

    That looks OK. Can you say what the problem is? What is wrong? And are you able to link to your page so we can take a look?

    Colin

This discussion has been closed.