POST
|
Working with the ArcGIS JavaScript API version 4.13 and was able to build popup templates that included data attributes to work with the Semantic UI library for their Tab module (https://semantic-ui.com/modules/tab.html). I recently upgraded to version 4.16 and now the template is broken. Upon examining the html when rendered it strips key data-attributes for tabs (data-tab) prevent it from working. Is there a way to force explicit content and prevent the template from being modified in version 4.16 or if this expected going forward? Thanks. Example (Click on the map to launch the popup) Version 4.13 Working: https://codepen.io/booshwa/pen/ExPJgRz Version 4.16 Broken: https://codepen.io/booshwa/pen/qBbwaJB
... View more
07-25-2020
05:41 PM
|
0
|
2
|
1408
|
POST
|
Hello, I am hoping someone out there has some experience with creating new records on tables because I have not seen any posts or examples of doing this. I have created my own editor tool consisting of the template picker and a custom attribute editor/field validator. It also checks if the featurelayer supports attachments and related records. If the selected feature supports related records it will allow the user to view/add/edit/delete records on the tables. Everything is working except for the add record part. I added the table as a featurelayer which supports editing and deleting of the tables records. When the user clicks a button to add a record, it queries the selected graphic and copies the related ID which is a GUID (Not the ObjectID field) and places it in the attribute object before edits are applied to the table. The next step is to display the attributes to allow the user to enter more information for each field. An error ("Internal error during object insert.") is thrown which is because it does not autoincrement the ObjectID. So I used the StatisticDefinition to query the max ObjectID, add 1, and added it to the attribute table with the related ID. It still throws the error. The remaining fields are set to null. My question is does the related tables support adding new records? If the server does not create an objectID for me and I cannot supply an objectID because that field is not editable, how do we create a new record on the client's side? I am using version 3.6 and we are using ArcGIS Server 10.1. Below is the code that fires after the user clicks a button to add a new record to the table. Thanks.
$("#addRelBtn").click(function() {
var query = new Query();
// Table is a featurelayer and gra is the selected graphic
console.log(table);
console.log(gra);
// Get graphic attributes, create new record, query record and pass to buildAttr.
var arr = {};
var field;
// Matches table and layer IDs
$.each(table.relationships, function(i) {
if (table.relationships.relatedTableId == gra._graphicsLayer.layerId) {
field = table.relationships.keyField;
}
})
// Query the table to return incremented ID
var statDef = new StatisticDefinition();
statDef.statisticType = "max";
statDef.onStatisticField = '"'+table.objectIdField+'"';
statDef.outStatisticFieldName = "maxID";
query.where = table.objectIdField+" >= 0";
query.returnGeometry = false;
query.outFields = [ table.objectIdField ];
query.outStatistics = [ statDef ];
queryTask.execute(query, function(result) {
// Loop each field to find the related field and objectid field
$.each(table.fields, function(i) {
console.log(table.fields);
if (table.fields.name === field) {
var attr = "gra.attributes."+oldResp.relationships[0].keyField;
arr[table.fields.name] = eval(attr);;
} else if (table.fields.name == table.objectIdField) {
arr[table.fields.name] = result.features[0].attributes.maxID + 1;
} else {
arr[table.fields.name] = null;
}
})
console.log(arr);
var ng = new esri.Graphic(null, null, arr);
console.log(ng);
table.on("edits-complete", function(evt) {
console.log(evt);
if (evt.updates[0].success === true) {
alert('New record added.');
// buildAttr(table, result.features[str], table, "rel", null);
}
})
table.applyEdits([arr], null, null)
})
})
... View more
05-19-2014
09:09 AM
|
0
|
0
|
1343
|
Online Status |
Offline
|
Date Last Visited |
03-11-2022
01:28 PM
|