row select - selector-modifier

row select - selector-modifier

montoyammontoyam Posts: 568Questions: 136Answers: 5

I have a table where I want to select all records where a data field has a value. Is this possible?

something like:

table.rows(Users.UserID != '').select();

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949

    Use the row-selector as a function to return the rows that Users.UserID != ''.

    Kevin

  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    with that advice this is what I came up with...not sure if it is the best/only way???

            var indexes = RequestDetailTable.rows().eq(0).filter(function (rowIdx) {
                console.log(RequestDetailTable.cell(rowIdx, 5).data());
                return RequestDetailTable.cell(rowIdx, 5).data() == null ? false : true;
            });
            RequestDetailTable.rows(indexes)
                .nodes()
                .to$()
                .addClass('highlight');
            RequestDetailTable.rows('.highlight').select();
    
  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949
    edited November 2021

    In the row-selector docs see the function example which is used to return just the rows that match criteria.

    Kevin

  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949
    Answer ✓

    Here is an example:
    http://live.datatables.net/xulifexe/1/edit

    Kevin

  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    oh, yeah, that is MUCH cleaner... thanks!!

            RequestDetailTable
                .rows(function (idx, data, node) {
                    return data.Users.UserID != null ? true : false;
                })
                .select();
    
Sign In or Register to comment.