"
, info: "Zeige Einträge _START_ bis _END_ von _TOTAL_ Einträgen"
, infoEmpty: "Zeige Eintrag 0 bis 0 von 0 Einträgen"
, emptyTable: "Zurzeit sind keine Daten für die gewählten Filter verfügbar"
, zeroRecords: "Keine Daten für die gewählten Filter verfügbar"
, lengthMenu: "Zeige _MENU_ Einträge"
, thousands: "'"
, paginate: {
first: "<<",
last: ">>",
next: ">",
previous: "<"
}
}
, createdRow: function(row, data, dataIndex) { // Callback after a row was created
console.log("row created "+(Date.now()-timestampBeforeAjaxCall)+'ms) ');
var title="";
var iconClass="";
var iconName="";
if ('deal_type' in data && (data.deal_type=='LIVING_APARTMENT_BUY' || data.deal_type=='LIVING_HOUSE_BUY') || data.deal_type=='PROPERTY_BUY') {
$(row).addClass("buy");
title+="Dieses Objekt wird in diesem Angebot zum Kauf angeboten.";
iconClass="iconBadgeBuy";
iconName="KAUF";
} else if ('deal_type' in data && (data.deal_type=='LIVING_APARTMENT_RENT' || data.deal_type=='LIVING_HOUSE_RENT')) {
$(row).addClass("rent");
title+="Dieses Objekt wird in diesem Angebot zur Miete angeboten.";
iconClass="iconBadgeRent";
iconName="MIETE";
}
$(row).find('td:first-child').css('height','1px').addClass('p-0').append('
');
if ('matched' in data && data.matched && !hideMatchedOffer) {
$(row).addClass("match");
title+=" Dieses Immobilienangebot wurde anhand der Filterkriterien gefunden.";
}
if ('outlier' in data && data.outlier) {
$(row).addClass("outlier");
title+=" Dieses Immobilienangebot beinhaltet möglicherweise fehlerhafte Informationen, da sehr ungewöhnliche oder unübliche Werte erkannt wurden.";
}
if (title!='') $(row).find('td:first-child').attr('data-toggle','tooltip').attr('title',title);
}
, fixedHeader: true
, rowGroup: {
dataSrc: function(d) {
return d.fk_objects;
},
className: 'bg-light',
startRender: function (rows, group) {
console.log("row group created "+(Date.now()-timestampBeforeAjaxCall)+'ms) ');
// Make row group collapse it's child rows
rows.nodes().each(function (r) {
$(r).attr('data-name', group+'_child');
});
// Create group row content
var rowObj=$('
|
').attr('data-name', group);
var groupRowContent="";
var row;
if (rows!==null && rows.rowGroup()!==null && rows.rowGroup()[0].length && rows.rowGroup()[0][0]!==null) {
row=rows.row(rows.rowGroup()[0][0]);
if (row!==null && row.data()!=null) {
// Create default object title
var defaultObjectTitle="";
if ('country' in row.data() && row.data().country!==null) defaultObjectTitle+=(defaultObjectTitle=='' ? '' : ', ')+row.data().country;
if ('zip' in row.data() && row.data().zip!==null) defaultObjectTitle+=(defaultObjectTitle=='' ? '' : ', ')+row.data().zip;
if ('city' in row.data() && row.data().city!==null) defaultObjectTitle+=(defaultObjectTitle=='' ? '' : ', ')+row.data().city;
if ('street' in row.data() && row.data().street!==null) {
defaultObjectTitle+=(defaultObjectTitle=='' ? '' : ', ')+row.data().street;
if ('nr' in row.data() && row.data().nr!==null) defaultObjectTitle+=" "+row.data().nr;
}
if ('sqmLiving' in row.data() && row.data().sqmLiving!==null) defaultObjectTitle+=(defaultObjectTitle=='' ? '' : ', ')+row.data().sqmLiving+'qm';
if ('sqmEstate' in row.data() && row.data().sqmEstate!==null) defaultObjectTitle+=(defaultObjectTitle=='' ? '' : ', ')+"Grundstück: "+row.data().sqmEstate+'qm';
if ('nrRooms' in row.data() && row.data().nrRooms!==null) defaultObjectTitle+=(defaultObjectTitle=='' ? '' : ', ')+"Räume: "+row.data().nrRooms;
if ('constructionYear' in row.data() && row.data().constructionYear!==null) defaultObjectTitle+=(defaultObjectTitle=='' ? '' : ', ')+"Baujahr: "+row.data().constructionYear;
// Create real object title
if ('favouriteObjectName' in row.data() && row.data().favouriteObjectName!==null) { // pre-set favorite name exists
groupRowContent+=row.data().favouriteObjectName;
} else {
groupRowContent+=defaultObjectTitle;
}
if (groupRowContent=='') groupRowContent='Keine Objektdaten verfügbar.';
groupRowContent='
'+ObjectsDataTable.getGroupRowTitle(groupRowContent)+'';
// Favorite star & Object social sharing
const urlSocialSharing=websiteUrl+'?objectIds='+row.data().fk_objects+'&objectType='+row.data().object_type;
var htmlFavorite;
if (typeof userSettings === 'undefined') { // User is not logged in
htmlFavorite='';
} else {
htmlFavorite='
'+('favouriteObject' in row.data() && row.data().favouriteObject ? ObjectsDataTableGUI.favouriteStarOn : ObjectsDataTableGUI.favouriteStarOff)+'';
}
const htmlShare='
'
groupRowContent=htmlFavorite+htmlShare+groupRowContent;
z
} else {
groupRowContent='Objektdaten sind zurzeit nicht verfügbar.';
}
} else groupRowContent='Objektdaten sind zurzeit nicht verfügbar.';
rowObj.append('
'+groupRowContent+' | ');
return rowObj;
}
}
, serverSide: true
, processing: true
, ajax: {
url: apiUrl//apiHost+apiPath+'?'+apiHttpGetParameterStr
, type: 'GET'
, data: function(d) {
parent.datatablesPrepareRequestParameters(d); // prepare prequest parameters
}
, beforeSend: function() {
timestampBeforeAjaxCall=Date.now();
var table=$('#'+parent.dataTableGuiObj.idDataTable);
if (table.length) {
if (table.DataTable().hasOwnProperty('settings')) {
if ('jqXHR' in table.DataTable().settings()[0] && table.DataTable().settings()[0].jqXHR!==null) { // if there were previous ajax calls
table.DataTable().settings()[0].jqXHR.abort();
console.log("ABORT PREVIOUS AJAX CALL");
}
}
}
}
, dataFilter: function(data) { // Called first. A function to be used to handle the raw response data of XMLHttpRequest. MUST return a string, not a JSON object. https://api.jquery.com/jQuery.ajax/
console.log('AJAX SUCCESS: ('+(Date.now()-timestampBeforeAjaxCall)+'ms) '+apiUrl);
var json = $.parseJSON(data);
var jsonNew={};
if (json.status=='error') {
jsonNew.recordsTotal = 0; // Total and filtered are the same
jsonNew.recordsFiltered = 0;
jsonNew.data = {};
} else {
jsonNew.recordsTotal = json.totalElements; // Total and filtered are the same
jsonNew.recordsFiltered = json.totalElements;
jsonNew.data=[];
for (var objectObj of json.content) {
//console.log(objectObj);
for (var offerObj of objectObj.offers) {
if (offerObj.matched) offerObj.offerDetails['matched']=true;
jsonNew.data.push(offerObj.offerDetails);
}
}
if (!(typeof userSettings === 'undefined')) { // User is logged in
for (var rowObj of jsonNew.data) {
if ('favouriteOffers' in userSettings) {
for (var favouriteObj of userSettings.favouriteOffers) {
if (favouriteObj.pkOffers==rowObj.id) {
rowObj.favouriteOffer=true;
break;
}
}
}
}
// Mark favourite objects (to make sure the star in data table row is highlighted)
for (var rowObj of jsonNew.data) {
if ('favouriteObjects' in userSettings) {
for (var favouriteObj of userSettings.favouriteObjects) {
if (favouriteObj.fkObjects==rowObj.fk_objects) {
rowObj.favouriteObject=true;
rowObj.favouriteObjectName=favouriteObj.name;
break;
}
}
}
}
}
}
return JSON.stringify(jsonNew); // return JSON string
}
}
, columns: colsReturn
, initComplete: function(settings, json) { // Table is created and drawn and data are loaded
console.log('initComplete Callback START '+(Date.now()-timestampBeforeAjaxCall)+'ms) ');
if (groupsCollapsed) {
$(this).find('tbody tr:not(.dtrg-start)').addClass('collapsedCustom');
}
if ($(this).DataTable().column(0).data().length==0) {
console.log('NO DATA');
parent.dataTableGuiObj.showEmpty();
}
}
, drawCallback: function( settings ) {
console.log('drawCallback '+(Date.now()-timestampBeforeAjaxCall)+'ms) ');
}
, rowCallback: function( row, data ) {
console.log('rowCallback '+(Date.now()-timestampBeforeAjaxCall)+'ms) ');
}
};