Dynamic extraction of set fields
Dynamic extraction of set fields
I want the function CreeTableau in the script hereby to extract and display the information in the same way the basic Datatable shows up (http://www.datatables.net/examples/api/row_details.html). Right now it displays only as txt form from ajax. Example of display:
{
"data": [
{
"name": "soso, ssosos",
"status": "Director",
"affiliation": "Anywhere",
"courriel": " ",
"bureau": " ",
"telephoneCRM": " ",
"telephoneAutre": " ",
"page": " "
},
{
"name": " ",
"status": " ",
"affiliation": " ",
"courriel": " ",
"bureau": " ",
"telephoneCRM": " ",
"telephoneAutre": " ",
"page": " "
},
]
}
How do I do that? Thank you.
http://www.crm.umontreal.ca/repertoire/repertoire.shtml
<script type="text/javascript" src="media/js/site.js"></script>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript" src="resources/demo.js"></script>
<script type="text/javascript" class="init">
/* Formatting function for row details - modify as you need */
function format ( d ) {
// d
is the original data object for the row
return '
Courriel: | '+ ''+d.courriel+' | '+ '
Bureau: | '+ ''+d.bureau+' | '+ '
Telephone CRM: | '+ ''+d.telephoneCRM+' | '+ '
Telephone Autre: | '+ ''+d.telephoneAutre+' | '+ '
Page web page: | '+ ''+d.page+' | '+ '
';
}
$(document).ready(function() {
var table = $('#example').DataTable( {
"ajax": "tous.txt",
"columns": [
{
"class": 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{ "data": "name" },
{ "data": "status" },
{ "data": "affiliation" }
],
"order": [[1, 'asc']]
} );
// Add event listener for opening and closing details
$('#example tbody').on('click', 'td.details-control', function () {
var tr = $(this).closest('tr');
var row = table.row( tr );
if ( row.child.isShown() ) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
}
else {
// Open this row
row.child( format(row.data()) ).show();
tr.addClass('shown');
}
} );
// Modification proposee par Michele Nasoni pour changer de tables sur choix de menu
$( "#SelectMenu" ).change(function() {
var table = $('#example').dataTable();
table.fnReloadAjax( $(this).val() );
} );
} );
</script>
<SCRIPT>
</SCRIPT>
</head>
<body>
<span class="titreGras">RÉPERTOIRE / DIRECTORY </span>
<span class="pos_fixed"> Recherche par statut / Search by status
document.write(""); document.write(""); Nombre = LibelleOption.length; for (var i = 1; i <= Nombre; i++) document.write("<OPTION>" +LibelleOption[i]); document.write(''); document.write(''); // --></span>
<
p>
Nom/Name | Statut/Status | Affiliation | |
---|---|---|---|
Nom/Name | Statut/Status | Affiliation |