Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82387

datatable serverSide_ dataSrc mapping _ some problem

$
0
0

Hello,

i get data from ajax and i need to apply JSON.parse before.
So i want use dataSrc like documentation explain.

If i do

                dataSrc: function (json) {
                    let jsonParse = JSON.parse(json)
                   return  jsonParse.data
                },

It's ok to populate Table... but i don't have draw, recordsFiltered, recordsTotal ( parts of my response Ajax).
It's normal..doc is clear with that.

So..i try to map src like doc explain :
__
Each mapping value may be a string in Javascript dotted object notation or a function. If a function a single parameter is passed in, the JSON response from the server, and the return value should be the value for the parameter
__

                dataSrc : {
                    data : function (json){
                        console.log('here')
                        let jsonParse = JSON.parse(json)
                        return  jsonParse.data
                    },
                    draw: function(json){
                        console.log('allo')
                    } ,
                    recordsTotal: 1,
                    recordsFiltered: 1
                },

This time, nothing happen... console.log are not display.

So.... why mapping don't work ?
And if mapping is broken,,...how i can display recordsFiltered/recordsTotal when i need to JSON.parse() my response Ajax


Viewing all articles
Browse latest Browse all 82387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>