Example for selector-modifier

Example for selector-modifier

nikrounikrou Posts: 5Questions: 1Answers: 0

Hi all,
I try to limit selection on current page. I read carrefully https://datatables.net/reference/type/selector-modifier#Built-in-options.
But I do not understand how to inject selector-modifier object in dataTables configuration.
Any help is welcome. Thanks in advance

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓

    There is an example of selecting the rows on the current page:
    https://datatables.net/reference/type/selector-modifier#page

    If that is not what you are looking for then please post the code you are trying to work with and what specifically you want to select.

    Kevin

  • nikrounikrou Posts: 5Questions: 1Answers: 0

    Thanks for your answer. Of course it works.
    I searched for a way to inject following object in the main dataTable parameters.

    {
        // DataTables core
        order:  'current',  // 'current', 'applied', 'index',  'original'
        page:   'all',      // 'all',     'current'
        search: 'none',     // 'none',    'applied', 'removed'
     
        // Extension - KeyTable (v2.1+) - cells only
        focused: undefined, // true, false, undefined
     
        // Extension - Select (v1.0+)
        selected: undefined // true, false, undefined
    }
    
    $('#my-list').DataTable({
       ajax: { // my_ajax params },
       select: {
        style: 'os',
       }
    });
    

    Where should I put the selector modifier ?

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    I see, you are looking for the Select Extension options. You will want to use the select.selector option.

    Kevin

  • nikrounikrou Posts: 5Questions: 1Answers: 0

    But Kevin what value can I set to select only rows on current page ?

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    Are you trying to use rows().select(). If so then use the selector {page: 'current'}. Like this example:
    http://live.datatables.net/fezumija/1/edit

    Is this what you are trying to do?

    Kevin

  • nikrounikrou Posts: 5Questions: 1Answers: 0

    I'm afraid I should use what you proposed. I wish I can only use one parameter to tell that I only want selection on currrent page.
    In my code I have a "select all" button, a "deselect all" button. Both must use that parameter. So the parameter value is duplicated. You must admit it's not really good. Of course it works and if I cannot do in another way I keep my code like that.

    Anyway thanks for your help.

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    Not sure I understand the issue. What do you mean the parameter is duplicated? It is used once to tell the rows() API which rows to get followed by either the select() API or the deselect() API, for example:
    table.rows({page: 'current'}).select();

    Kevin

  • nikrounikrou Posts: 5Questions: 1Answers: 0

    And you must also use table.rows({page: 'current'}).deselect();

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    That is correct. If you don't want all the rows returned from rows() then you need to use a selector to define the rows you want.

    HTH,

    Kevin

This discussion has been closed.