$('input.editor-active', row).prop( 'checked' ???

$('input.editor-active', row).prop( 'checked' ???

Hildeb67Hildeb67 Posts: 69Questions: 19Answers: 1
edited February 2023 in Free community support

Hi.
I have a table as a variable "kalenderwoche". That also works so far

var kalenderwoche = moment().isoWeek();
kalenderwoche = 'kw'+fill(kalenderwoche);

....................

columns: [  
            {
                data: null,
                defaultContent: '',
                className: 'select-checkbox',
                orderable: false    
            },
            { data: kalenderwoche+".Klasse"},
            { data: kalenderwoche+".KNachname"},

but unfortunately this doesn't work. What am I doing wrong?

rowCallback: function ( row, data ) {
            
    $('input.editor-active1', row).prop( 'checked', data.kalenderwoche +'.Mo_mitessen'  == 1 );         
    $('input.editor-active2', row).prop( 'checked', data.kalenderwoche +".Mo_haus" == 1 );
        }               

...............
but this works

    $('input.editor-active1', row).prop( 'checked', data.kw07.Mo_mitessen == 1  );
        $('input.editor-active1', row).prop( 'checked', data.kw07.Mo_haus == 1  );

kw07 is value for "kalenderwoche"

Can somebody tell me why?
Thanks Christian

Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    data.kalenderwoche +'.Mo_mitessen'

    This is telling Javascript to look use the key kalenderwoche.Mo_mitessen. It is not referencing the variable. Try data[kalenderwoche +'.Mo_mitessen'] instead. For example:

    rowCallback: function ( row, data ) {

    $('input.editor-active1', row).prop( 'checked', data[kalenderwoche +'.Mo_mitessen']  == 1 );        
    $('input.editor-active2', row).prop( 'checked', data[kalenderwoche +".Mo_haus"] == 1 );
        }              
    

    ```

    Kevin

  • Hildeb67Hildeb67 Posts: 69Questions: 19Answers: 1

    Thanks for the quick reply but unfortunately it doesn't work that way either

  • Hildeb67Hildeb67 Posts: 69Questions: 19Answers: 1

    Thanks for the quick reply but unfortunately it doesn't work that way either

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    You probably need to use:

    data[kalenderwoche].Mo_mitessen
    

    If that doesn't work, can you show your JSON that is being loaded for the table please?

    Allan

  • Hildeb67Hildeb67 Posts: 69Questions: 19Answers: 1

    Thank you very much Allan it worked. Greetings

Sign In or Register to comment.