// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
require({cache:{"url:esri/dijit/FeatureTable/templates/Grid.html":'\x3cdiv\x3e\r\n  \x3cdiv class\x3d"${css.borderContainer}" data-dojo-attach-point\x3d "_gridBorderContainerNode" data-dojo-type\x3d"dijit/layout/BorderContainer" gutters\x3d"false"\x3e\r\n    \x3cdiv class\x3d"${css.contentPane} ${css.menu}" data-dojo-attach-point\x3d "_gridHeaderNode" data-dojo-type\x3d"dijit/layout/ContentPane" data-dojo-props\x3d"region: \'top\'"\x3e\r\n      \x3cdiv class\x3d"${css.menuItem} ${css.loadingIndicator} ${css.hidden}" data-dojo-attach-point\x3d "_gridLoadingIndicatorNode"\x3e\x3c/div\x3e\r\n      \x3cdiv class\x3d"${css.menuItem} ${css.menuOptions}" data-dojo-attach-point\x3d "_menuNode" \x3e\r\n        \x3cdiv data-dojo-attach-point\x3d "_gridMenuNode"\x3e\x3c/div\x3e\r\n      \x3c/div\x3e\r\n      \x3cdiv class\x3d"${css.menuItem} ${css.title}" data-dojo-attach-point\x3d "_gridTitleNode"\x3e\x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"${css.contentPane}" data-dojo-attach-point\x3d "_gridContentPaneNode" data-dojo-type\x3d"dijit/layout/ContentPane" data-dojo-props\x3d"region: \'center\'"\x3e\r\n      \x3cdiv class\x3d"${css.grid}" data-dojo-attach-point\x3d"_gridNode"\x3e\x3c/div\x3e\r\n    \x3c/div\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e'}});
define("esri/dijit/FeatureTable/Grid","../../kernel ./dataUtils ./dialogUtils dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/aspect dojo/has dojo/keys dojo/on dojo/string dojo/dom-class dojo/dom-construct dojo/Deferred dojox/html/entities dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin dijit/_WidgetBase dijit/a11yclick dijit/focus dijit/Menu dijit/MenuItem dijit/Tooltip dijit/form/Button dijit/form/DateTextBox dijit/form/DropDownButton dijit/form/NumberTextBox dijit/form/Select dijit/form/TimeTextBox dijit/form/ValidationTextBox dijit/layout/BorderContainer dijit/layout/ContentPane dgrid/OnDemandGrid dgrid/Selection dgrid/selector dgrid/Keyboard dgrid/editor dgrid/extensions/Pagination dgrid/extensions/DijitRegistry dgrid/extensions/ColumnHider dgrid/extensions/ColumnResizer dojo/i18n!../../nls/jsapi dojo/text!./templates/Grid.html".split(" "),
function(N,g,F,G,e,r,H,O,z,q,B,y,t,P,I,C,Q,R,x,S,J,A,T,ha,K,ia,D,E,U,V,ja,ka,W,X,Y,Z,aa,ba,ca,da,ea,fa,ga){C=G([R,C,Q],{declaredClass:"esri.dijit.FeatureTable.Grid",baseClass:"esri-feature-table-grid",templateString:ga,map:null,layer:null,layerInfo:null,idProperty:"id",sort:null,defaultSort:null,filterIds:null,where:null,batchCount:50,editable:!1,editOn:"dblclick, keypress",css:null,showAttachments:!1,showRelatedRecords:!1,showCyclicalRelationships:!1,showStatistics:!1,showFieldDetails:!1,showGridHeader:!0,
showGridMenu:!0,showFilterMenuItems:!0,showDefaultSortMenuItem:!0,showFeatureCount:!0,showDataTypes:!1,showColumnHeaderTooltips:!1,showColumnHider:!1,syncSelection:!1,menuFunctions:null,columnMenuFunctions:null,gridOptions:null,dateOptions:null,visibleLayerIds:null,showExpressionFields:!1,loaded:!1,store:null,columns:null,fieldInfos:null,customFieldInfos:null,expressionInfos:null,expressionCache:{},noDataMessage:"",featureCount:0,selectedFeatureCount:0,selectedRows:null,selectedRowIds:null,optionsMenu:null,
optionsMenuAnchor:null,columnMenu:null,rollbackInfos:null,attachmentInfos:null,relatedRecordInfos:null,relatedRecordCounts:null,_i18nStrings:fa.widgets.FeatureTable,_numericFieldTypes:["esriFieldTypeInteger","esriFieldTypeSingle","esriFieldTypeDouble","esriFieldTypeSmallInteger","number"],_unsupportedFieldTypes:["esriFieldTypeGUID","esriFieldTypeRaster","esriFieldTypeBlob","esriFieldTypeGeometry","esriFieldTypeXML"],_activeEditors:[],_relationshipColumnLimit:5,_nullConstant:"ft_null",_watchers:null,
_tableTitle:null,_previousSelectedRowIds:null,postMixInProperties:function(){this.inherited(arguments);this.set({sort:{},columns:[],fieldInfos:[],selectedRows:[],selectedRowIds:[],rollbackInfos:{},attachmentInfos:{},relatedRecordInfos:{},relatedRecordCounts:{},_watchers:[],_previousSelectedRowIds:[]})},startup:function(){this.inherited(arguments);this.showExpressionFields&&this.expressionInfos&&(this.expressionCache=g.compileExpressions(this.expressionInfos));this.dGrid=this._createGrid();this._cleanUpGrid();
this.dGrid.startup();this.dGrid.resize();this.showLoadingIndicator();this.updateHeaderText();this.showGridHeader||this.hideHeader();this._generateOptionsMenu();this.showGridMenu||this.hideOptionsMenu();this._addGridListeners()},destroy:function(){this.inherited(arguments);this.optionsMenu&&this.optionsMenu.destroy();this.columnMenu&&this.columnMenu.destroyRecursive();r.forEach(this._watchers,function(a){a.remove()})},resize:function(){this._gridBorderContainerNode&&this._gridBorderContainerNode.resize();
this._gridHeaderNode&&this._gridHeaderNode.resize();this._gridContentPaneNode&&this._gridContentPaneNode.resize();this.dGrid&&this.dGrid.resize()},setHeaderTitle:function(a){this._gridTitleNode&&(this._gridTitleNode.innerHTML=a)},showHeader:function(){y.remove(this._gridHeaderNode.domNode,this.css.hidden);this.resize()},hideHeader:function(){y.add(this._gridHeaderNode.domNode,this.css.hidden);this.resize()},showLoadingIndicator:function(){this._gridLoadingIndicatorNode&&y.remove(this._gridLoadingIndicatorNode,
this.css.hidden)},hideLoadingIndicator:function(){this._gridLoadingIndicatorNode&&y.add(this._gridLoadingIndicatorNode,this.css.hidden)},showOptionsMenu:function(){this._menuNode&&y.remove(this._menuNode,this.css.hidden)},hideOptionsMenu:function(){this._menuNode&&y.add(this._menuNode,this.css.hidden)},updateNoDataMessage:function(a){this.dGrid.set("noDataMessage",a)},showColumnHiderMenu:function(){this.gridOptions.columnHider&&this.dGrid._toggleColumnHiderMenu()},refresh:function(){this.dGrid&&this.dGrid.refresh();
0===this.featureCount&&this.hideLoadingIndicator();this._updateSelection().then(e.hitch(this,this.updateHeaderText))},getRowById:function(a){return this.dGrid.row(a)||{}},getRowDataById:function(a){return(a=this.getRowById(a))&&a.data?a.data:{}},emptyStore:function(){this.updateNoDataMessage("");this.updateStore(null)},updateStore:function(a){this.set("store",a);this.dGrid.set("store",a)},updateSort:function(a){this.set("sort",a[0]);this.dGrid.set("sort",a)},updateSelectionMode:function(a){this.dGrid.set("selectionMode",
a)},getColumns:function(){return this.dGrid.columns},styleColumn:function(a,b){return this.dGrid.styleColumn(a,b)},clearSelection:function(){this.dGrid.clearSelection();this._updateSelection().then(e.hitch(this,this.updateHeaderText));this.emit("clear-selection")},centerOnSelection:function(){var a=this.map,b=this.selectedRowIds;if(a&&b&&0!==b.length)return g.queryLayerForFeatures({layer:this.layer,ids:b}).then(e.hitch(function(b){(b=b.features)&&0<b.length&&a.setExtent(g.calculateExtentFromFeatures(b))}))},
selectRows:function(a,b,d){var c=this.dGrid,f=[],k;this._closeCellEditors();this.clearSelection();a instanceof Array?(r.forEach(a,function(a){c._select(a);f.push(this.getRowById(a))},this),k=a[0]):(c._select(a),k=a,f=[this.getRowById(a)]);this._updateSelection().then(e.hitch(this,function(){this.updateHeaderText();d||this.emit("row-select",{rows:f,grid:this.dGrid});b&&this._scrollToRow(k)}))},_createGrid:function(){return new (this._generateGridClass())({columns:this.columns,sort:[this.defaultSort],
noDataMessage:this.noDataMessage,selectionMode:this.gridOptions.selectionMode,allowSelectAll:this.gridOptions.allowSelectAll,allowTextSelection:this.gridOptions.allowTextSelection,cellNavigation:this.gridOptions.cellNavigation,keepScrollPosition:this.gridOptions.keepScrollPosition,pageSizeOptions:this.gridOptions.pageSizeOptions,queryRowsOverlap:this.gridOptions.queryRowsOverlap,minRowsPerPage:this.batchCount,maxRowsPerPage:this.batchCount,pagingDelay:this.pagingDelay,query:e.hitch(this,this._getQueryForGrid)},
this._gridNode)},_generateGridClass:function(){var a=[ca,W,X,aa,Y,Z];this.gridOptions.pagination&&a.push(ba);this.gridOptions.columnHider&&a.push(da);this.gridOptions.columnResizer&&a.push(ea);return G(a)},_getQueryForGrid:function(a){return!this.filterIds||-1!==r.indexOf(this.filterIds,a[this.idProperty])},_cleanUpGrid:function(){var a=this.dGrid,b=H.before(a,"removeRow",e.hitch(this,function(b){r.forEach(this.columns.length,function(c,d){var f=a.cell(b,d).element;(f=(f.contents||f).widget)&&f.destroyRecursive()})})),
d=H.after(a,"renderHeader",function(){a._sortListener.remove()});this._watchers.push(b,d)},_setUpColumns:function(a){a=this._generateFieldInfos(a);var b=this._generateColumns(a);this.set({columns:b,fieldInfos:a});this.dGrid.set("columns",b);return{fieldInfos:a,columns:b}},_generateFieldInfos:function(a){if(a&&0!==a.length&&this.layerInfo){a=this._orderFieldsForDisplay(a);var b=this.layer,d=this.layerInfo,c=[],f=this.customFieldInfos;r.forEach(a,function(a){var e=a.name,k=a.length||null,n=g.findFirst(b.fields,
"name",e)||{},l=g.findFirst(f,"name",e)||g.findFirst(f,"fieldName",e);if(g.isExpressionField(e))n=g.getExpressionInfo(this.expressionInfos,e),c.push({name:n.name,expression:!0,length:k,hidden:!l.visible,alias:a.alias,type:a.type,editable:a.editable,nullable:a.nullable,domain:!1,typeId:!1,subtypeDomain:!1,format:l.format||null,dateOptions:null});else{var u=this.idProperty,p=this.outFields,t=this.hiddenFields,L,M,q,w,v;L=l&&(l.label||l.alias)||n.alias;M=b.getDomain&&b.getDomain(e)?b.getDomain(e):!1;
q=!(!d.typeIdField||e!==d.typeIdField);w=d.types&&r.some(d.types,function(a){if(a.domains&&a.domains[e]&&a.domains[e].name)return!0});v=!this._getFieldVisibility({field:a,hiddenFields:t,customFieldInfo:l,outFields:p});p=d.editable&&d.editCapabilities.canUpdate;t=l&&("undefined"!==typeof l.editable&&!1!==n.editable||"undefined"!==typeof l.isEditable&&!1!==n.isEditable);c.push({name:e,alias:L,length:k,type:a.type,hidden:v,editable:p&&e!==u&&n&&"undefined"!==n.editable?t?!!l.editable||!!l.isEditable:
!!n.editable:!1,nullable:!!n.nullable,domain:M,typeId:q,subtypeDomain:w,format:l&&l.format?l.format:null,dateOptions:l&&(l.dateOptions||l.format&&l.format.dateFormat)||null})}},this);r.every(c,function(a){return a.hidden})&&(g.findFirst(c,"name",this.idProperty).hidden=!1);this.showRelatedRecords&&(a=this._generateRelatedRecordFieldInfos({relationships:b.relationships}),c=c.concat(a));this.showAttachments&&c.push({alias:this._i18nStrings.photosAndFiles,name:"esriAttachments",type:"esriAttachments",
editable:d.editable});return c}},_destroyColumns:function(){this.dGrid&&this.dGrid._destroyColumns()},_getFieldVisibility:function(a){var b=a.field,d=a.outFields,c=a.customFieldInfo;a=-1!==r.indexOf(a.hiddenFields,b.name);c=!(!c||!1!==c.visible);d="*"!==d[0]&&-1===r.indexOf(d,b.name);b="esriFieldTypeOID"===b.type||"esriFieldTypeGlobalID"===b.type;return!(a||b&&(c||d)||c||d)},_applyEdits:function(a){var b=a.row,d=a.rollbackInfo;this.showLoadingIndicator();d&&this._updateRollbackInfos(d);this.emit("data-change",
{row:b,rollbackInfo:d});return g.applyEditsFromRow({layer:this.layer,idProperty:this.idProperty,row:b}).then(e.hitch(this,function(a){var c=a.updates||[];c&&c.length&&r.forEach(c,function(a){a.success||(a.error?this.emit("error",{message:a.error}):this.emit("error",{message:this._i18nStrings.errorUpdateFailed}),d?(b=this.getRowDataById(d.rowId),b[d.fieldName]=d.oldValue,this.dGrid.updateDirty(d.rowId,d.fieldName,d.oldValue),this.refresh()):this.emit("error",{message:this._i18nStrings.errorRollback}))},
this);this.hideLoadingIndicator();this.emit("edits-complete",a)})).otherwise(e.hitch(this,function(){d&&(b=this.getRowDataById(d.rowId),b[d.fieldName]=d.oldValue,this.dGrid.updateDirty(d.rowId,d.fieldName,d.oldValue),this.refresh());this.hideLoadingIndicator();this.emit("error",{message:this._i18nStrings.errorUpdateFailed})}))},_updateRollbackInfos:function(a){if(a){var b=a.rowId;this.rollbackInfos[b]||(this.rollbackInfos[b]=[]);this.rollbackInfos[b].push(a)}},_updateSelection:function(){var a=this.dGrid.selection,
b=new P,d=[],c=[],f,e;for(e in a)a.hasOwnProperty(e)&&(f=parseInt(e,10),c.push(f),f=this.dGrid.row(f),(f=f.data)&&d.push(f));a={selectedRows:d,selectedRowIds:c,selectedFeatureCount:c.length};this.set(a);b.resolve(a);return b},_scrollToRow:function(a){var b=this.store,d=this.dGrid,c=d.row(a),f=this.sort;if(c&&b)if(c.element)c.element.scrollIntoView();else if(a=b.data[a]||c.data)b=f&&f.attribute===this.idProperty&&f.descending?b.data.length-r.indexOf(b.data,a):r.indexOf(b.data,a),d.scrollTo({x:0,y:d.rowHeight*
b-d.rowHeight}),c.element?c.element.scrollIntoView():setTimeout(function(){c.element&&c.element.scrollIntoView()},200)},_generateColumns:function(a){a=e.clone(a)||[];var b=[];r.forEach(a,function(a){a.expression?b.push(this._generateExpressionColumn(a)):"esriAttachments"===a.type?b.push(this._generateAttachmentsColumn(a)):"esriRelatedRecords"===a.type?b.push(this._generateRelatedRecordsColumn(a)):"esriFieldTypeDate"===a.type?this.dateOptions.timeEnabled?b.push(this._generateDateTimeColumn(a)):b.push(this._generateDateColumn(a)):
a.typeId?b.push(this._generateTypeColumn(a)):a.domain?b.push(this._generateDomainColumn(a)):a.subtypeDomain&&!a.typeId?b.push(this._generateSubtypeDomainColumn(a)):-1<r.indexOf(this._numericFieldTypes,a.type)?b.push(this._generateNumberColumn(a)):-1===r.indexOf(this._unsupportedFieldTypes,a.type)&&b.push(this._generateStringColumn(a))},this);return b},_orderFieldsForDisplay:function(a){var b=this.outFields,d=this.idProperty,c=[];b&&"*"===b[0]?c=e.clone(a):(g.isValueEmpty(d)||-1!==r.indexOf(b,d)||
c.push(g.findFirst(a,"name",d)),r.forEach(b,function(b){var f=g.findFirst(a,"name",b);f&&b!==d&&-1===r.indexOf(c,f)&&c.push(f)},this),r.forEach(a,function(a){-1===r.indexOf(c,a)&&c.push(e.clone(a))}));return c},_generateDateColumn:function(a){var b=a.dateOptions||this.dateOptions;return{label:a.alias,field:a.name,type:a.type,hidden:a.hidden,className:this.css.dateValue,get:e.hitch(this,function(d){return g.isValueEmpty(d[a.name])?null:g.formatDateForLocale({dateOptions:b,timestamp:new Date(d[a.name]),
fieldInfo:a})}),renderCell:e.hitch(this,function(b,c,f){c=t.create("div",{innerHTML:g.isValueEmpty(c)?"":c},f);this._setUpDateCell({row:b,cellNode:f,fieldInfo:a,container:c})}),renderHeaderCell:e.hitch(this,function(){return this._getColumnHeaderCellContent({fieldInfo:a})})}},_generateDateTimeColumn:function(a){return{label:a.alias,field:a.name,type:a.type,hidden:a.hidden,className:this.css.dateValue,get:e.hitch(this,function(b){return g.isValueEmpty(b[a.name])?null:g.formatDateForLocale({dateOptions:a.dateOptions||
this.dateOptions,timestamp:new Date(b[a.name]),fieldInfo:a})}),renderCell:e.hitch(this,function(b,d,c){d=t.create("div",{innerHTML:g.isValueEmpty(d)?"":d},c);this._setUpDateTimeCell({row:b,cellNode:c,fieldInfo:a,container:d})}),renderHeaderCell:e.hitch(this,function(){return this._getColumnHeaderCellContent({fieldInfo:a})})}},_generateDomainColumn:function(a){return{label:a.alias,field:a.name,type:a.type,hidden:a.hidden,get:function(b){return g.getDomainValueFromRow({fieldInfo:a,row:b})},renderHeaderCell:e.hitch(this,
function(){return this._getColumnHeaderCellContent({fieldInfo:a})}),renderCell:e.hitch(this,function(b,d,c){var f=t.create("div");if(a.domain.codedValues)d=this._formatStringCellContent({fieldInfo:a,value:d}),this._setUpCodedValueDomainCell({row:b,cellNode:c,fieldInfo:a,container:f});else if("range"===a.domain.type)d=this._formatNumberCellContent({fieldInfo:a,value:d}),this._setUpRangeDomainCell({row:b,cellNode:c,fieldInfo:a,container:f});else{this.emit("error",{message:this._i18nStrings.errorDomainType});
return}f.innerHTML=d;t.place(f,c)})}},_generateTypeColumn:function(a){return{label:a.alias,field:a.name,type:a.type,hidden:a.hidden,get:e.hitch(this,function(b){var d=g.getTypeValueFromRow({layerInfo:this.layerInfo,fieldInfo:a,row:b});return g.isValueEmpty(d)?b[a.name]:d}),renderCell:e.hitch(this,function(b,d,c){d=this._formatStringCellContent({fieldInfo:a,value:d});d=t.create("div",{innerHTML:d},c);this._setUpTypeCell({row:b,cellNode:c,fieldInfo:a,container:d})}),renderHeaderCell:e.hitch(this,function(){return this._getColumnHeaderCellContent({fieldInfo:a})})}},
_generateSubtypeDomainColumn:function(a){return{label:a.alias,field:a.name,type:a.type,hidden:a.hidden,editOn:this.editOn,editor:"text",get:e.hitch(this,function(b){return g.getSubtypeDomainValue({layerInfo:this.layerInfo,fieldInfo:a,row:b})}),renderHeaderCell:e.hitch(this,function(){return this._getColumnHeaderCellContent({fieldInfo:a})}),renderCell:e.hitch(this,function(b,d,c){d=this._formatStringCellContent({fieldInfo:a,value:d});d=t.create("div",{innerHTML:d},c);this._setUpSubtypeDomainCell({row:b,
cellNode:c,fieldInfo:a,container:d})})}},_generateNumberColumn:function(a){return{label:a.alias,field:a.name,type:a.type,hidden:a.hidden,renderHeaderCell:e.hitch(this,function(){return this._getColumnHeaderCellContent({fieldInfo:a})}),renderCell:e.hitch(this,function(b,d,c){d=this._formatNumberCellContent({fieldInfo:a,value:d});d=t.create("div",{innerHTML:d},c);this._setUpNumberCell({row:b,cellNode:c,fieldInfo:a,container:d})})}},_generateStringColumn:function(a){return{label:a.alias,field:a.name,
type:a.type,hidden:a.hidden,renderHeaderCell:e.hitch(this,function(){return this._getColumnHeaderCellContent({fieldInfo:a})}),renderCell:e.hitch(this,function(b,d,c){d=this._formatStringCellContent({fieldInfo:a,value:d});d=t.create("div",{innerHTML:d},c);this._setUpStringCell({row:b,cellNode:c,fieldInfo:a,container:d})})}},_generateAttachmentsColumn:function(a){var b=this.layerInfo||{};return{label:a.alias,field:a.name,type:"esriAttachments",sortable:!1,get:e.hitch(this,function(a){a=this.attachmentInfos[a[this.idProperty]];
var c;c=b.queryAttachmentsSupported?0:null;return a&&a.attachments?a.attachments.length:c}),renderCell:e.hitch(this,function(b,c,f){this._generateAttachmentsCell({row:b,fieldInfo:a,cellValue:c,cellNode:f})}),renderHeaderCell:e.hitch(this,function(){return this._getColumnHeaderCellContent({fieldInfo:a,cssClass:this.css.attachmentsTitle})})}},_generateRelatedRecordsColumn:function(a){return{label:a.alias,field:a.name,type:"esriRelatedRecords",hidden:a.hidden,sortable:!1,get:e.hitch(this,function(b){return this._getRelatedRecordsCount({featureId:b[this.idProperty],
relationshipId:a.relationship.id})}),renderCell:e.hitch(this,function(b,d,c){this._generateRelatedRecordsCell({row:b,fieldInfo:a,cellValue:d,cellNode:c})}),renderHeaderCell:e.hitch(this,function(){return this._getColumnHeaderCellContent({fieldInfo:a,cssClass:this.css.relatedRecordsTitle})})}},_generateExpressionColumn:function(a){return{label:a.alias,field:a.name,type:"esriExpressions",sortable:!1,get:e.hitch(this,function(b){return g.getExpressionValue(this.store.data[b[this.idProperty]],this.expressionCache[a.name])}),
renderCell:e.hitch(this,function(b,d,c){"number"==a.type?b=this._formatNumberCellContent({fieldInfo:a,value:d}):(b=this._formatStringCellContent({fieldInfo:a,value:d}),b=String(b),b=I.encode(b));t.create("div",{innerHTML:b},c)}),renderHeaderCell:e.hitch(this,function(){return this._getColumnHeaderCellContent({fieldInfo:a,cssClass:this.css.expressionsTitle})})}},_closeCellEditors:function(){r.forEach(this._activeEditors,function(a){a.widget.onBlur()});this.set("_activeEditors",[])},_getColumnHeaderCellContent:function(a){var b=
a.fieldInfo,d=a.cssClass||null;a=this.css;var c,f;f=t.create("div",{className:a.columnHeader});c=d?a.columnHeaderTitle+" "+d:a.columnHeaderTitle;!b.editable&&this.editable&&this.layerInfo.editable&&t.create("span",{className:a.lockedIconContainer+" "+a.lockedIcon},f);d=I.encode(b.alias||b.name);t.create("div",{innerHTML:d,className:c},f);t.create("div",{className:a.columnHeaderClear},f);this.showColumnHeaderTooltips&&this.own(new T({connectId:[f],label:d}));d="esriExpressions"===b.type||"esriRelatedRecords"===
b.type||"esriAttachments"===b.type;this.showDataTypes&&!d&&(t.create("div",{innerHTML:b.type.replace("esriFieldType",""),className:a.columnHeaderType},f),t.create("div",{className:a.columnHeaderClear},f));return f},_setUpNumberCell:function(a){var b=a.row,d=a.cellNode,c=a.fieldInfo,f=a.container,k=this.idProperty,m=g.isIntegerFieldType(c.type)?0:"0,20",h,n;q(d,this.editOn,e.hitch(this,function(){var a=g.isFeatureEditable({layer:this.layer,layerInfo:this.layerInfo,attributes:b});this.editable&&c.editable&&
!1!==a&&(a=g.compareIntArrays(this.selectedRowIds,this._previousSelectedRowIds),this.editOn!=x||a)&&(h&&h.destroy(),this._closeCellEditors(),f.innerHTML="",h=new D({value:b[c.name],required:!c.nullable,constraints:{places:m}}),h.placeAt(f),h.focus(),h.textbox.select(),this.emit("editor-show",{cell:d,editor:h,grid:this}),h.on("blur",e.hitch(this,function(){f.innerHTML=this._formatNumberCellContent({fieldInfo:c,value:b[c.name]});d.focus();this.emit("editor-hide",{cell:d,editor:h,grid:this})})),h.on("keydown",
function(a){a.keyCode===z.ENTER&&h.isValid()&&h.focusNode.blur()}),h.on("change",e.hitch(this,function(a){n={fieldName:c.name,oldValue:b[c.name],rowId:b[k],row:b};if(""===a||isNaN(a))a=null;h.isValid()?(b[c.name]=a,f.innerHTML=this._formatNumberCellContent({fieldInfo:c,value:a}),this._applyEdits({row:b,rollbackInfo:n})):f.innerHTML=this._formatNumberCellContent({fieldInfo:c,value:b[c.name]});h.destroy()})),this._activeEditors.push({id:b[k],widget:h}))}))},_setUpDateCell:function(a){var b=a.row,d=
a.cellNode,c=a.fieldInfo,f=a.container,k=this.idProperty,m,h;q(d,this.editOn,e.hitch(this,function(){var a=g.isFeatureEditable({layer:this.layer,layerInfo:this.layerInfo,attributes:b});if(this.editable&&c.editable&&!1!==a&&(a=g.compareIntArrays(this.selectedRowIds,this._previousSelectedRowIds),this.editOn!=x||a)){this._closeCellEditors();f.innerHTML="";h=c.dateOptions&&c.dateOptions.datePattern?c.dateOptions.datePattern:this.dateOptions.datePattern;m=g.isValueEmpty(b[c.name])?null:new Date(b[c.name]);
var l=new K({value:m,constraints:{datePattern:h}});l.placeAt(f);l.focus();l.textbox.select();this.emit("editor-show",{cell:d,editor:l,grid:this});l.on("blur",e.hitch(this,function(){f.innerHTML=g.isValueEmpty(b[c.name])?null:g.formatDateForLocale({dateOptions:this.dateOptions,timestamp:b[c.name],fieldInfo:c});d.focus();this.emit("editor-hide",{cell:d,editor:l,grid:this})}));l.on("keydown",function(a){a.keyCode===z.ENTER&&l.isValid()&&l.focusNode.blur()});l.on("change",e.hitch(this,function(a){if(l.isValid()){var d=
{fieldName:c.name,oldValue:b[c.name],rowId:b[k],row:b};b[c.name]=g.isValueEmpty(a)?null:a.getTime();f.innerHTML=g.isValueEmpty(b[c.name])?null:g.formatDateForLocale({dateOptions:this.dateOptions,timestamp:b[c.name],fieldInfo:c});this._applyEdits({row:b,rollbackInfo:d})}else f.innerHTML=g.isValueEmpty(b[c.name])?null:g.formatDateForLocale({dateOptions:this.dateOptions,timestamp:b[c.name],fieldInfo:c})}))}}))},_setUpDateTimeCell:function(a){var b=a.row,d=a.cellNode,c=a.fieldInfo,f=a.container,k=this.idProperty,
m,h,n;q(d,this.editOn,e.hitch(this,function(){var a=g.isFeatureEditable({layer:this.layer,layerInfo:this.layerInfo,attributes:b});if(this.editable&&c.editable&&!1!==a&&(a=g.compareIntArrays(this.selectedRowIds,this._previousSelectedRowIds),this.editOn!=x||a)){this._closeCellEditors();f.innerHTML="";h=c.dateOptions&&c.dateOptions.datePattern?c.dateOptions.datePattern:this.dateOptions.datePattern;n=c.dateOptions&&c.dateOptions.timePattern?c.dateOptions.timePattern:this.dateOptions.timePattern;m=g.isValueEmpty(b[c.name])?
null:new Date(b[c.name]);var u=new K({value:m,constraints:{datePattern:h}}),p=new U({value:m,constraints:{timePattern:n}});u.placeAt(f);p.placeAt(f);u.focus();u.textbox.select();this.emit("editor-show",{cell:d,editor:[u,p],grid:this});u.on("change",e.hitch(this,function(a){u.isValid()&&(null===a||""===a?p.setValue(null):(a=p.getValue(),null===a&&(a=new Date(0,0),p.setValue(a))))}));p.on("change",e.hitch(this,function(a){p.isValid()&&(null===a||""===a?u.setValue(null):(a=u.getValue(),null===a&&(a=
new Date(0,0),u.setValue(a))))}));var t=S.watch("activeStack",e.hitch(this,function(a,e,h){a=-1!==r.indexOf(e,u.id)||-1!==r.indexOf(e,p.id);h=-1===r.indexOf(h,u.id)&&-1===r.indexOf(h,p.id);if(a&&h){t.remove();this.emit("editor-hide",{cell:d,editor:[u,p],grid:this});a=u.getValue();e=p.getValue();h=b[c.name];if(p.isValid()&&u.isValid()){a&&e?(a=g.getCombinedDateTime(a,e).getTime(),f.innerHTML=g.formatDateForLocale({dateOptions:this.dateOptions,timestamp:new Date(a),fieldInfo:c})):(a=null,f.innerHTML=
"");if(b[c.name]===a)return;b[c.name]=a;this._applyEdits({row:b,rollbackInfo:{fieldName:c.name,oldValue:h,rowId:b[k],row:b}})}else f.innerHTML=null===h?"":g.formatDateForLocale({dateOptions:this.dateOptions,timestamp:b[c.name],fieldInfo:c});u.destroy();p.destroy()}}))}}))},_setUpCodedValueDomainCell:function(a){var b=a.row,d=a.cellNode,c=a.fieldInfo,f=a.container,k=this.idProperty,m=[],h;r.forEach(c.domain.codedValues,function(a){b[c.name]===a.code?m.push({label:a.name,value:a.code,selected:!0}):
m.push({label:a.name,value:a.code})});g.isValueEmpty(b[c.name])&&c.nullable?m.push({label:this._i18nStrings.empty,value:this._nullConstant,selected:!0}):g.isValueEmpty(b[c.name])&&!c.nullable?m.push({label:this._i18nStrings.empty,value:this._nullConstant,selected:!0,disabled:!0}):c.nullable&&m.push({label:this._i18nStrings.empty,value:this._nullConstant});q(d,this.editOn,e.hitch(this,function(){var a=g.isFeatureEditable({layer:this.layer,layerInfo:this.layerInfo,attributes:b});if(this.editable&&c.editable&&
!1!==a&&(a=g.compareIntArrays(this.selectedRowIds,this._previousSelectedRowIds),this.editOn!=x||a)){this._closeCellEditors();f.innerHTML="";var l=new E({options:m,"class":this.css.select,style:{width:"100%"}});l.placeAt(f);l.focus();this.emit("editor-show",{cell:d,editor:l,grid:this});l.on("blur",e.hitch(this,function(){var a=g.getDomainValueFromRow({fieldInfo:c,row:b});f.innerHTML=this._formatStringCellContent({fieldInfo:c,value:a});this.emit("editor-hide",{cell:d,editor:l,grid:this});this._activeEditors.pop()}));
l.on("keydown",function(a){a.keyCode===z.ENTER&&l.focusNode.blur()});l.on("change",e.hitch(this,function(a){h={fieldName:c.name,oldValue:b[c.name],rowId:b[k],row:b};a===this._nullConstant&&(a=null);b[c.name]=a;l.onBlur();this._applyEdits({row:b,rollbackInfo:h});l.destroy();l=null}));this._activeEditors.push({id:b[k],widget:l})}}))},_setUpRangeDomainCell:function(a){var b=a.row,d=a.cellNode,c=a.fieldInfo,f=a.container,k=c.domain.minValue,m=c.domain.maxValue,h=this.idProperty,n=g.isIntegerFieldType(c.type)?
0:"0,20",l;q(d,this.editOn,e.hitch(this,function(){var a=g.isFeatureEditable({layer:this.layer,layerInfo:this.layerInfo,attributes:b});if(this.editable&&c.editable&&!1!==a&&(a=g.compareIntArrays(this.selectedRowIds,this._previousSelectedRowIds),this.editOn!=x||a)){this._closeCellEditors();f.innerHTML="";var p=new D({value:b[c.name],required:!c.nullable,constraints:{min:k,max:m,places:n}});p.placeAt(f);p.focus();p.textbox.select();this.emit("editor-show",{cell:d,editor:p,grid:this});p.on("blur",e.hitch(this,
function(){f.innerHTML=this._formatNumberCellContent({fieldInfo:c,value:b[c.name]});this.emit("editor-hide",{cell:d,editor:p,grid:this});this._activeEditors.pop()}));p.on("keydown",function(a){a.keyCode===z.ENTER&&p.isValid()&&p.focusNode.blur()});p.on("change",e.hitch(this,function(a){l={fieldName:c.name,oldValue:b[c.name],rowId:b[h],row:b};p.isValid()&&(b[c.name]=a,this._applyEdits({row:b,rollbackInfo:l}));p.onBlur();p.destroy();p=null}));this._activeEditors.push({id:b[h],widget:p})}}))},_setUpTypeCell:function(a){var b=
a.row,d=a.cellNode,c=a.fieldInfo,f=a.container,k=this.idProperty,m=this.layerInfo,h=m.types,n;q(d,this.editOn,e.hitch(this,function(){var a=g.isFeatureEditable({layer:this.layer,layerInfo:this.layerInfo,attributes:b});if(this.editable&&c.editable&&!1!==a){var a=g.compareIntArrays(this.selectedRowIds,this._previousSelectedRowIds),u=b[c.name],p=[],t=g.isValueEmpty(g.getTypeValueFromRow({layerInfo:this.layerInfo,fieldInfo:c,row:b}));if(this.editOn!=x||a){this._closeCellEditors();r.forEach(h,function(a){b[c.name]===
a.id?p.push({label:a.name,value:a.id,selected:!0}):p.push({label:a.name,value:a.id})});g.isValueEmpty(b[c.name])?p.push({label:this._i18nStrings.empty,value:this._nullConstant,selected:!0,disabled:!0}):t&&p.push({label:u,value:u,selected:!0,disabled:!0});f.innerHTML="";var q=new E({options:p,"class":this.css.select,style:{width:"100%"}});q.placeAt(f);q.focus();this.emit("editor-show",{cell:d,editor:q,grid:this});q.on("blur",e.hitch(this,function(){var a=g.getTypeValueFromRow({layerInfo:m,fieldInfo:c,
row:b});f.innerHTML=this._formatStringCellContent({fieldInfo:c,value:a||u});this.emit("editor-hide",{cell:d,editor:q,grid:this.grid});this._activeEditors.pop()}));q.on("keydown",function(a){a.keyCode===z.ENTER&&q.focusNode.blur()});q.on("change",e.hitch(this,function(a){n={fieldName:c.name,oldValue:b[c.name],rowId:b[k],row:b};a===this._nullConstant&&(a=null);b[c.name]=a;q.onBlur();this._applyEdits({row:b,rollbackInfo:n});q.destroy();q=null}));this._activeEditors.push({id:b[k],widget:q})}}}))},_setUpSubtypeDomainCell:function(a){var b=
a.row,d=a.cellNode,c=a.fieldInfo,f=a.container,k=this.idProperty,m=this.layerInfo,h=m.types,n,l,t,p,y;q(d,this.editOn,e.hitch(this,function(){var a=g.isFeatureEditable({layer:this.layer,layerInfo:this.layerInfo,attributes:b});if(this.editable&&c.editable&&!1!==a&&(a=g.compareIntArrays(this.selectedRowIds,this._previousSelectedRowIds),this.editOn!=x||a))if(this._closeCellEditors(),n=[],f.innerHTML="",l=g.findFirst(h,"id",b[m.typeIdField]),t=l.domains[c.name]){var q=l.domains[c.name].codedValues,u=
g.findFirst(q,"code",b[c.name]);r.forEach(q,function(a){b[c.name]===a.code?n.push({label:a.name,value:a.code,selected:!0}):n.push({label:a.name,value:a.code});a.code===u&&(y=!0)});g.isValueEmpty(b[c.name])&&c.nullable?n.push({label:this._i18nStrings.empty,value:this._nullConstant,selected:!0}):g.isValueEmpty(b[c.name])&&!c.nullable?n.push({label:this._i18nStrings.empty,value:this._nullConstant,selected:!0,disabled:!0}):c.nullable&&n.push({label:this._i18nStrings.empty,value:this._nullConstant});y||
u||null===b[c.name]||n.push({label:b[c.name].toString(),value:"N/A",selected:!0,disabled:!0});var w=new E({options:n,"class":this.css.select,style:{width:"100%"}});w.placeAt(f);w.focus();this.emit("editor-show",{cell:d,editor:w,grid:this});w.on("blur",e.hitch(this,function(){var a=g.findFirst(q,"code",b[c.name]);f.innerHTML=a?this._formatStringCellContent({fieldInfo:c,value:a.name}):this._formatStringCellContent({fieldInfo:c,value:b[c.name]});this.emit("editor-hide",{cell:d,editor:w,grid:this});this._activeEditors.pop()}));
w.on("keydown",function(a){a.keyCode===z.ENTER&&w.focusNode.blur()});w.on("change",e.hitch(this,function(a){p={fieldName:c.name,oldValue:b[c.name],rowId:b[k],row:b};a===this._nullConstant&&(a=null);b[c.name]=a;w.onBlur();this._applyEdits({row:b,rollbackInfo:p});w.destroy();w=null}));this._activeEditors.push({id:b[k],widget:w})}else{var v=new D({value:b[c.name],required:!c.nullable});v.placeAt(f);v.focus();v.textbox.select();this.emit("editor-show",{cell:d,editor:v,grid:this});v.on("blur",e.hitch(this,
function(){f.innerHTML=b[c.name];this._activeEditors.pop()}));v.on("keydown",function(a){a.keyCode===z.ENTER&&v.isValid()&&v.focusNode.blur()});v.on("change",e.hitch(this,function(a){p={fieldName:c.name,oldValue:b[c.name],rowId:b[k],row:b};v.isValid()&&(b[c.name]=a,this._applyEdits({row:b,rollbackInfo:p}));v.onBlur();v.destroy();v=null}));this._activeEditors.push({id:b[k],widget:v})}}))},_setUpStringCell:function(a){var b=a.row,d=a.cellNode,c=a.fieldInfo,f=a.container,k=this.idProperty;q(d,this.editOn,
e.hitch(this,function(){var a=g.isFeatureEditable({layer:this.layer,layerInfo:this.layerInfo,attributes:b});if(this.editable&&c.editable&&!1!==a&&(a=g.compareIntArrays(this.selectedRowIds,this._previousSelectedRowIds),this.editOn!=x||a)){this._closeCellEditors();f.innerHTML="";var h=new V({value:b[c.name],required:!c.nullable,maxLength:c.length?c.length:null});h.placeAt(f);h.focus();h.textbox.select();this.emit("editor-show",{cell:d,editor:h,grid:this});h.on("blur",e.hitch(this,function(){f.innerHTML=
this._formatStringCellContent({fieldInfo:c,value:b[c.name]});d.focus();this.emit("editor-hide",{cell:d,editor:h,grid:this});this._activeEditors.pop()}));h.on("keydown",function(a){a.keyCode===z.ENTER&&h.isValid()&&h.focusNode.blur()});h.on("change",e.hitch(this,function(a){var d={fieldName:c.name,oldValue:b[c.name],rowId:b[k],row:b};""===a&&(a=null);h.isValid()&&(b[c.name]=a,this._applyEdits({row:b,rollbackInfo:d}));f.innerHTML=this._formatStringCellContent({fieldInfo:c,value:b[c.name]});h.destroy();
h=null}));this._activeEditors.push({id:b[k],widget:h})}}))},_formatStringCellContent:function(a){var b=a.value;return(a=(a=a.fieldInfo)?a.format:null)&&(a.embeddedHTML||!1===a.link)?g.isValueEmpty(b)?"":b:a&&a.template?g.isValueEmpty(b)?"":B.substitute(a.template,{value:b}):g.generateLinkFromString(b)},_formatNumberCellContent:function(a){var b=a.value,d=(a=a.fieldInfo.format)?a.template:null;return null!==b?d?B.substitute(d,{value:g.formatNumberForLocale(b,a)}):g.formatNumberForLocale(b,a):null===
b?"":g.formatNumberForLocale(b)},_generateAttachmentsCell:function(a){if(this.layerInfo){var b=a.row,d=a.cellValue,c=a.cellNode,f=a.fieldInfo;a=this.layerInfo;var k=this.css,m=this._i18nStrings,h,n;n=g.isValueEmpty(d)?"":B.substitute(m.parenValue,{value:d});h=t.create("div",{innerHTML:n,className:k.attachmentsCell},c);t.create("span",{innerHTML:0<d||!a.queryAttachmentsSupported?" "+m.show:this.editable&&a.editable?" "+m.add:"",className:k.attachmentsLink},h);q(h,x,e.hitch(this,function(){this._showAttachmentsHandler({row:b,
fieldInfo:f,cellValue:d,cellNode:c,textContainer:h})}))}},_generateRelatedRecordsCell:function(a){var b=a.row,d=a.cellValue,c=a.cellNode,f=a.fieldInfo;a=this.css;var k=this._i18nStrings,m;m=g.isValueEmpty(d)?"":B.substitute(k.parenValue,{value:d})+" ";m=t.create("div",{innerHTML:m,className:a.relatedRecordsCell},c);t.create("span",{innerHTML:0<d?k.show:"",className:a.relatedRecordsLink},m);q(c,x,e.hitch(this,function(a){0<d&&(a=this.dGrid.cell(a).column,this._showRelatedRecordsHandler({row:b,fieldInfo:f,
column:a,count:d}))}))},updateHeaderText:function(a){var b=a?a.count:null,d=a?a.selectedCount:null,c=a?a.title:null;a=a?a.showFilterCount:!0;c=g.isValueEmpty(c)?this._tableTitle||this.layer.name||this._i18nStrings.untitled:c;b=g.isValueEmpty(b)?this.featureCount:b;d=g.isValueEmpty(d)?this.selectedFeatureCount:d;this.filterIds&&0<this.filterIds.length&&a&&(b=this.filterIds.length);this.showFeatureCount?this.setHeaderTitle(B.substitute(this._i18nStrings.gridHeader,{gridTitle:c,featureCount:b,featureSelectedCount:d})):
this.setHeaderTitle(c)},_generateOptionsMenu:function(){var a=this.css,b=this._i18nStrings,a=t.create("div",{className:a.menuItem+" "+a.button+" "+a.menuIcon,title:b.options,"aria-label":b.options,tabIndex:0},this._gridMenuNode);q(a,[x,"keydown"],e.hitch(this,function(a){"Tab"!==a.key&&this._showOptionsMenu(a)}));this.optionsMenuAnchor=a},_showOptionsMenu:function(a){var b=this.optionsMenuAnchor,d=this.css,c,f,g,m;this.optionsMenu&&(this.optionsMenu.destroy(),this.optionsMenu=null);f=b.getBoundingClientRect();
g=f.top+f.height;m=this.isLeftToRight()?f.left+f.width:f.right-f.width;c=new J({className:d.optionsMenu});f=this._generateOptionsMenuItems();r.forEach(f,function(a){a=new A({label:a.label,baseClass:d.menuItem,onClick:e.hitch(this,a.callback)});c.addChild(a)},this);c._openMyself({target:a.target,delegatedTarget:b,iframe:null,coords:{x:m,y:g}});this.optionsMenu=c},_generateOptionsMenuItems:function(){var a=[];this.showDefaultSortMenuItem&&a.push({label:this._i18nStrings.defaultSort,callback:this._sortFieldDefaultCallback});
this.showFilterMenuItems?a.push({label:this._i18nStrings.showSelected,callback:this._showSelectedRecordsCallback},{label:this._i18nStrings.clearSelection,callback:this._clearFilterCallback}):a.push({label:this._i18nStrings.clearSelection,callback:this.clearSelection});this.gridOptions.columnHider&&a.push({label:this._i18nStrings.toggleColumns,callback:this.showColumnToggleMenu});this.map&&this.syncSelection&&a.push({label:this._i18nStrings.centerOnSelection,callback:this.centerOnSelection});this.menuFunctions&&
0<this.menuFunctions.length&&r.forEach(this.menuFunctions,function(b){a.push({label:b.label,callback:b.callback})},this);return a},_sortFieldDefaultCallback:function(){var a=this.defaultSort.attribute,b=this.defaultSort.descending;this.set("sort",{field:a,descending:b});this.emit("sort",{field:a,descending:b,orderByFields:[g.getOrderByString(a,b)]})},_showSelectedRecordsCallback:function(){0!==this.selectedRowIds.length&&this.emit("show-selected-records",{ids:this.selectedRowIds})},_clearFilterCallback:function(){this.emit("clear-selection");
this.emit("clear-filter")},showColumnToggleMenu:function(){this.dGrid._toggleColumnHiderMenu()},_generateColumnMenu:function(a){var b=this.dGrid.cell(a),d=b?b.column:null;if(d){var c=this.columnMenu,f=this.css,k=this.columnMenuFunctions,d=d.id,m=this.dGrid.columns[d],h=g.findFirst(this.fieldInfos,"name",m.field),n;c&&this.set("columnMenu",null);!1!==m.sortable&&(n=new J({className:f.columnMenu}),this._generateSortMenuItems({menu:n,columnId:d}),this._generateStatisticsMenuItem({menu:n,fieldInfo:h,
columnId:d}),this._generateFieldDetailsMenuItem({menu:n,fieldInfo:h,column:m}),k&&0<k.length&&r.forEach(k,function(a){n.addChild(new A({label:a.label,iconClass:a.iconClass||"",baseClass:a.baseClass||"",onClick:e.hitch(this,a.callback,h)}))}),n.startup(),this._showColumnMenu({menu:n,cell:b,evt:a,fieldInfo:h,previousMenu:c}),this.set("columnMenu",n))}},_showColumnMenu:function(a){var b=a.menu,d=a.cell,c=a.evt,f=a.previousMenu,e;e=d.element.getBoundingClientRect();a=e.top+e.height;e=this.isLeftToRight()?
e.right-e.width:e.right;b._openMyself({target:c.target,delegatedTarget:d,iframe:null,coords:{x:e,y:a}});q(b,"close",function(){f&&(f.destroyRecursive(),f=null)})},_generateSortMenuItems:function(a){var b=a.menu;a=a.columnId;var d=this.css;b.addChild(new A({label:this._i18nStrings.sortAsc,iconClass:d.sortAscendingIcon,baseClass:d.menuItem,onClick:e.hitch(this,this._sortFieldAscendingHandler,a)}));b.addChild(new A({label:this._i18nStrings.sortDesc,iconClass:d.sortDescendingIcon,baseClass:d.menuItem,
onClick:e.hitch(this,this._sortFieldDescendingHandler,a)}))},_sortFieldAscendingHandler:function(a){var b=this.dGrid.columns[a];this.emit("sort",{column:b,id:a,field:b.field,descending:!1,orderByFields:[g.getOrderByString(b.field,!1)]})},_sortFieldDescendingHandler:function(a){var b=this.dGrid.columns[a];this.emit("sort",{column:b,id:a,field:b.field,descending:!0,orderByFields:[g.getOrderByString(b.field,!0)]})},_generateStatisticsMenuItem:function(a){var b=a.menu,d=a.fieldInfo,c=this.css,f=this.layer,
k=!!this.layerInfo.isFeatureCollection,f=f.advancedQueryCapabilities.supportsStatistics||f.supportsStatistics;!this.showStatistics||!f||!d||d.domain&&d.domain.codedValues||d.subtypeDomain||d.typeId||k||g.isNumericFieldType(d.type)&&b.addChild(new A({label:this._i18nStrings.statistics,iconClass:c.statisticsIcon,baseClass:c.menuItem,onClick:e.hitch(this,this._showStatisticsHandler,a)}))},_generateFieldDetailsMenuItem:function(a){if(this.showFieldDetails){var b=a.menu,d=a.fieldInfo,c=parseInt(a.column.id,
10);a=this.css;"esriFieldTypeOID"!==d.type&&"esriFieldTypeGlobalID"!==d.type&&-1===r.indexOf(this._unsupportedFieldTypes,d.type)&&b.addChild(new A({label:this._i18nStrings.showDetailedView,iconClass:a.propertiesIcon,baseClass:a.menuItem,onClick:e.hitch(this,function(){this.emit("show-detailed-field-view",{columnId:c,fieldInfo:d})})}))}},_fetchAttachments:function(a){return g.queryLayerForAttachments({layer:this.layer,ids:a||null})},_showAttachmentsHandler:function(a){var b=a.row,d=a.fieldInfo,c=a.cellValue,
f=a.cellNode,g=this.layerInfo,m=b[this.idProperty],h,n;if(0!==c||g.editCapabilities.canCreate)a=F.generateAttachmentsDialog({layer:this.layer,featureId:m,attachments:this.attachmentInfos[m]?this.attachmentInfos[m].attachments:[],editable:this.editable&&g.editable,css:this.css}),n=a.featureAttachments,h=n.attachments,this.own(n.on("add-complete",e.hitch(this,function(a){this.attachmentInfos[m]||(this.attachmentInfos[m]={attachments:[]});this.attachmentInfos[m].attachments=a.attachments;g.queryAttachmentsSupported&&
(c+=1);f.innerHTML="";this._generateAttachmentsCell({row:b,fieldInfo:d,cellValue:c,cellNode:f})})),n.on("delete-complete",e.hitch(this,function(a){this.attachmentInfos[m]||(this.attachmentInfos[m]={attachments:[]});this.attachmentInfos[m].attachments=a.attachments;g.queryAttachmentsSupported&&--c;f.innerHTML="";this._generateAttachmentsCell({row:b,fieldInfo:d,cellValue:c,cellNode:f})}))),this.emit("show-attachments",{featureId:m,attachments:h,dialog:a.dialog})},_updateAttachmentInfos:function(a){return e.mixin(this.attachmentInfos,
a)},_fetchRelatedRecords:function(a){return g.queryLayerForRelatedRecords({layer:this.layer,ids:a.ids||null,relationship:a.relationship,outFields:a.outFields||["*"]})},_showRelatedRecordsHandler:function(a){var b=a.row,d=this.idProperty,c=b[d],e=a.fieldInfo.relationship;a=a.count;var k=this.columns,m=this.layer,h=m.getField(e.keyField),n=(h=h?h.name:null)?b[h]:null,l,q;l=r.filter(k,function(a){return!a.hidden});d=[g.findFirst(l,"field",m.displayField),g.findFirst(l,"field",h),g.findFirst(l,"type",
"esriFieldTypeString"),g.findFirstNumberColumn(k,d),g.findFirst(l,"type","esriFieldTypeDate")];r.some(d,function(a){if(this._validateRelatedColumnDisplay(a))return q=r.indexOf(k,a),!0},this);g.isValueEmpty(q)&&(q=0);this.emit("show-related-records",{row:b,featureId:c,keyField:h,keyFieldValue:n,columnId:q,relationship:e,count:a})},_setUpRelatedRecordInfos:function(a){var b=a.records,d=this.relatedRecordInfos;r.forEach(a.relationships,function(a,e){d[a.id]=b[e]});return d},_updateRelatedRecordInfos:function(a){this.relatedRecordInfos=
g.mergeDictionaries(this.relatedRecordInfos,a)},_updateRelatedRecordCounts:function(a){var b=this.relatedRecordCounts,d={};r.forEach(this.layer.relationships,function(b){var c=a[b.id].relatedRecordGroups;d[b.id]={};r.forEach(c,function(a){d[b.id][a.objectId]={count:a.count}})});this.relatedRecordCounts=g.mergeDictionaries(b,d)},_getRelatedRecordsById:function(a){var b=a.featureId;a=a.relationshipId;return this.relatedRecordInfos[a]?this.relatedRecordInfos[a][b]:[]},_getRelatedRecordsCount:function(a){var b=
a.featureId;a=a.relationshipId;return this.layerInfo.supportsAdvancedQueryRelated?(b=this.relatedRecordCounts[a]?this.relatedRecordCounts[a][b]:{})?b.count:0:(b=this._getRelatedRecordsById({featureId:b,relationshipId:a}))&&b.features?b.features.length:0},_generateRelatedRecordFieldInfos:function(a){var b=[],d=this.visibleLayerIds,c=!1,e,k;r.some(a.relationships,function(a,f){f===this._relationshipColumnLimit&&(c=!0);k=g.isCyclicalRelationship(a);(e=d?d[d.length-1]===a.relatedTableId:!1)&&k&&!this.showCyclicalRelationships||
b.push({alias:a.name,name:a.name,type:"esriRelatedRecords",hidden:c,relatedIndex:f,relationship:a})},this);return b},_validateRelatedColumnDisplay:function(a){return!(!a||a.hidden||-1===r.indexOf(this.columns,a)||"esriFieldTypeOID"===a.type||"esriFieldTypeGlobalID"===a.type)},_showStatisticsHandler:function(a){var b=a.columnId,d=a.fieldInfo,c;a=this.where||this.layer.getDefinitionExpression?this.layer.getDefinitionExpression():"1\x3d1";g.getFieldStatistics({grid:this.dGrid,layer:this.layer,fieldInfo:d,
idProperty:this.idProperty,filterIds:this.filterIds,where:a,columnId:b}).then(e.hitch(this,function(a){c=F.generateStatisticsDialog({data:a,fieldInfo:d,css:this.css});this.emit("show-statistics",c)}))},_addGridListeners:function(){this._setUpRowSelectListener();this._setUpRowDeselectListener();this._setUpDataChangeListener();this._setUpRefreshListener();this._setUpColumnClickListener();this._setUpColumnStateChangeListener();this._setUpColumnResizeListener();this._setUpErrorListener();this._setUpSortListener();
this._setUpFilterListener();this._setUpEditorShowListener();this._setUpEditorHideListener();this.own(this._setUpStoreLoadListener(),this._setUpLayerClickListener(),this._setUpLayerSelectionCompleteListener(),this._setUpLayerSelectionClearListener(),this._setUpLayerUpdateEndListener())},_setUpStoreLoadListener:function(){var a=this.watch("store",e.hitch(this,function(b,d,c){null===d&&c&&(this.set("loaded",!0),this.emit("load",{loaded:!0}),a.remove())}));return a},_setUpRowSelectListener:function(){return this.dGrid.on("dgrid-select",
e.hitch(this,function(a){this._updateSelection().then(e.hitch(this,function(){this.updateHeaderText();this.emit("row-select",a)}))}))},_setUpRowDeselectListener:function(){return this.dGrid.on("dgrid-deselect",e.hitch(this,function(a){this._previousSelectedRowIds=this.selectedRowIds;this._updateSelection().then(e.hitch(this,function(){this.updateHeaderText();this.emit("row-deselect",a)}))}))},_setUpDataChangeListener:function(){return this.dGrid.on("dgrid-datachange",e.hitch(this,function(a){var b=
a.cell.column.field,d=g.findFirst(this.fieldInfos,"name",b),c=a.cell.row.data,f=c[this.idProperty],k=a.value;a=a.oldValue;var m=g.isIntegerFieldType(d.type),d=g.isFloatFieldType(d.type),h={oldValue:a,fieldName:b,rowId:f,row:c};""===k&&(k=null);m&&null!==k&&(k=parseInt(k,10));d&&null!==k&&(k=parseFloat(k));k&&k.getTime&&k.getTime()?c[b]=k.getTime():c[b]=k;this.showLoadingIndicator();this._updateSelection().then(e.hitch(this,function(){this.updateHeaderText();this._applyEdits({row:c,rollbackInfo:h})}));
this.emit("data-change",{row:c,rollbackInfo:h})}))},_setUpRefreshListener:function(){return this.dGrid.on("dgrid-refresh-complete",e.hitch(this,function(a){this.dGrid.columns[0]&&this.emit("refresh",a)}))},_setUpColumnClickListener:function(){return this.dGrid.on(".dgrid-header .dgrid-cell:click",e.hitch(this,this._generateColumnMenu))},_setUpColumnStateChangeListener:function(){return this.dGrid.on("dgrid-columnstatechange",e.hitch(this,function(a){this.emit("column-state-change",a)}))},_setUpColumnResizeListener:function(){return this.dGrid.on("dgrid-columnresize",
e.hitch(this,function(a){this.emit("column-resize",a)}))},_setUpErrorListener:function(){return this.dGrid.on("dgrid-error",e.hitch(this,function(a){this.emit("error",a)}))},_setUpSortListener:function(){return this.dGrid.on("dgrid-sort",e.hitch(this,function(a){this.emit("sort",a)}))},_setUpFilterListener:function(){return this.dGrid.on("dgrid-filter",e.hitch(this,function(a){this.emit("filter",a)}))},_setUpEditorShowListener:function(){return this.dGrid.on("dgrid-editor-show",e.hitch(this,function(a){this.emit("editor-show",
a)}))},_setUpEditorHideListener:function(){return this.dGrid.on("dgrid-editor-hide",e.hitch(this,function(a){this.emit("editor-hide",a)}))},_setUpLayerClickListener:function(){return q(this.layer,"click",e.hitch(this,function(a){this.emit("layer-click",a)}))},_setUpLayerSelectionCompleteListener:function(){return q(this.layer,"selection-complete",e.hitch(this,function(a){this.emit("layer-selection-complete",a)}))},_setUpLayerSelectionClearListener:function(){return q(this.layer,"selection-clear",
e.hitch(this,function(a){this.emit("layer-selection-clear",a)}))},_setUpLayerUpdateEndListener:function(){return q(this.layer,"update-end",e.hitch(this,function(a){this.emit("layer-update-end",a)}))}});O("extend-esri")&&e.setObject("dijit.Grid",C,N);return C});