About the rows select after order change

About the rows select after order change

cmanskycmansky Posts: 9Questions: 4Answers: 0

I have a place to enter the begin and end to select the rows and the datatable is created with default order by created date asc. After I change the ordering to "created date desc" and keep using same number for selection, e.g. 0 to 1, the table is not select the first and second records, it selects the last two records.
Is possible to ignore the ordering and select the first two recorded?
ascending order
descending order

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 61,687Questions: 1Answers: 10,100 Site admin
    Answer ✓

    Row selection is a property of the row, not its position. If a row is selected, it doesn't matter where it is in the table, it will remain selected.

    If you need to only have the top two rows selected:

    1. In a draw event listener
    2. Use the rows().deselect() method to deselect the rows that are currently selected
    3. Use row().select() to select the top two rows.

    Allan

  • cmanskycmansky Posts: 9Questions: 4Answers: 0


    there is my code to control the selection

  • allanallan Posts: 61,687Questions: 1Answers: 10,100 Site admin
    Answer ✓
    table_Usermanage.rows(':lt(2)').select();
    

    will select the first two rows. See the row-selector documentation for the full list of options that you can use for the row selector.

    Allan

  • cmanskycmansky Posts: 9Questions: 4Answers: 0

    Thanks you Allan!!!
    finally i use "table_Usermanage.row(':eq('+i+')').select();"
    is there any different with ":lt(2)"?

  • allanallan Posts: 61,687Questions: 1Answers: 10,100 Site admin

    lt is less than. eq is equals. See the docs here.

    Allan

  • cmanskycmansky Posts: 9Questions: 4Answers: 0

    Thanks again!!!! I am a beginner in developing a website, it is helpful for me!!!

Sign In or Register to comment.