hi,
i have set of query results,added them to map as feature layer,
results were displaying in attribute table.but when i click on export to csv the operation is failing.
it display's "TypeError: Cannot read property 'query' of undefined" in console.please help me in this.
Thanks&Regards
Tarun
Solved! Go to Solution.
Robert
Thanks for your support ,i have added the code in export to csv function in featuretable.js,still i was unable to close the issue.below im adding export csv function code for your reference please go through it once ,i have highlighted code you given,please help me for resolving the issue.
exportToCSV : function(fileName, richTextFieldsToClear) {
if (!this.layerInfo || !this.layer || !this.tableCreated) {
return;
}
// var types = this.layer.types;
this.getSelectedRowsData().then(lang.hitch(
this,
function(datas) {
// seleted data process.
var oid = this.layer.objectIdField;
var _exportData = [];
var isSameProjection = this.layer.fullExtent.spatialReference.equals(
this.map.extent.spatialReference);
var hasArcadeExpressionFields = this._hasArcadeExpressionFields();
// if the output layer's spatial reference is the same as map's, which means
// a spatial reference conversion to make output data (X, Y fileds) consistent with
//layer's original projection system is NOT needed. then we can use data from client side.
// if they are different, then it needs to send a query request to
// server side (handle by "_getExportDataFromServer" method in jimu/CSVUtils.js)
// to get the data with correct spatial reference
if(isSameProjection) {
var rows = array.map(
this._getTableSelectedIds(),
lang.hitch(this, function(id) {
for (var i = 0, len = datas.length; i < len; i++) {
if (datas && datas[oid] === id) {
return datas;
}
}
return {};
})
);
var _selectedData = rows || [];// get selected data
// if table were in selection mode and no records were selected, we push an
// empty object to _selectedData, for the following logic compatible.
if(_selectedData.length === 0 && this.isSelectionMode()){
_selectedData.push({});
}
_exportData = _selectedData;
if(_selectedData.length === 0 && this.grid.store instanceof Memory){
_exportData = lang.clone(this.grid.store.data);
}
if(_exportData.length){
this._appendXY(_exportData);
}
}
var options = {};
var _outFields = this.getOutFields(!!_exportData.length);
options.datas = _exportData;
options.fromClient = false;
if(this.layer.declaredClass === 'esri.layers.FeatureLayer' && !this.layer.url)
{ options.fromClient = true; }
options.withGeometry = this.layer.geometryType === 'esriGeometryPoint';
options.outFields = _outFields;
options.formatNumber = false;
options.formatDate = true;
options.formatCodedValue = true;
options.popupInfo = this.layerInfo.getPopupInfo();
//if spatial reference needs to be converted:
// 1. query data using object ids
options.objectIds = !isSameProjection && this._getExportObjectIds();
// 2. use layer's default spatial reference as the output to do
// the conversion on the server side
options.outSpatialReference = !isSameProjection &&
lang.clone(this.layer.fullExtent.spatialReference);
// pass in rich text fields to be cleared:
options.richTextFieldsToClear = richTextFieldsToClear;
// if the output layer has arcade expressions configured, the computed values
// need to be added to each data to be exported
if(hasArcadeExpressionFields) {
options.arcadeExpressions = {
expressionInfos: this.layerInfo.getPopupInfo().expressionInfos,
layerDefinition: jimuUtils.getFeatureLayerDefinition(this.layer)
};
}
return CSVUtils.exportCSVFromFeatureLayer(
fileName || this.configedInfo.name,
this.layer, options);
}
));
},
.