I am new to cartodb and i don't understand how to populate a bootstrap table with my json data retreived using sql.execute:

sql.execute("SELECT sonde.the_geom,sonde.nom,sonde_data.time,sonde_data.cod,sonde_data.fluo FROM sonde, sonde_data WHERE sonde.nom = sonde_data.ref_id_nom AND sonde.cartodb_id = '"+selection+"' ORDER by time").done(function(data) {

for (i in data.rows){

        $(function () {
            //method: 'get',
            data: data,
            cache: false,
            height: 400,
            striped: true,
            pagination: true,
            pageSize: 50,
            pageList: [10, 25, 50, 100, 200],
            search: true,
            showColumns: true,
            showRefresh: true,
            minimumCountColumns: 2,
            clickToSelect: true,
            columns: [{
                field: 'data.nom',
                title: 'nom',
                align: 'center',
                valign: 'bottom',
                sortable: true
            }, {
                field: 'data.fluo',
                title: 'fluo',
                align: 'center',
                valign: 'middle',
                sortable: true,

            }, {
                field: 'data.cod',
                title: 'cod',
                align: 'center',
                valign: 'top',
                sortable: true



enter code 

I am unable to display my data into the table, i don't know how to call it... Could someone give me the clue please?

1 Answer 1


Since you're already looping through data.rows, which contains the data, this looks more like a Bootstrap question. I've just done an example of html table from CartoDB SQL API data with plain JS:

<script> var table = document.getElementById('mytable'); var sql = cartodb.SQL({ user: 'documentation' }); sql.execute("select adm0name, name from ne_10m_populated_places_simple_1 limit 10") .done(function(data) { data.rows.map(function(r) { var row = document.createElement('tr'); var nameCell = document.createElement('td'); nameCell.innerText = r.name; row.appendChild(nameCell); table.appendChild(row); }); }) </script>


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.