DataTables AJAX source with sub-arrays and sAjaxDataProp

DataTables AJAX source with sub-arrays and sAjaxDataProp

MadmaxMadmax Posts: 4Questions: 0Answers: 0
edited August 2013 in DataTables 1.9
Hi
I need your help to treat this json :
[code]
{
"responseHeader": {
"status": 0,
"QTime": 9
},
"response": {
"numFound": 29,
"start": 0,
"maxScore": 0.9772936,
"docs": [
{
"title": "02-01 mj 11.pdf",
"url": "http://fic01.dev.xxx.grp/xxx/_dev/2118",
"[hl field=fulltext.snippet fragsize=150 snippet=3]": "Aspect commercial - Les missions xxx ",
"[indexid]": 1
},
{
"title": "K6100_0_0_ESSENTIEL_A_SAVOIR_Le_Scan.BGC.doc",
"url": "http://fic01.dev.xxx.grp/xxx/_dev/ged/2810",
"[hl field=fulltext.snippet fragsize=150 snippet=3]": "LE SCAN ESSENTIEL A SAVOIR - GENERALITES Fiche générique recouvrant toutes les missions d'aide et assistance regroupées dans la marque \"Le scan par xxx\". ",
"[indexid]": 2
},
{
"title": "K6100_0_0_ESSENTIEL_A_SAVOIR_Le_Scan.BGC.doc",
"url": "http://fic01.dev.xxx.grp/xxx/_dev/ged/2810",
"[hl field=fulltext.snippet fragsize=150 snippet=3]": "LE SCAN ESSENTIEL A SAVOIR – GENERALITES Fiche générique recouvrant toutes les missions d'aide et assistance regroupées dans la marque \"Le scan par xxx\". ",
"[indexid]": 3
},
{
"title": "K6100_0_0_ESSENTIEL_A_SAVOIR_Le_Scan.BGC.doc",
"url": "http://fic01.dev.xxx.grp/xxx/_dev/ged/2810",
"[hl field=fulltext.snippet fragsize=150 snippet=3]": "LE SCAN ESSENTIEL A SAVOIR – GENERALITES Fiche générique recouvrant toutes les missions d'aide et assistance regroupées dans la marque \"Le scan par xxx\". ",
"[indexid]": 4
},
{
"title": "http://xxx.intra.xxx.com/open_ged.php?id_ged=3027",
"url": "http://fic01.dev.xxx.grp/xxx/_dev/ged/3027",
"[hl field=fulltext.snippet fragsize=150 snippet=3]": "K163 Etat de l'installation intérieure de gaz - IE01 - 11_2012 ",
"[indexid]": 5
},
{
"title": "http://xxx.intra.xxx.com/open_ged.php?id_ged=1302",
"url": "http://fic01.dev.xxx.grp/xxx/_dev/ged/1302",
"[hl field=fulltext.snippet fragsize=150 snippet=3]": "K1263 VRE Systèmes d'extinction automatique à eau type sprinkleur dans un ERP ",
"[indexid]": 6
},
{
"title": "http://xxx.intra.xxx.com/open_ged.php?id_ged=1304",
"url": "http://fic01.dev.xxx.grp/xxx/_dev/ged/1304",
"[hl field=fulltext.snippet fragsize=150 snippet=3]": "K1265 VRE dans un ERP du type \"L\" avec espaces scéniques ",
"[indexid]": 7
},
{
"title": "http://xxx.intra.xxx.com/open_ged.php?id_ged=1305",
"url": "http://fic01.dev.xxx.grp/xxx/_dev/ged/1305",
"[hl field=fulltext.snippet fragsize=150 snippet=3]": "K1271 VRE dans un parc de stationnement couvert ",
"[indexid]": 8
},
{
"title": "http://xxx.intra.xxx.com/open_ged.php?id_ged=1306",
"url": "http://fic01.dev.xxx.grp/xxx/_dev/ged/1306",
"[hl field=fulltext.snippet fragsize=150 snippet=3]": "K1272 VRE dans un Etablissement pénitentiaire ",
"[indexid]": 9
},
{
"title": "http://xxx.intra.xxx.com/open_ged.php?id_ged=1533",
"url": "http://fic01.dev.xxx.grp/xxx/_dev/ged/1533",
"[hl field=fulltext.snippet fragsize=150 snippet=3]": "K 1203 Installation de gaz à usage médical ",
"[indexid]": 10
}
]
}
}
[/code]
Need url and title (columns) my code return no data :
[code]
<?php
$rep_jquery = "../_commun/jquery/"; //Répertoire ou se trouve les fichiers jquery
?>

@import "<?php echo $rep_jquery ?>jquery_datatables_table_jui.css";



title
url














$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "json.txt",
"sAjaxDataProp": "response",
"aoColumns": [
{ "mData": "docs.title" },
{ "mData": "docs.url" }
]
} );
} );

[/code]

thx for help !

Loïc

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Use sAjaxDataProp: "response.docs" - since its the docs array you want for the rows. Remove `docs.` from mData.

    Allan
  • MadmaxMadmax Posts: 4Questions: 0Answers: 0
    Yeah !!
    Thx Allan.

    Loïc
This discussion has been closed.