Use function as source in rowGroup.dataSrc()

Use function as source in rowGroup.dataSrc()

JesterAntikJesterAntik Posts: 12Questions: 3Answers: 0

I'll try to use rowGroup. But when I add the data-sort attribute to a column, rowGroup does not work. As I understand it, this is due to the call to the dataFn, which I can not directly set.

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Could you show me the code you are using please? Or even better, a link to a test case showing the issue.

    Thanks,
    Allan

  • JesterAntikJesterAntik Posts: 12Questions: 3Answers: 0

    I incorrectly set the task. I think you can close this discussion. I will open a new one with a statement of the problem in its original form and with an example.

  • JesterAntikJesterAntik Posts: 12Questions: 3Answers: 0

    That's my fault. I use the construction from the example:

    table.on( 'rowgroup-datasrc', function ( e, dt, val ) {
        table.order.fixed( {pre: [[ val, 'asc' ]]} ).draw();
    } );
     
    $('a.group-by').on( 'click', function (e) {
        e.preventDefault();
     
        table.rowGroup().dataSrc( $(this).data('column') );
    } );
    

    In this case have error:

    Cannot read property 'aDataSort' of undefined

  • JesterAntikJesterAntik Posts: 12Questions: 3Answers: 0

    It's my fault.
    I use code from example:

    table.on( 'rowgroup-datasrc', function ( e, dt, val ) {
        table.order.fixed( {pre: [[ val, 'asc' ]]} ).draw();
    } );
    function makeData(data, type, row, meta) {
      ....
    }
    $('a.group-by').on( 'click', function (e) {
        e.preventDefault();
        table.rowGroup().dataSrc( makeData );
    } );
    

    In this case I have error:

    Cannot read property 'aDataSort' of undefined

    Only now I realized that the problem with
    table.order.fixed( {pre: [[ val, 'asc' ]]} ).draw();

  • JesterAntikJesterAntik Posts: 12Questions: 3Answers: 0

    Sorry, it's my fault. I try to fix other issue by function, and take error at

    table.on('rowgroup-datasrc', function (e, dt, val) {
    dt.order.fixed({pre: [[val, 'asc']]}).draw();
    }
    

    where val is a function, not column index

  • JesterAntikJesterAntik Posts: 12Questions: 3Answers: 0

    It's my fault.
    I use code from example:

    table.on( 'rowgroup-datasrc', function ( e, dt, val ) {
        table.order.fixed( {pre: [[ val, 'asc' ]]} ).draw();
    } );
    function makeData(data, type, row, meta) {
      ....
    }
    $('a.group-by').on( 'click', function (e) {
        e.preventDefault();
        table.rowGroup().dataSrc( makeData );
    } );
    

    In this case I have error:

    Cannot read property 'aDataSort' of undefined

    Only now I realized that the problem with
    table.order.fixed( {pre: [[ val, 'asc' ]]} ).draw();

This discussion has been closed.