/*!@license
 * Infragistics.Web.ClientUI Hierarchical Grid 21.2.12
 *
 * Copyright (c) 2011-2022 Infragistics Inc.
 *
 * http://www.infragistics.com/
 *
 * Depends on:
 *	jquery-1.9.1.js
 *	jquery.ui.core.js
 *	jquery.ui.widget.js
 *	infragistics.ui.widget.js
 *	infragistics.dataSource.js
 *	infragistics.ui.shared.js
 *	infragistics.util.js
 *	infragistics.ui.grid.framework.js
 */
(function(factory){if(typeof define==="function"&&define.amd){define(["./infragistics.ui.grid.featurechooser","./infragistics.ui.grid.filtering","./infragistics.ui.grid.groupby","./infragistics.ui.grid.hiding","./infragistics.ui.grid.cellmerging","./infragistics.ui.grid.paging","./infragistics.ui.grid.resizing","./infragistics.ui.grid.rowselectors","./infragistics.ui.grid.selection","./infragistics.ui.grid.sorting","./infragistics.ui.grid.summaries","./infragistics.ui.grid.multicolumnheaders","./infragistics.ui.grid.columnmoving","./infragistics.ui.grid.tooltips","./infragistics.ui.grid.updating","./infragistics.ui.grid.responsive"],factory)}else{return factory(jQuery)}})(function($){"use strict";$.widget("ui.igHierarchicalGrid",$.ui.igWidget,{css:{expandColumn:"ui-iggrid-expandcolumn",expandColumnExpanded:"ui-iggrid-expandcolumn-expanded",expandButton:"ui-iggrid-expandbutton ui-icon-plus",expandButtonHover:"ui-iggrid-expandbuttonhover ui-icon-plus ui-state-hover",expandButtonExpandedHover:"ui-iggrid-expandbuttonexpandedhover ui-icon-plus ui-state-hover",expandButtonExpanded:"ui-iggrid-expandbutton ui-iggrid-expandbuttonexpanded ui-icon-minus",expandButtonClick:"ui-iggrid-expandbuttonclick ui-icon-plus",childGridArea:"ui-iggrid-childarea",childGridAreaCollapsed:"ui-iggrid-childarea-collapsed",expandHeaderCell:"ui-iggrid-expandheadercell ui-iggrid-header ui-widget-header",expandHeaderCellTriangle:"ui-icon ui-icon-triangle-1-se",root:"ui-iggrid-root",childGridSeparator:"ui-iggrid-childgridseparator"},options:{initialDataBindDepth:-1,initialExpandDepth:-1,odata:false,rest:false,maxDataBindDepth:-1,defaultChildrenDataProperty:"children",autoGenerateLayouts:false,expandCollapseAnimations:true,expandColWidth:30,pathSeparator:"/",animationDuration:500,expandTooltip:undefined,collapseTooltip:undefined,locale:{expandTooltip:undefined,collapseTooltip:undefined},columnLayouts:[{key:null,primaryKey:null,foreignKey:null}],width:null,height:null,autoAdjustHeight:true,avgRowHeight:25,avgColumnWidth:null,defaultColumnWidth:null,autoGenerateColumns:true,virtualization:false,virtualizationMode:"fixed",rowVirtualization:false,columnVirtualization:false,virtualizationMouseWheelStep:null,adjustVirtualHeights:false,templatingEngine:"infragistics",columns:[{headerText:null,key:null,formatter:null,format:null,dataType:"string",width:null,hidden:false,template:null,unbound:false,groupOptions:{expanded:true,allowGroupCollapsing:false,hidden:"never"},group:[],dateDisplayType:"local",rowspan:0,formula:null,unboundValues:null,headerCssClass:null,columnCssClass:null,mapper:null,rowIndex:null,columnIndex:null,navigationIndex:null,colSpan:1,rowSpan:1}],dataSource:null,dataSourceUrl:null,dataSourceType:null,responseDataKey:null,responseTotalRecCountKey:null,requestType:"GET",responseContentType:"application/json; charset=utf-8",showHeader:true,showFooter:true,fixedHeaders:true,fixedFooters:true,caption:null,features:[{name:null}],tabIndex:0,localSchemaTransform:true,primaryKey:null,serializeTransactionLog:true,autoCommit:false,aggregateTransactions:false,autoFormat:"date",renderCheckboxes:false,updateUrl:null,restSettings:{create:{url:null,template:null,batch:false},update:{url:null,template:null,batch:false},remove:{url:null,template:null,batch:false},encodeRemoveInRequestUri:true,contentSerializer:null,contentType:"application/json; charset=utf-8"},alternateRowStyles:true,autofitLastColumn:true,enableHoverStyles:true,enableUTCDates:false,mergeUnboundColumns:false,jsonpRequest:false,enableResizeContainerCheck:true,featureChooserIconDisplay:"desktopOnly",scrollSettings:{scrollTop:0,scrollLeft:0,wheelStep:50,smoothing:false,smoothingStep:1,smoothingDuration:1,inertiaStep:1,inertiaDuration:1}},events:{rowExpanding:"rowExpanding",rowExpanded:"rowExpanded",rowCollapsing:"rowCollapsing",rowCollapsed:"rowCollapsed",childrenPopulating:"childrenPopulating",childrenPopulated:"childrenPopulated",childGridRendered:"childGridRendered",childGridCreating:"igchildgridcreating",childGridCreated:"igchildgridcreated",cellClick:"cellClick",cellRightClick:"cellRightClick",dataBinding:"dataBinding",dataBound:"dataBound",rendering:"rendering",rendered:"rendered",dataRendering:"dataRendering",dataRendered:"dataRendered",headerRendering:"headerRendering",headerRendered:"headerRendered",captionRendering:"captionRendering",captionRendered:"captionRendered",footerRendering:"footerRendering",footerRendered:"footerRendered",headerCellRendered:"headerCellRendered",rowsRendering:"rowsRendering",rowsRendered:"rowsRendered",schemaGenerated:"schemaGenerated",columnsCollectionModified:"columnsCollectionModified",requestError:"requestError",created:"igcontrolcreated",destroyed:"igcontroldestroyed"},_changeLanguage:function(language){var rootWidget=this.rootWidget();if(rootWidget){rootWidget._setOption("language",language);this.allChildren().each(function(){$(this).igGrid("option","language",language)})}},changeLocale:function(){var self=this,rootWidget=this.rootWidget();if(rootWidget){rootWidget.container().find("[data-toggle-button]").each(function(){self._changeLocaleForElement($(this))})}},changeRegional:function(){var rootWidget=this.rootWidget(),regional=this.options.regional;if(rootWidget){rootWidget._setOption("regional",regional);this.allChildren().each(function(){$(this).igGrid("option","regional",regional)})}},_setOption:function(key,value){var rootWidget=this.rootWidget();switch(key){case"dataSource":this.options.dataSource=value;this.dataBind();break;case"initialDataBindDepth":case"initialExpandDepth":case"expandColWidth":throw new Error(this._getLocaleValue("optionChangeNotSupported").replace("{optionName}",key));case"odata":case"defaultChildrenDataProperty":case"autoGenerateLayouts":case"expandCollapseAnimations":case"animationDuration":this._superApply(arguments);break;case"regional":this._superApply(arguments);break;case"locale":rootWidget._setOption(key,value);this._superApply(arguments);break;case"language":if(this.options.language!==value){this._superApply(arguments);this._changeLanguage(value)}break;default:if(rootWidget){rootWidget._setOption(key,value)}break}},_create:function(){this._regevents(this.element,this);$.ui.igGrid.prototype.options.columns=[];$.ui.igGrid.prototype.options.features=[];this.options=$.extend(true,{},$.ui.igGrid.prototype.options,this.options);if(this.tmpDataSource!==null&&this.tmpDataSource!==undefined){this.options.dataSource=this.tmpDataSource;this._originalOptions.dataSource=this.tmpDataSource}if(this.options.virtualization===true||this.options.rowVirtualization===true){this.options.virtualizationMode="continuous"}this._eventQueue=[];this._animationQueue=[];this._firstBind=true;this.dataBind();this.rootWidget()._isMultiColumnGrid=this._checkIsMultiColumnHeader(this.options)},_createWidget:function(options){this.options.columns=[];this.options.features=[];this.options.columnLayouts=[];if(options.dataSource&&($.type(options.dataSource)==="array"||$.type(options.dataSource)==="object")){this.tmpDataSource=options.dataSource;options.dataSource=null;this._originalOptions=options}this._superApply(arguments)},dataBind:function(){var hds,hdsoptions,rootds,opts;if(this.options.autoGenerateLayouts){this._generateLayouts()}hdsoptions=this._hdsoptions();hds=new $.ig.HierarchicalDataSource(hdsoptions);this._hds=hds;rootds=this._hds.root();this._tmpds=this.options.dataSource;this.options.dataSource=null;opts=$.extend(true,{},this.options);this.options.dataSource=this._tmpds;this._tmpds=null;opts.dataSource=rootds;if($.type(hdsoptions.dataSource)==="string"){opts.dataSourceUrl=hdsoptions.dataSource}if(!this._columnsGeneratedHandler){this._columnsGeneratedHandler=$.proxy(this._columnsGenerated,this)}else{this.element.unbind("iggridcolumnsgenerated.hierarchicalgrid",this._columnsGeneratedHandler)}this.element.bind("iggridcolumnsgenerated.hierarchicalgrid",this._columnsGeneratedHandler);if(this.options.autoGenerateLayouts===true){if(!this._databoundHandler){this._databoundHandler=$.proxy(this._layouts,this)}else{this.element.unbind("iggridcolumnsgenerated.hierarchicalgrid",this._databoundHandler)}this.element.bind("iggriddatarendering.hierarchicalgrid",this._databoundHandler)}this.element.addClass(this.css.root);this.element.attr("data-level",0);opts._isHierarchicalGrid=true;if(this._root){this._root.igGrid("option","dataSource",opts.dataSource)}else{if(this.options.autoGenerateLayouts===true){opts._recurseSchema=true}this._root=this.element;this.element.igGrid(opts);if(this.options.dataSourceUrl!==null&&this._firstBind){this.options.dataSource=this.options.dataSourceUrl;this._firstBind=false}}if(this.rootWidget().container().data("igLoading")){this.indicator=this.rootWidget().container().data("igLoading").indicator()}else{this.indicator=this.rootWidget().container().igLoading().data("igLoading").indicator()}this._regToggleEvent(this.element,this)},_generateLayouts:function(){var rec,i,ds=this.options.dataSource;if($.type(ds)!=="array"&&$.type(ds)!=="object"||ds.length===0){return}if($.type(ds)==="object"&&this.options.responseDataKey){ds=ds[this.options.responseDataKey]||ds}for(i=0;i<ds.length;i++){rec=ds[i];this._generateLayout(rec,this.options)}},_generateLayout:function(record,options){var name,layout,tmpLayout,i,rec,hasRespKey=false;for(name in record){if(record.hasOwnProperty(name)&&($.type(record[name])==="array"||$.type(record[name])==="object"&&options.responseDataKey&&$.type(record[name][options.responseDataKey])==="array")){rec=record[name];if(options.responseDataKey&&$.type(rec)==="object"){if(rec[options.responseDataKey]&&$.type(rec[options.responseDataKey])==="array"){rec=rec[options.responseDataKey];hasRespKey=true}else{continue}}layout={key:name,childrenDataProperty:name,columnLayouts:[]};if(hasRespKey){layout.responseDataKey=options.responseDataKey}tmpLayout=this._layoutExistsRecursive(this.options,name);if(!tmpLayout){if(options.columnLayouts===undefined||options.columnLayouts===null){options.columnLayouts=[]}options.columnLayouts.push(layout)}else{layout=tmpLayout}if(rec.length>0){for(i=0;i<rec.length;i++){this._generateLayout(rec[i],layout)}}}}},_layoutExistsRecursive:function(options,key){var i,tmpLayout=null;tmpLayout=options.key===key?options:tmpLayout;if(!tmpLayout){for(i=0;options.columnLayouts&&i<options.columnLayouts.length;i++){tmpLayout=this._layoutExistsRecursive(options.columnLayouts[i],key);if(tmpLayout){break}}}return tmpLayout},root:function(){return this._root},rootWidget:function(){return this.root().data("igGrid")},allChildrenWidgets:function(){return this.root().find(".ui-iggrid-table").map(function(){return $(this).data("igGrid")})},allChildren:function(){return this.root().find("table[data-childgrid='true']")},toggle:function(element,callback){this._toggleInternal({target:$(element).find(".ui-iggrid-expandcolumn")},true,callback)},expand:function(id,callback){if(!this.populated(id)){this._toggleInternal({target:$(id).find(".ui-iggrid-expandcolumn")},true,callback)}else{this._expand(id,true,callback)}},_expand:function(id,suppressEvents,callback){var tr=$(id),c,noCancel=true,handler,rootgrid;if(this.expanded(tr)){return}if(!suppressEvents){noCancel=this._trigger(this.events.rowExpanding,null,{owner:this,parentrow:tr})}if(this.expanded(tr)){return}rootgrid=this._rootgrid||this.element.closest(".ui-iggrid-root").data("igHierarchicalGrid");if(noCancel){if(this.options.expandCollapseAnimations){if(rootgrid._animationQueue[tr.attr("data-id")+"_"+tr.index()]===true){return}rootgrid._animationQueue[tr.attr("data-id")+"_"+tr.index()]=true}c=tr.find(".ui-iggrid-expandcolumn");tr.next().css("display","").css("visibility","visible");if(this.options.expandCollapseAnimations){if(!suppressEvents){handler=this._expandend}else{handler=this._expandendnoevents}tr.next().find("> td > div").slideDown(this.options.animationDuration,function(ctx){handler.apply(this,[ctx,callback])})}else{tr.next().find("> td > div").show();c.addClass(this.css.expandColumnExpanded).find(".ui-iggrid-expandbutton").removeClass(this.css.expandButton).addClass(this.css.expandButtonExpanded).attr({title:this._getLocaleValue("collapseTooltip"),"data-localeid":"collapseTooltip","data-localeattr":"title"})}tr.attr("state","e");tr.attr("aria-expanded",true);tr.next().children().first().removeClass(this.css.childGridAreaCollapsed).addClass(this.css.childGridArea);if(!this.options.expandCollapseAnimations){this._rowExpanded({owner:this,parentrow:tr});if(!suppressEvents){this._trigger(this.events.rowExpanded,null,{owner:this,parentrow:tr})}else if(callback){$.ig.util.invokeCallback(callback,[this,tr])}}}},expanded:function(element){var $e=element.length!==undefined?element:$(element);if($e===null||$e===undefined){return false}if($e.attr("state")!=="e"||$e.attr("state")===undefined){return false}return true},_expandendnoevents:function(ctx,callback){var expcell,expcellspan,rootgrid,$this=ctx?$(ctx):$(this),prow=$this.closest("tr[data-container]").prev();rootgrid=this._rootgrid||$this.closest(".ui-iggrid-root").data("igHierarchicalGrid");expcell=$this.closest("[data-container=true]").prev().find(".ui-iggrid-expandcolumn");expcellspan=expcell.find(".ui-iggrid-expandbutton");expcell.addClass(rootgrid.css.expandColumnExpanded);expcellspan.removeClass(rootgrid.css.expandButton).addClass(rootgrid.css.expandButtonExpanded).attr({title:rootgrid._getLocaleValue("collapseTooltip"),"data-localeid":"collapseTooltip","data-localeattr":"title"});rootgrid._rowExpanded({owner:rootgrid,parentrow:prow});if(rootgrid._animationQueue[prow.attr("data-id")+"_"+prow.index()]===true){delete rootgrid._animationQueue[prow.attr("data-id")+"_"+prow.index()]}if(callback){$.ig.util.invokeCallback(callback,[rootgrid,prow])}},_expandend:function(){var $this=$(this),rootgrid,prow=$this.closest("tr[data-container]").prev(),parentGrid=prow.closest(".ui-iggrid-table").data("igGrid");rootgrid=this._rootgrid||$this.closest(".ui-iggrid-root").data("igHierarchicalGrid");rootgrid._expandendnoevents(this);parentGrid._adjustLastColumnWidth(false);rootgrid._trigger(rootgrid.events.rowExpanded,null,{owner:rootgrid,parentrow:prow})},_collapseendnoevents:function(ctx,callback){var expcell,expcellspan,rootgrid,$this=ctx?$(ctx):$(this),ctd=$this.closest(".ui-iggrid-childarea"),prow=$this.closest("tr[data-container]").prev();rootgrid=this._rootgrid||$this.closest(".ui-iggrid-root").data("igHierarchicalGrid");ctd.removeClass(rootgrid.css.childGridArea).addClass(rootgrid.css.childGridAreaCollapsed);ctd.closest("tr").css("display","none").css("visibility","hidden");expcell=$this.closest("[data-container=true]").prev().find(".ui-iggrid-expandcolumn");expcellspan=expcell.find(".ui-iggrid-expandbutton");expcell.removeClass(rootgrid.css.expandColumnExpanded);expcellspan.removeClass(rootgrid.css.expandButtonExpanded).addClass(rootgrid.css.expandButton).attr({title:rootgrid._getLocaleValue("expandTooltip"),"data-localeid":"expandTooltip","data-localeattr":"title"});if(rootgrid._animationQueue[prow.attr("data-id")+"_"+prow.index()]===true){delete rootgrid._animationQueue[prow.attr("data-id")+"_"+prow.index()]}if(callback){$.ig.util.invokeCallback(callback,[rootgrid,prow])}},_collapseend:function(){var $this=$(this),rootgrid,prow=$this.closest("tr[data-container]").prev(),parentGrid=prow.closest(".ui-iggrid-table").data("igGrid");rootgrid=this._rootgrid||$this.closest(".ui-iggrid-root").data("igHierarchicalGrid");rootgrid._collapseendnoevents(this);parentGrid._adjustLastColumnWidth(false);rootgrid._trigger(rootgrid.events.rowCollapsed,null,{owner:rootgrid,parentrow:prow})},collapse:function(id,callback){this._collapse(id,true,callback)},_collapse:function(id,suppressEvents,callback){var tr=$(id),c,noCancel=true,handler,rootgrid;if(this.collapsed(tr)){return}if(!suppressEvents){noCancel=this._trigger(this.events.rowCollapsing,null,{owner:this,parentrow:tr})}rootgrid=this._rootgrid||this.element.closest(".ui-iggrid-root").data("igHierarchicalGrid");if(noCancel){if(this.options.expandCollapseAnimations){if(rootgrid._animationQueue[tr.attr("data-id")+"_"+tr.index()]===true){return}rootgrid._animationQueue[tr.attr("data-id")+"_"+tr.index()]=true}c=tr.find(".ui-iggrid-expandcolumn");if(this.options.expandCollapseAnimations){if(!suppressEvents){handler=this._collapseend}else{handler=this._collapseendnoevents}this._rowCollapsed({owner:this,parentrow:tr});tr.next().find("> td > div").slideUp(this.options.animationDuration,function(ctx){handler.apply(this,[ctx,callback])})}else{this._rowCollapsed({owner:this,parentrow:tr});tr.next().find("> td > div").hide();tr.next().children().first().removeClass(this.css.childGridArea).addClass(this.css.childGridAreaCollapsed);tr.next().css("display","none").css("visibility","hidden");c.find(".ui-iggrid-expandbutton").removeClass(this.css.expandButtonExpanded).addClass(this.css.expandButton).attr({title:this._getLocaleValue("expandTooltip"),"data-localeid":"expandTooltip","data-localeattr":"title"});if(!suppressEvents){this._trigger(this.events.rowCollapsed,null,{owner:this,parentrow:tr})}else if(callback){$.ig.util.invokeCallback(callback,[this,tr])}}tr.attr("state","c");tr.attr("aria-expanded",false)}},collapsed:function(element){var $e=element.length!==undefined?element:$(element);if($e===null||$e===undefined){return true}if($e.attr("state")==="c"||$e.attr("state")===undefined){return true}return false},populated:function(element){var $e=element.length!==undefined?element:$(element);if($e===null||$e===undefined){return false}if($e.attr("c")==="true"){return true}return false},_mouseOver:function(event){$(event.target).addClass(this.css.expandButtonHover)},_mouseOut:function(event){$(event.target).removeClass(this.css.expandButtonHover).addClass(this.css.expandButton)},_toggleInternalWithDelay:function(event){var self=this;setTimeout(function(){self._toggleInternal(event)},0);event.stopImmediatePropagation()},_toggleInternal:function(event,suppressEvents,callback){var created=$(event.target).closest("tr").attr("c"),tr=$(event.target).closest("tr"),p=tr.find(".ui-iggrid-expandcolumn"),hgrid=this,isExpand,expandTout=this.options.virtualization===true?50:0;isExpand=$(event.target).hasClass("ui-iggrid-expandbutton")||$(event.target).children(".ui-iggrid-expandbutton").length>0;if(!created&&this.options.initialDataBindDepth===-1&&isExpand){this.indicator.refreshPos();if(!$.ig.util.isWebKit){p.find(".ui-iggrid-expandbutton").css("visibility","hidden");this.indicator.show(false)}else{this.indicator.show(false)}setTimeout(function(){hgrid._toggleInternalAsync(event,suppressEvents,callback)},expandTout)}else{hgrid._toggleInternalAsync(event,suppressEvents,callback)}if(!suppressEvents){if(event.originalEvent&&typeof event.originalEvent.cancelBubble==="unknown"){event.originalEvent={}}event.stopImmediatePropagation()}},_toggleInternalAsync:function(event,suppressEvents,callback){var $td=$(event.target),parentrow=$td.closest("tr"),rowid="",keyspath="",keyspathvar="",pgridp,level=-1,sp=false,restSettingsSet,childds,created=parentrow.attr("c"),childrow,childgrids=[],ds,opts=[],id,k,isHierarchical,tmpkey,pki,key,pgInstance,cs,popts,i,j,h,parentLevel=0,tmpgrid,state=parentrow.attr("state"),animatec,noCancel=true,noCancelChild=true,pid,instanceOfDs,eArgs,currPathVar,paths,ids,childGrid,createdChildGrids=[];if($td.is("td")&&$td.attr("data-parent")!=="true"||$td.closest("td").attr("data-parent")!=="true"){return}if(state===undefined){state="c"}restSettingsSet=this.options.restSettings.update.url!==null||this.options.restSettings.update.template!==null||this.options.restSettings.create.url!==null||this.options.restSettings.create.template!==null||this.options.restSettings.remove.url!==null||this.options.restSettings.remove.template!==null;if(!created&&state==="c"){parentrow.after("<tr></tr>");childrow=parentrow.next();childrow.attr("data-container",true);popts=parentrow.closest("table").data("igGrid").options;opts=this._optsFor(popts);pgridp=parentrow.closest(".ui-iggrid-table");keyspath+=pgridp.attr("data-path")||"";rowid+=pgridp.attr("data-ids")||"";k=parentrow.closest("table").data("igGrid").options.primaryKey;if(rowid===""){rowid=k+":"+parentrow.attr("data-id")}else{rowid+=this.options.pathSeparator+k+":"+parentrow.attr("data-id")}cs=parentrow.find("td,th").length;animatec=$("<div></div>").appendTo($("<td></td>").appendTo(childrow).addClass(this.css.childGridArea).attr("colspan",cs));for(i=0;i<opts.length;i++){keyspathvar="";childgrids.push($("<table></table>").appendTo(animatec).attr("data-childgrid",true));key=opts[i].key!==undefined?opts[i].key:opts[i].childrenDataProperty;childgrids[i].attr("id",this.root()[0].id+"_"+parentrow.attr("data-id")+"_"+key+"_child");parentLevel=parseInt(parentrow.closest("table").attr("data-level"),10);childgrids[i].attr("id",childgrids[i].attr("id").replace(",","-")).attr("data-level",parentLevel+1);if(keyspath===""){keyspathvar=opts[i].childrenDataProperty===undefined?opts[i].key:opts[i].childrenDataProperty}else{keyspathvar=this.options.pathSeparator+(opts[i].childrenDataProperty===undefined?opts[i].key:opts[i].childrenDataProperty)}childds=this._hds.dataAt(rowid,keyspath+keyspathvar);if(childds===null||childds===undefined){childds=[]}else if($.type(childds)!=="array"&&!opts[i].responseDataKey&&childds!==undefined){childds=[childds]}isHierarchical=false;if(opts[i].columnLayouts&&opts[i].columnLayouts.length>0){isHierarchical=true}if(isHierarchical){this._regevents(childgrids[i],this)}level=rowid.split(this.options.pathSeparator).length;if(level>this.options.initialDataBindDepth&&this.options.initialDataBindDepth!==-1){sp=true}ds=this._hdsoptions().dataSource;eArgs={owner:this,options:opts[i],element:childgrids[i],id:rowid,path:keyspath+keyspathvar};if(!sp){opts[i].dataSource=childds;if($.type(ds)==="string"&&this.options.rest!==true&&!opts[i].dataSourceUrl){opts[i].dataSourceUrl=ds}if(opts[i].dataSourceUrl&&$.type(opts[i].dataSourceUrl)==="string"){if(!this.options.odata){opts[i].dataSourceUrl=$.ig.util.appendToQueryString(opts[i].dataSourceUrl,this._hds._encodeUrlPath(rowid,opts[i].key))}else{opts[i].dataSourceUrl=this._getOdataChildUrl(parentrow,keyspathvar,opts[i])}}if(this.options.autoGenerateLayouts===true){opts[i]._recurseSchema=true}noCancelChild=$.event.trigger(this.events.childGridCreating,eArgs,childgrids[i][0]);noCancelChild=childgrids[i].attr("data-create")!=="false"&&noCancelChild!==false;if(noCancelChild){if((this.options.rest||this.options.odata)&&restSettingsSet===true){this._inheritRestSettings(null,parentrow.attr("data-id"),keyspathvar.toLowerCase(),popts,opts[i])}if(isHierarchical){opts[i]._isHierarchicalGrid=true}opts[i].layoutPath=keyspath+keyspathvar;pgInstance=parentrow.closest(".ui-iggrid-table").data("igGrid");if(pgInstance){opts[i].foreignKeyValue=pgInstance._fixPKValue(parentrow.data("id"))}else{opts[i].foreignKeyValue=parentrow.data("id")}h=$.proxy(this._childRendered,this);childgrids[i].bind("iggridrendered.hierarchicalgrid",h);childgrids[i].igGrid(opts[i]);childgrids[i].attr("data-path",keyspath+keyspathvar);childgrids[i].attr("data-ids",rowid);if(opts[i].dataSourceUrl&&$.type(opts[i].dataSourceUrl)==="string"&&this.options.odata){childGrid=childgrids[i].data("igGrid");childGrid.options.responseDataKey=this.options.responseDataKey;childGrid.dataSource.schema().schema.searchField=this.options.responseDataKey}if(isHierarchical){this._regToggleEvent(childgrids[i],this)}childgrids[i].trigger(this.events.childGridCreated,{owner:this,element:childgrids[i]});createdChildGrids.push(childgrids[i])}if(opts[i].primaryKey===null||opts[i].primaryKey===undefined){if(opts[i].dataSource&&typeof opts[i].dataSource._xmlToArray==="function"&&typeof opts[i].dataSource._encodePkParams==="function"){throw new Error(this._getLocaleValue("noPrimaryKey"))}tmpgrid=childgrids[i].data("igGrid");tmpkey=tmpgrid.dataSource.schema().schema.searchField;if(tmpkey!==null){for(pki=0;pki<opts[i].dataSource[tmpkey].length;pki++){opts[i].dataSource[tmpkey][pki].ig_pk=tmpgrid.dataSource.data()[pki].ig_pk}}else{for(pki=0;pki<opts[i].dataSource.length;pki++){if(opts[i].dataSource[pki]){opts[i].dataSource[pki].ig_pk=tmpgrid.dataSource.data()[pki].ig_pk}}}}}else{instanceOfDs=ds&&typeof ds._xmlToArray==="function"&&typeof ds._encodePkParams==="function";if(this.options.odata){opts[i].dataSource=this._getOdataChildUrl(parentrow,keyspathvar,opts[i]);if(restSettingsSet===true){this._inheritRestSettings(null,parentrow.attr("data-id"),keyspathvar.toLowerCase(),popts,opts[i])}}else if(this.options.rest===true){if(ds.substr(ds.length-1)!=="/"){ds+="/"}currPathVar=keyspathvar;if(currPathVar.substr(0,1)!=="/"){currPathVar="/"+currPathVar}if(pgridp.attr("data-path")!==undefined&&pgridp.attr("data-ids")!==undefined){paths=pgridp.attr("data-path").split(this.options.pathSeparator);ids=pgridp.attr("data-ids").split(this.options.pathSeparator);for(j=0;j<paths.length;j++){ds+=ids[j].split(":")[1]+"/"+paths[j]+"/"}}pid=parentrow.attr("data-id");opts[i].dataSource=ds+pid+currPathVar.toLowerCase();if(restSettingsSet===true){this._inheritRestSettings(opts[i].dataSource,pid,keyspathvar.toLowerCase(),popts,opts[i])}}else if(instanceOfDs){opts[i].dataSource=ds.settings.dataSource+this._hds._encodeUrlPath(rowid,opts[i].key)}else{if(opts[i].dataSource){opts[i].dataSource=$.ig.util.appendToQueryString(opts[i].dataSource,this._hds._encodeUrlPath(rowid,opts[i].key));opts[i].dataSourceType="remoteUrl"}else{if($.type(ds)!=="string"){if($.type(opts[i].dataSource)==="string"){opts[i].dataSource=$.ig.util.appendToQueryString(opts[i].dataSource,this._hds._encodeUrlPath(rowid,opts[i].key));opts[i].dataSourceType="remoteUrl"}else if($.type(childds)==="array"){opts[i].dataSource=childds}}else{opts[i].dataSource=$.ig.util.appendToQueryString(ds,this._hds._encodeUrlPath(rowid,opts[i].key))}}if($.type(opts[i].dataSource)==="string"){opts[i].dataSourceUrl=opts[i].dataSource}}}}if(sp){noCancel=this._trigger(this.events.childrenPopulating,null,{owner:this,parentrow:parentrow,id:rowid});if(noCancel){for(i=0;i<opts.length;i++){id=parentrow.attr("data-id");if(!this._eventQueue["id"+id]||!this._eventQueue["id"+id].length){this._eventQueue["id"+id]=[]}h=$.proxy(this._childRendered,this);this._eventQueue["id"+id].push({grid:childgrids[i],handler:h,parentrow:parentrow,id:rowid});childgrids[i].bind("iggridrendered",h);if(this.options.autoGenerateLayouts===true){opts[i]._recurseSchema=true}if(isHierarchical){opts[i]._isHierarchicalGrid=true}pgInstance=parentrow.closest(".ui-iggrid-table").data("igGrid");if(pgInstance){opts[i].foreignKeyValue=pgInstance._fixPKValue(parentrow.data("id"))}else{opts[i].foreignKeyValue=parentrow.data("id")}eArgs={owner:this,options:opts[i],element:childgrids[i],id:rowid,path:keyspath+keyspathvar};noCancelChild=$.event.trigger(this.events.childGridCreating,eArgs,childgrids[i][0]);noCancelChild=childgrids[i].attr("data-create")!=="false"&&noCancelChild!==false;if(noCancelChild){childgrids[i].igGrid(opts[i]);childgrids[i].attr("data-path",keyspath+keyspathvar);childgrids[i].attr("data-ids",rowid);childgrids[i].trigger(this.events.childGridCreated,{owner:this,element:childgrids[i]});createdChildGrids.push(childgrids[i]);if(isHierarchical){this._regToggleEvent(childgrids[i],this)}}}}}animatec.attr("id","ac_"+parentrow.attr("data-id"));parentrow.attr("c",true);parentrow.next().hide();animatec.hide();this._expand(parentrow,suppressEvents,callback)}else{if(state==="e"){this._collapse(parentrow,suppressEvents,callback)}else if(state==="c"){this._expand(parentrow,suppressEvents,callback)}}if(this.indicator){this.indicator.hide()}parentrow.find(".ui-iggrid-expandbutton").css("visibility","visible");for(i=1;i<createdChildGrids.length;i++){tmpgrid=createdChildGrids[i].data("igGrid");if(tmpgrid){$("<div></div>").insertBefore(tmpgrid.container()).addClass(this.css.childGridSeparator)}}},_getOdataChildUrl:function(parentrow,keyspathvar,childGridOpts){var popts=parentrow.closest("table").data("igGrid").options,ds=this._hdsoptions().dataSource,instanceOfDs=ds&&typeof ds._xmlToArray==="function"&&typeof ds._encodePkParams==="function",dsobj=instanceOfDs?ds.settings.dataSource:ds,dsString=popts.dataSource&&typeof popts.dataSource._xmlToArray==="function"&&typeof popts.dataSource._encodePkParams==="function"?popts.dataSource.settings.dataSource:popts.dataSource,childds=parentrow.closest("table").data("igGrid").dataSource.data(),tmpkey=parentrow.attr("data-id"),k=popts.primaryKey,dsURL,pki,pid,currPathVar;if(parentrow.closest("table").data("igGrid").columnByKey(k).dataType==="number"){tmpkey=parseInt(tmpkey,10)}pid=typeof tmpkey==="string"?"'"+tmpkey+"'":tmpkey;for(pki=0;pki<childds.length;pki++){if(childds[pki][parentrow.closest("table").data("igGrid").options.primaryKey]===tmpkey){childds=childds[pki][childGridOpts.key];break}}if(!childds){if(dsString.substr(dsString.length-1)==="/"){dsString=dsString.substring(0,dsString.length-1)}currPathVar=keyspathvar;if(currPathVar.charAt(0)!=="/"){currPathVar="/"+currPathVar}if($.type(dsobj)==="string"&&dsobj!==dsString){dsString=dsobj.substring(0,dsobj.lastIndexOf("/"))+dsString.substring(dsString.lastIndexOf("/"))}dsURL=dsString.indexOf("?")!==-1?$.ig.util.prependToQueryString(dsString,"("+pid+")"+currPathVar):dsString+"("+pid+")"+currPathVar}else{if(childds.__deferred&&childds.__deferred.uri){dsURL=childds.__deferred.uri;if(dsobj.indexOf("$callback=?")!==-1){dsURL=$.ig.util.appendToQueryString(dsobj,"$callback=?")}if(dsobj.indexOf("$format=")!==-1&&dsURL.indexOf("$format=json")===-1){if(dsobj.indexOf("$format=json")!==-1){dsURL=$.ig.util.appendToQueryString(dsURL,"$format=json")}else{dsURL=$.ig.util.appendToQueryString(dsURL,"$format=atom")}}}else{dsURL=$.ig.util.prependToQueryString(childGridOpts.dataSourceUrl,"("+pid+")/"+keyspathvar)}}return dsURL},_layouts:function(){this.element.unbind("iggriddatarendering",this._databoundHandler)},_columnsGenerated:function(event,args){var layoutKey=args.key,layout;if(!layoutKey){return}layout=this._findLayout(this.rootWidget().options.columnLayouts,layoutKey);if(layout.columns&&layout.columns.length&&layout.columns.length>0){return}layout.columns=args.owner.options.columns},_findLayout:function(layouts,key){var i,layout;for(i=0;layouts&&i<layouts.length;i++){if(layouts[i].key===key){layout=layouts[i];break}if(!layout&&layouts[i].columnLayouts){layout=this._findLayout(layouts[i].columnLayouts,key)}}return layout},_hdsoptions:function(){var opts,schema,instanceOfHds;opts={responseDataKey:this.options.responseDataKey,responseTotalRecCountKey:this.options.responseTotalRecCountKey,dataSource:this.options.dataSource,primaryKey:this.options.primaryKey,localSchemaTransform:this.options.localSchemaTransform,autoCommit:this.options.autoCommit,odata:this.options.odata,serializeTransactionLog:this.options.serializeTransactionLog,updateUrl:this.options.updateUrl,restSettings:this.options.restSettings,initialDataBindDepth:this.options.initialDataBindDepth,requestType:this.options.requestType};if(this.options.dataSourceType!==null){opts.type=this.options.dataSourceType}schema=this._hschema();instanceOfHds=this.options.dataSource&&typeof this.options.dataSource._encodeHierarchicalUrlParams==="function"&&this.options.dataSource.settings&&this.options.dataSource.settings.hasOwnProperty&&this.options.dataSource.settings.hasOwnProperty("initialDataBindDepth");if(instanceOfHds&&this.options.dataSource.settings.schema===null||!instanceOfHds){opts=$.extend(opts,{schema:schema})}return opts},_getDataColumns:function(cols){var i,j,res=[],colsLength=cols.length,dCols;for(i=0;i<colsLength;i++){if(cols[i].group!==undefined&&cols[i].group!==null){dCols=this._getDataColumns(this._getDataColumns(cols[i].group));for(j=0;j<dCols.length;j++){res.push(dCols[j])}}else{res.push(cols[i])}}return res},_hschema:function(){var schema,i,j,rec,prop,cols=this._getDataColumns(this.options.columns),encodedLayouts=[],k,c;if(cols.length>0&&!this.options.autoGenerateColumns){schema={};schema.fields=[];j=0;for(i=0;i<cols.length;i++){if(cols[i].unbound===true){continue;
}schema.fields[j]={};schema.fields[j].name=cols[i].key;schema.fields[j].type=cols[i].dataType;j++}schema.searchField=this.options.responseDataKey}else if(this.options.autoGenerateColumns){schema={};schema.fields=[];if(this.options.dataSource&&this.options.dataSource.length&&this.options.dataSource.length>0&&$.type(this.options.dataSource)==="array"){rec=this.options.dataSource[0];for(prop in rec){if(rec.hasOwnProperty(prop)){for(k=0;k<cols;k++){if(cols[k].key===prop){c=cols[k];break}}if(c===null||c===undefined){schema.fields.push({name:prop,type:$.ig.getColType(rec[prop])})}else{if(c.unbound===true){continue}schema.fields.push({name:prop,type:c.dataType})}}}}}if(this.options.columnLayouts&&this.options.columnLayouts.length>0){for(j=0;j<this.options.columnLayouts.length;j++){schema.fields.push({name:this.options.columnLayouts[j].childrenDataProperty===undefined?this.options.columnLayouts[j].key:this.options.columnLayouts[j].childrenDataProperty})}}this._parseLayouts(encodedLayouts,"",this.options);schema.layouts=encodedLayouts;return schema},_parseLayouts:function(layouts,cpath,options){var j,layout,p,cdp=null;if(options.columnLayouts&&options.columnLayouts.length!==undefined&&options.columnLayouts.length>0){for(j=0;j<options.columnLayouts.length;j++){layout=options.columnLayouts[j];cdp=layout.childrenDataProperty===undefined?layout.key:layout.childrenDataProperty;if(!cdp){cdp=this.options.defaultChildrenDataProperty}p=cpath+this.options.pathSeparator+cdp+":"+layout.primaryKey;layouts[p]=layout;this._parseLayouts(layouts,p,layout)}}},_batchExpand:function(){var crows=[],tmpanim,hgrid;hgrid=this.element.closest(".ui-iggrid-root").data("igHierarchicalGrid");if(!hgrid){hgrid=this.element.data("igHierarchicalGrid")}tmpanim=hgrid.options.expandCollapseAnimations;hgrid.options.expandCollapseAnimations=false;crows=this.element.find("tr[data-id]");hgrid._batchExpandLevel(crows);hgrid.options.expandCollapseAnimations=tmpanim},_batchExpandLevel:function(rows){var i;for(i=0;i<rows.length;i++){this.toggle(rows[i])}},_renderExtraHeaderCell:function(row,colgroup,prepend){if(prepend===true){$("<td></td>").prependTo(row).css("border-width",0).attr("data-skip",true)}else{$("<td></td>").appendTo(row).css("border-width",0).attr("data-skip",true)}},_renderExtraFooterCell:function(row,colgroup,prepend,cssClass){if(prepend===true){$("<td></td>").addClass(cssClass).prependTo(row).attr("data-skip",true)}else{$("<td></td>").addClass(cssClass).appendTo(row).attr("data-skip",true)}},_dataBound:function(sender,args){var senderId=sender.currentTarget.id,ownerId=args.owner.element[0].id,o=args.owner.options;if(ownerId!==senderId&&ownerId!==senderId+"_table"){return}if(o.primaryKey===null||o.primaryKey===undefined){this._generatePrimaryKeyValues(args.dataSource.data());o.primaryKey="ig_pk"}},_headerrenderedinternal:function(sender,args){if(args.owner.element[0].id!==sender.currentTarget.id&&args.owner.element[0].id!==sender.currentTarget.id+"_table"){return}var self=this,flatRenderColgroup=args.owner._renderColgroup,tmpid,$thDataSkip;args.owner._cleanupTBody=function(){var $tbody=this.element.children("tbody");this._fireInternalEvent("_cleanupTBody");$tbody.children("tr").remove();return $tbody};args.owner._renderRecord=$.proxy(this._hierarchicalRenderRecord,args.owner);args.owner._getFirstVisibleTR=$.proxy(this._hierarchicalGetFirstVisibleTR,args.owner);args.owner._getLastVisibleTR=$.proxy(this._hierarchicalGetLastVisibleTR,args.owner);args.owner._renderColgroup=function(){self._hierarchicalRenderColgroup.apply(args.owner,$.merge([flatRenderColgroup,self],arguments))};args.owner._headerInitCallbacks.push({type:"HierarchicalGrid",func:$.proxy(this._renderExtraHeaderCell,this)});args.owner._footerInitCallbacks.push({type:"HierarchicalGrid",func:$.proxy(this._renderExtraFooterCell,this)});args.owner._trigger("headerextracellsmodified",null,{owner:args.owner});if(args.table.attr("id")!==args.owner.element.attr("id")&&$(args.table).find("colgroup col[data-expander]").length===0){$("<col></col>").attr("data-skip","true").attr("data-expander",true).prependTo(args.table.find("colgroup")).width(this.options.expandColWidth)}$thDataSkip=$("<th></th>");$("<span></span>").appendTo($thDataSkip.prependTo(args.table.find("thead tr:first")).addClass(this.css.expandHeaderCell).attr("data-skip",true)).addClass(this.css.expandHeaderCellTriangle);if(args.owner._isMultiColumnGrid){$thDataSkip.attr("rowspan",args.owner._maxLevel+1)}if(args.owner._isWrapped){tmpid=args.owner.element.attr("id").substring(0,args.owner.element.attr("id").indexOf("_table"));args.owner.container().find("#"+tmpid).unbind("iggridheaderrenderedinternal",args.owner.element.data("hr"));args.owner.container().find("#"+tmpid).removeData("hr")}else{args.owner.element.unbind("iggridheaderrenderedinternal",args.owner.element.data("hr"));args.owner.element.removeData("hr")}},_checkIsMultiColumnHeader:function(lobj){var i,cols=lobj.columns,colsLength;if(cols){colsLength=cols.length;for(i=0;i<colsLength;i++){if(cols[i].group!==undefined&&cols[i].group!==null){return true}}}return false},_hierarchicalRenderRecord:function(data,rowIndex){var i,grid=this,lod,hg,childprop,dstr="",val,markup="",layouts,hasChildren,noVisibleColumns,layout,temp,cellClass;if(rowIndex%2!==0&&this.options.alternateRowStyles){dstr+="<tr class='"+grid.css.recordAltClass+"'"}else{dstr+="<tr"}dstr+=" data-row-idx='"+rowIndex+"'";if(!this._hg){hg=this.element.closest(".ui-iggrid-root").data("igHierarchicalGrid");if(!hg){hg=this.element.hasClass(".ui-iggrid-root")?this.element:undefined}this._hg=hg}else{hg=this._hg}if(this.options.foreignKey){dstr+=" data-id-fk='"+this._kval_from_key(this.options.foreignKey,data)+"'"}else{if(this.options.primaryKey===null||this.options.primaryKey===undefined){this.options.primaryKey="ig_pk";val=hg._getVal(data);dstr+=" data-id-fk='"+val+"'"}else if(this.options.primaryKey==="ig_pk"){val=hg._getVal(data);dstr+=" data-id-fk='"+val+"'"}else{dstr+=" data-id-fk='"+this._kval_from_key(this.options.primaryKey,data)+"'"}}if(this.options.primaryKey===null||this.options.primaryKey===undefined){this.options.primaryKey="ig_pk";val=hg._getVal(data);dstr+=" data-id='"+val+"'"}else if(this.options.primaryKey==="ig_pk"){val=hg._getVal(data);dstr+=" data-id='"+val+"'"}else{dstr+=" data-id='"+this._kval_from_key(this.options.primaryKey,data)+"'"}dstr+=" role='row' aria-expanded='false' tabindex='"+this.options.tabIndex+"'>";layouts=this.options.columnLayouts;hasChildren=false;lod=hg?hg.options.initialDataBindDepth>-1:false;if(!lod){for(i=0;layouts&&i<layouts.length;i++){if(data[layouts[i].key]){childprop=layouts[i].key;layout=layouts[i]}else{childprop=layouts[i].childrenDataProperty}childprop=childprop||this.options.defaultChildrenDataProperty;if(childprop){if(layout&&layout.responseDataKey){if(data[childprop]&&data[childprop][layout.responseDataKey]&&data[childprop][layout.responseDataKey].length!==undefined&&(data[childprop][layout.responseDataKey].length>0||this._shouldAlwaysRenderChildIndicator)){hasChildren=true;break}}else{if(data[childprop]){if(data[childprop].length!==undefined&&(data[childprop].length>0||this._shouldAlwaysRenderChildIndicator)){hasChildren=true;break}if(this.options.responseDataKey&&data[childprop][this.options.responseDataKey]&&data[childprop][this.options.responseDataKey].length!==undefined&&(data[childprop][this.options.responseDataKey].length>0||this._shouldAlwaysRenderChildIndicator)){hasChildren=true;break}}}}}}else{hasChildren=true}if(hasChildren){markup="<span class='ui-iggrid-expandbuttoncontainer'>"+"<span class='ui-iggrid-expandbutton ui-icon ui-icon-plus' "+"data-toggle-button='true' "+"data-localeid='expandTooltip' data-localeattr='title' "+"title='"+hg._getLocaleValue("expandTooltip")+"'></span></span>"}dstr+="<td tabindex='0' class='ui-iggrid-expandcolumn"+grid._addCellStyle(data,-1).replace(/class=\"/,"").replace(/\"/,"")+"' data-parent='"+hasChildren+"'>"+markup+"</td>";noVisibleColumns=true;$(this.options.columns).each(function(colIndex){var col=grid.options.columns[colIndex];cellClass=false;if(col.hidden){return}noVisibleColumns=false;dstr+="<td role='gridcell'  aria-readonly="+!!this.readOnly+" aria-describedby='"+grid.id()+"_"+this.key+"' tabindex='"+grid.options.tabIndex+"'";if(data[this.key]===undefined){if(this.template&&this.template.length){if(col.unbound){temp=grid._renderTemplatedCell(data,this)}else{temp=grid._renderTemplatedCell(data[colIndex],this)}if(temp.indexOf("<td")===0){dstr+=temp.substring(3)}else{dstr+=">"+temp;cellClass=true}dstr=grid._editCellStyle(dstr,data,colIndex,col,cellClass)}else{dstr+=grid._addCellStyle(data,colIndex,col)+">"+grid._renderCell(data[colIndex],this,data)}dstr+="</td>"}else{if(this.template&&this.template.length){temp=grid._renderTemplatedCell(data,this);if(temp.indexOf("<td")===0){dstr+=temp.substring(3)}else{dstr+=">"+temp;cellClass=true}dstr=grid._editCellStyle(dstr,data,this.key,col,cellClass)}else{dstr+=grid._addCellStyle(data,this.key,col)+">"+grid._renderCell(data[this.key],this,data)}dstr+="</td>"}});if(noVisibleColumns){dstr+="<td role='gridcell'></td>"}dstr+="</tr>";return dstr},_generatePrimaryKeyValues:function(ds){ds=ds||[];var i,len=ds.length;for(i=0;i<len;i++){ds[i].ig_pk=ds[i].ig_pk||$.ig.util.getCheckSumForObject(ds[i])}},_getVal:function(rec){rec.ig_pk=rec.ig_pk||$.ig.util.getCheckSumForObject(rec);return rec.ig_pk},_hierarchicalRenderColgroup:function(flatRenderColgroup,hierarchicalGrid,table,isHeader,isFooter,autofitLastColumn){var $colgroup;flatRenderColgroup.apply(this,[table,isHeader,isFooter,autofitLastColumn]);$colgroup=$(table).find(">colgroup");if($colgroup.find(">col[data-expander]").length>0){return}$("<col></col>").prependTo($colgroup).css("width",hierarchicalGrid.options.expandColWidth).attr("data-skip","true").attr("data-expander",true)},_schemaGenerated:function(event,args){var hg,i,rec,schema=args.schema,ds=args.dataSource,$this=args.owner,prop;hg=$this.element.closest(".ui-iggrid-root").data("igHierarchicalGrid");if(!hg){hg=$this.element.hasClass(".ui-iggrid-root")?$this.element:undefined}if(!hg||hg.options.initialDataBindDepth>-1){return}for(i=0;ds&&ds.length&&$.type(ds)==="array"&&i<ds.length;i++){rec=ds[i];for(prop in rec){if(rec.hasOwnProperty(prop)){if(!$this._fieldExists(prop,schema)&&($.type(rec[prop])==="array"||$.type(rec[prop])==="object")){schema.fields.push({name:prop,type:$.ig.getColType(rec[prop])})}}}}},_childRendered:function(sender,args){var ptr=args.owner.element.closest("tr").prev(),pid="id"+ptr.attr("data-id"),e=this._eventQueue[pid],i,fire=true;this._trigger(this.events.childGridRendered,null,{owner:this,parentrow:ptr,childgrid:args.owner});if(!e){args.owner.element.unbind("iggridrendered.hierarchicalgrid");return}for(i=0;e.length!==undefined&&i<e.length;i++){if(e[i].grid.attr("id")===args.owner.element.attr("id")){e[i].done=true;e[i].grid.unbind("iggridrendered",e[i].handler);break}}for(i=0;e.length!==undefined&&i<e.length;i++){if(!e[i].done){fire=false;break}}if(fire){this._trigger(this.events.childrenPopulated,null,{owner:this,parentrow:ptr,id:e[0].id});delete this._eventQueue[pid]}},_optsFor:function(popts){var i,j,o=[],layouts;if(popts.columnLayouts&&popts.columnLayouts.length>0&&$.type(popts.columnLayouts)==="array"){layouts=popts.columnLayouts;for(j=0;j<layouts.length;j++){this._inherit(popts,layouts[j]);o.push($.extend(true,{},$.ui.igGrid.prototype.options,{language:popts.language,locale:popts.locale,regional:popts.regional},layouts[j]))}}for(i=0;i<o.length;i++){if(!o[i].dataSource){o[i].dataSourceUrl=popts.dataSourceUrl}else{if(String(popts.initialDataBindDepth)==="-1"||popts.initialDataBindDepth===undefined){o[i].dataSourceUrl=o[i].dataSource}}}return o},_inherit:function(parent,child){var i,f,j,nowrite;if(parent.dataSourceType){child.dataSourceType=parent.dataSourceType}if(!parent.features||parent.features.length===undefined||parent.features.length===0){return}if(!child.features||child.features.length===undefined){child.features=[]}for(i=0;i<parent.features.length;i++){if(parent.features[i].inherit===true){f=null;for(j=0;j<child.features.length;j++){if(child.features[j].name===parent.features[i].name){f=child.features[j];break}}if(f===null||f===undefined){child.features.push($.extend(true,{},parent.features[i]));child.features[child.features.length-1].columnSettings=[]}else{nowrite=false;if(child.features[j].columnSettings&&child.features[j].columnSettings.length>0){nowrite=true}child.features[j]=$.extend(true,{},parent.features[i],f);if(!nowrite){child.features[j].columnSettings=[]}}}}},_regevents:function(e,context){var headerRenderedInternal,datarendered,schemaGenerated,columnStateChanged;headerRenderedInternal=$.proxy(context._headerrenderedinternal,context);datarendered=$.proxy(this._handleBatchExpandRender,context);schemaGenerated=$.proxy(this._schemaGenerated,context);columnStateChanged=$.proxy(this._columnStateChanged,context);e.bind("iggridheaderrenderedinternal.hierarchicalgrid",headerRenderedInternal);e.bind("iggriddatarendered.hierarchicalgrid",datarendered);e.bind("iggridschemagenerated.hierarchicalgrid",schemaGenerated);e.bind("iggriddatabound.hierarchicalgrid",$.proxy(this._dataBound,this));e.bind("iggridcolumnscollectionmodified.hierarchicalgrid",columnStateChanged);e.data("hr",headerRenderedInternal)},_regToggleEvent:function(e,context){var toggle;toggle=$.proxy(context._toggleInternalWithDelay,context);e.undelegate(".ui-iggrid-expandcolumn > .ui-iggrid-expandbuttoncontainer","mousedown");e.delegate(".ui-iggrid-expandcolumn > .ui-iggrid-expandbuttoncontainer","mousedown",toggle)},commit:function(){var elem=this.element;elem.find(".ui-iggrid-table").each(function(){$(this).igGrid("commit")});elem.igGrid("commit")},rollback:function(rebind){var elem=this.element;elem.find(".ui-iggrid-table").each(function(){$(this).igGrid("rollback",null,rebind)});elem.igGrid("rollback",null,rebind)},_addToLog:function(elem,taLog,child){var grid=elem.data("igGrid"),ds=grid?grid.dataSource:null,gridLog=ds?ds.allTransactions():[],i;if(!gridLog.length){return}this._dsLog=this._dsLog||[];this._dsLog.push(ds);for(i=0;i<gridLog.length;i++){taLog.push($.extend(true,child?{layoutKey:grid.options.key}:{},gridLog[i]))}},saveChanges:function(success,error){var self=this,opts,elem=self.element,url=self.options.updateUrl,taLog=[];if((this.options.rest||this.options.odata)&&this.options.restSettings){this._saveChangesForEachGrid();return}if(!url||!elem){return}delete self._dsLog;self._addToLog(elem,taLog);self.allChildren().each(function(){self._addToLog($(this),taLog,true)});opts={type:"POST",url:url,data:{ig_transactions:JSON.stringify(taLog)},success:function(data,textStatus,jqXHR){var logs=self._dsLog,i=logs?logs.length:0;while(i-- >0){logs[i]._saveChangesSuccess(data,textStatus,jqXHR)}if(success){success(data,textStatus,jqXHR)}},error:function(jqXHR,textStatus,errorThrown){var logs=self._dsLog,i=logs?logs.length:0;while(i-- >0){logs[i]._saveChangesError(jqXHR,textStatus,errorThrown)}if(error){error(jqXHR,textStatus,errorThrown)}}};$.ajax(opts)},_saveChangesForEachGrid:function(success,error){this.rootWidget().saveChanges(success,error);$.each(this.allChildrenWidgets(),function(){this.saveChanges(success,error)})},_handleBatchExpandRender:function(sender,args){var level=0,grid=args.owner,keyspath,ds,hdsData,rowid,popts,pgridp,parentRow,k,gridId=grid.element[0].id,tId=sender.currentTarget.id;if(gridId!==tId&&gridId!==tId+"_table"){return}level=parseInt(grid.element.attr("data-level"),10);if(isNaN(level)){level=0;grid.element.attr("data-level",level)}if(level>0&&this.options.initialDataBindDepth===-1&&this._hds.settings.type==="json"&&$.type(grid.options.dataSource)==="string"){keyspath="";rowid="";popts=grid.options;parentRow=grid.element.closest("tr[data-container]").prev("tr");pgridp=parentRow.closest(".ui-iggrid-table");keyspath+=pgridp.attr("data-path")||"";rowid+=pgridp.attr("data-ids")||"";k=pgridp.data("igGrid").options.primaryKey;if(rowid===""){rowid=k+":"+parentRow.attr("data-id")}else{rowid+=this.options.pathSeparator+k+":"+parentRow.attr("data-id")}if(popts.childrenDataProperty===undefined){if(popts.key){keyspath+=popts.key}}else{keyspath+=popts.childrenDataProperty}hdsData=this._hds.dataAt(rowid,keyspath);ds=grid.dataSource;if(hdsData[popts.responseDataKey]){hdsData[popts.responseDataKey]=ds._dataView;hdsData.Metadata=ds.metadata()}}if(level>this.options.initialExpandDepth){return}if((this.options.initialDataBindDepth===-1||this.options.initialDataBindDepth>=this.options.initialExpandDepth)&&this.options.initialExpandDepth!==-1){setTimeout($.proxy(this._batchExpand,args.owner),1)}},_columnStateChanged:function(sender,args){if(args.owner._initialized){this._handleBatchExpandRender(sender,args)}},_inheritRestSettings:function(path,pid,layout,popts,copts){var crest=copts.restSettings,prest=popts.restSettings,rs,ptmpl,fullpath;if(!path){if(prest.update.template||prest.remove.template){path=prest.update.template||prest.remove.template;path=path.replace("${id}",pid)}else{path=prest.create.url||prest.update.url||prest.remove.url;if(path.substr(path.length-1)!=="/"){path+="/"}path+=pid}if(layout.substr(0,1)==="/"){layout=layout.substr(1)}if(path.substr(path.length-1)!=="/"){path+="/"}fullpath=path+layout}else{fullpath=path}rs={update:{url:fullpath},create:{url:fullpath},remove:{url:fullpath}};if(crest.create.template&&prest.create.template){ptmpl=prest.create.template.replace("${id}",pid);crest.create.template=ptmpl+"/"+crest.create.template}if(crest.remove.template&&prest.remove.template){ptmpl=prest.remove.template.replace("${id}",pid);crest.remove.template=ptmpl+"/"+crest.remove.template}if(crest.update.template&&prest.update.template){ptmpl=prest.update.template.replace("${id}",pid);crest.update.template=ptmpl+"/"+crest.update.template}crest=$.extend(true,crest,rs)},_rowExpanded:function(args){var rowExpansion,rowHeight,parentGrid,currentHeight,rootGrid;rowExpansion=args.parentrow.next();if(rowExpansion.length===0||!rowExpansion.is("tr[data-container='true']")){return}rowHeight=rowExpansion.outerHeight();parentGrid=args.parentrow.closest(".ui-iggrid-table").data("igGrid");if((parentGrid.options.virtualization||parentGrid.options.rowVirtualization)&&parentGrid.options.virtualizationMode==="continuous"){currentHeight=parentGrid._getScrollContainerHeight();parentGrid._setScrollContainerHeight(currentHeight+rowHeight)}rootGrid=this.element.closest(".ui-iggrid-root").data("igGrid");if(rootGrid.options.rowVirtualization&&!parentGrid.options.height&&rootGrid.options.height){currentHeight=rootGrid._getScrollContainerHeight();rootGrid._setScrollContainerHeight(currentHeight+rowHeight)}},_rowCollapsed:function(args){var rowExpansion=args.parentrow.next(),rowHeight,parentGrid,currentHeight,rootGrid;if(rowExpansion.length===0||!rowExpansion.is("tr[data-container='true']")){return}rowHeight=rowExpansion.outerHeight();parentGrid=args.parentrow.closest(".ui-iggrid-table").data("igGrid");if((parentGrid.options.virtualization||parentGrid.options.rowVirtualization)&&parentGrid.options.virtualizationMode==="continuous"){currentHeight=parentGrid._getScrollContainerHeight();parentGrid._setScrollContainerHeight(currentHeight-rowHeight)}rootGrid=this.element.closest(".ui-iggrid-root").data("igGrid");if(rootGrid.options.rowVirtualization&&!parentGrid.options.height&&rootGrid.options.height){currentHeight=rootGrid._getScrollContainerHeight();rootGrid._setScrollContainerHeight(currentHeight-rowHeight)}},_hierarchicalGetFirstVisibleTR:function(visibleArea){var tableId="#"+this.element[0].id,firstVisibleTR;firstVisibleTR=$(tableId+" > tbody > tr:not([data-container='true'])").filter(function(){return this.offsetTop+$(this).height()>visibleArea.top}).first();return firstVisibleTR},_hierarchicalGetLastVisibleTR:function(visibleArea){var tableId="#"+this.element[0].id,lastVisibleTR;lastVisibleTR=$(tableId+" > tbody > tr:not([data-container='true'])").filter(function(){return this.offsetTop<visibleArea.bottom}).last();return lastVisibleTR},_clearVariablesAndEvents:function(){this.tmpDataSource=null;this._rootgrid=null;this.element.unbind(".hierarchicalgrid")},destroy:function(){this._clearVariablesAndEvents();this.rootWidget().destroy();this._superApply(arguments)}});$.extend($.ui.igHierarchicalGrid,{version:"21.2.12"});return $});