Ajax and buttons : collection

Ajax and buttons : collection

aelghaelgh Posts: 6Questions: 4Answers: 0
edited December 2018 in Free community support

Hello,

First I have a dt that is being filled by json from an SP call.

SmixTable = table.DataTable({ 
         ajax: {
                        url: "service/CallSP.cs/CallsSPMethod",
                        contentType: 'application/json; charset=utf-8',
                        data: { xx: mId, xx: sId },
                        dataType: 'json',                      
                    },
         columns: [
                        { "xx": "xx"  },
         ],
buttons: [
          
                        { 
                         extend: 'collection',
                         text: 'xx'
                         buttons : [{}]
                        }
]

})


Just an example of my code. As you see the datatable is calling an SP via the method CallSPMethod. This method will return content for the whole table. I would like to fill my button with data from another SP. Is this doable in a neat way? Or will it end up as a hack?

edit: https://datatables.net/extensions/buttons/examples/initialisation/collections-autoClose.html

Like this I would like to fill the datatable with content from one ajax call and would like to fill the button in the links case "Table Control" with content from another ajax call

Br,
Anton

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    Hi @aelgh ,

    That would be possible - buttons.buttons.text can be a function (see those examples), so it can get that text field from an Ajax call.

    Cheers,

    Colin

  • aelghaelgh Posts: 6Questions: 4Answers: 0

    Hey! @colin

    Thanks for quick answer. Just by a quick look I think this is what im looking for! Cheers :)
    Anton

This discussion has been closed.