I exported some QGIS data and I see one field was parsed incorrectly with a space. Here it is a partial list from console.log();
properties:
aa_lifts_count: 6
aa_lifts_length: 3526.712152733529
aa_pistes_count: 9
"aa_pistes_length ": 4269.831629811177
[snip]
As you can see "aa_pistes_length " has quotes and a trailing space. I do not know how to access this data in datatables. For instance, to access aa_lift_length I do the following;
{
data: "properties.aa_lifts_length",
defaultContent: "<i>Not set</i>",
render: function ( data, type, row ) {
return (data/1000).toFixed(2);
},
},
Based on this comment, I have tried;
{
data: 'properties.aa_pistes_length ', // added trailing space.
// also tried, '"properties.aa_pistes_length "'
defaultContent: "<i>Not set</i>",
render: function ( data, type, row ) {
return (data/1000).toFixed(2);
},
},
But I am unable to access the data. How do I access it please?
CodePudding user response:
You can use the following syntax to access the property with the key "aa pistes length" (notice the trailing space):
properties['aa_pistes_length ']
And here's a function you can use with your datatables.
{
data: null,
defaultContent: "<i>Not set</i>",
render: function ( data, type, row ) {
return (row.properties['aa_pistes_length ']/1000).toFixed(2);
},
},
The value of the property will be accessed, multiplied by 1000, and then formatted as a fixed-point number with two decimal places.