I have a Object that contain objetcs like this.Object {MAILING ADDRESS: "P O BOX 59", APN: "066-102-11-1"}
. Now I need data without empty Object. Like I get output like this Output
Object {MAILING ADDRESS: "P O BOX 59", APN: "066-102-11-1"}
Object {MAILING ADDRESS: "", APN: ""}
Object {MAILING ADDRESS: "P O BOX 3", APN: "066-105-11-1"}
Object {MAILING ADDRESS: "", APN: ""}
So in this case I dont want to get 2nd and 4th object. And in case of 100 I dont want to get 2,4,6,8..100 index . Because output after one time is repeating and I have to remove this. ScreenShot of output I getting
//Code How I am creating this
ExportTool.prototype.click = function(value) {
var lidtest = mapport.panels.info.current.selection.features.mem;
if (value != undefined) {
var lid = lidtest[value].attributes.layer_id;
} else {
var lid = lidtest[0].attributes.layer_id;
}
if (!lid) return;
var tbody;
var thead;
tbody = $('<tbody></tbody>');
thead = $('<thead></thead>');
self = this;
// Reset
this.tblHeader = [];
this.tblData = [];
this.labelData = [];
// thead.children().remove();
// tbody.children().remove();
//var tbody;
var layer = mapport.layer(lid);
var tr = $('<tr></tr>');
layer.fields.each(function(field) {
tr.append($('<th ></th>').text(field.name));
// Table heading for the PDF
if (self.availableForTable.indexOf(field.name.toUpperCase()) != -1)
self.tblHeader.push(field.name);
});
tbody.append(tr);
var features = mapport.panels.info.current.features();
for (var i = 0; i < features.length; ++i) {
if (features[i].geometry != null) {
var data = features[i].attributes.data,
row_data = [],
row_field, obj_field = {};
tr = $('<tr></tr>');
layer.fields.each(function(field) {
var field_name = field.name.toUpperCase();
var td = $('<td></td>');
if (data[field.id] != null) td.text(data[field.id]);
tr.append(td);
if (self.availableForTable.indexOf(field_name) != -1) {
row_field = (data[field.id] != null) ? data[field.id] : '';
row_data.push(row_field);
obj_field[field_name] = row_field;
}
});
row_data = row_data.filter(function(entry) {
return /S/.test(entry);
});
obj_field = JSON.parse(obj_field);
console.log(obj_field);
// Table Data for the PDF
this.tblData.push(row_data);
// Table Data for the PDF
this.labelData.push(obj_field);
tbody.append(tr);
$('#table_multi_layers').append(tbody);
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…