edit cells by index array

edit cells by index array

ludwigmludwigm Posts: 10Questions: 7Answers: 1

I would like to edit a cell of a DataTable by row index, which is a array that contains the rows that fired the select event. So far I edit just one row, by index 0:

dtMember.cell({row: indexes[0], column: COL_SELECT}).data(CHAR_UNSELECTED);

just removing [0] is not working (Uncaught TypeError: c[0] is undefined. (jquery.dataTables.min.js:153:256))

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586
    edited September 2022

    cell() doesn't take an object - try this instead:

    dtMember.cell(indexes[0], COL_SELECT).data(CHAR_UNSELECTED);
    

    Colin

  • ludwigmludwigm Posts: 10Questions: 7Answers: 1

    I tried:
    dtMember.cell( indexes, COL_SELECT).data(CHAR_UNSELECTED);

    still just in the first row the CHAR_UNSELECTEDis set.
    indexescontains all indexes whereas indexes[0]contains just the first row

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin

    cell() will only select a single cell. It sounds like you are wanting to edit multiple? I'm not sure - it is hard to say without a test case.

    Allan

  • ludwigmludwigm Posts: 10Questions: 7Answers: 1
    Answer ✓

    I solved it so:

    indexes.forEach(element => {
        dtMember.cell(element, COL_SELECT).data(CHAR_UNSELECTED);
     }); 
    
Sign In or Register to comment.