Filtering externally hosted GEOJSON data to not show certain results
Filtering externally hosted GEOJSON data to not show certain results
![[Deleted User]](https://secure.gravatar.com/avatar/22e649c501306c9aa077f905dbd6ee8f/?default=https%3A%2F%2Fvanillicon.com%2F22e649c501306c9aa077f905dbd6ee8f_200.png&rating=g&size=120)
Hi There,
I'm wondering if it's possible with the filter API to limit shown results in column 4 to not show files ending with .txt
$(document).ready(function() {
var table = $('#example').DataTable( {
var filteredData = table
.column( 4 )
.data()
.filter( function ( value, index ) {
return value != "*.txt") ? true : false;
}
"ajax":{
"url":"https://opendata.arcgis.com/datasets/TheFile.geojson",
"dataSrc": "features"
},
"columns": [
{ "data": "properties.BoreholeId"},
{ "data": "properties.ArchiveId" },
{ "data": "properties.Description" },
{ "data": "properties.UNCPath" }
],
dom: 'lfrtBip',
buttons: [
'copy', 'csv'
]
});
});
Cheers
RockE
This question has an accepted answers - jump to answer
Answers
The
filter()
API doesn't affect the Datatable rows displayed. From the docs:Depending on your goal and the amount of data you can use the
ajax.dataSrc
as a function and remove the appropriate data by iterating the JSON response.Another option is to simply use the
search
to set the initial search fo the table to filter those rows. The rows are still in the table and shown as part of the table info element. They potentially could be unfiltered and shown in the table.If you don't want the data at all then I would look for options to have the hosted side return the data as needed.
Kevin
Thanks Kevin, I'll check out these option.