edit cells by index array

edit cells by index array

ludwigmludwigm Posts: 12Questions: 8Answers: 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,240Questions: 1Answers: 2,599
    edited September 2022

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

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

    Colin

  • ludwigmludwigm Posts: 12Questions: 8Answers: 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: 63,530Questions: 1Answers: 10,473 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: 12Questions: 8Answers: 1
    Answer ✓

    I solved it so:

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