Spry.Data.NestedXMLDataSet=function(a,b,c){this.parentDataSet=a;this.xpath=b;this.nestedDataSets=[];this.nestedDataSetsHash={};this.currentDS=null;this.currentDSAncestor=null;this.options=c;this.ignoreOnDataChanged=false;Spry.Data.DataSet.call(this,c);a.addObserver(this)};Spry.Data.NestedXMLDataSet.prototype=new Spry.Data.DataSet();Spry.Data.NestedXMLDataSet.prototype.constructor=Spry.Data.NestedXMLDataSet.prototype;Spry.Data.NestedXMLDataSet.prototype.getParentDataSet=function(){return this.parentDataSet};Spry.Data.NestedXMLDataSet.prototype.getNestedDataSetForParentRow=function(f){var d=f.ds_XMLNode;if(d&&this.nestedDataSets){if(this.currentDSAncestor&&this.currentDSAncestor==d){return this.currentDS}var b=this.nestedDataSets;var a=b.length;for(var c=0;c<a;c++){var e=b[c];if(e&&d==e.ancestor){return e.dataSet}}}return null};Spry.Data.NestedXMLDataSet.prototype.getNestedXMLDataSetsArray=function(){var d=[];if(this.nestedDataSets){var a=this.nestedDataSets;var b=this.nestedDataSets.length;for(var c=0;c<b;c++){d.push(a[c].dataSet)}}return d};Spry.Data.NestedXMLDataSet.prototype.onDataChanged=function(a,b){if(!this.ignoreOnDataChanged){this.loadData()}};Spry.Data.NestedXMLDataSet.prototype.onCurrentRowChanged=function(c,d){this.notifyObservers("onPreParentContextChange");this.currentDS=null;this.currentDSAncestor=null;var b=this.parentDataSet.getCurrentRow();if(b){var a=this.getNestedDataSetForParentRow(b);if(a){this.currentDS=a;this.currentDSAncestor=b.ds_XMLNode}}this.notifyObservers("onDataChanged");this.notifyObservers("onPostParentContextChange");this.ignoreOnDataChanged=false};Spry.Data.NestedXMLDataSet.prototype.onPostParentContextChange=Spry.Data.NestedXMLDataSet.prototype.onCurrentRowChanged;Spry.Data.NestedXMLDataSet.prototype.onPreParentContextChange=function(a,b){this.ignoreOnDataChanged=true};Spry.Data.NestedXMLDataSet.prototype.loadData=function(){var o=this.parentDataSet;if(!o||o.getLoadDataRequestIsPending()||!o.getDataWasLoaded()||!this.xpath){return}this.notifyObservers("onPreLoad");this.nestedDataSets=[];this.currentDS=null;this.currentDSAncestor=null;this.data=[];this.dataHash={};var p=this;var d=[o];if(o.getNestedXMLDataSetsArray){d=o.getNestedXMLDataSetsArray()}var c=null;var k=o.getCurrentRow();if(k){c=k.ds_XMLNode}var m=d.length;for(var g=0;g<m;g++){var n=d[g];var e=n.getData(true);if(e){var h=e.length;for(var f=0;f<h;f++){var q=e[f];if(q&&q.ds_XMLNode){var b=new Spry.Data.DataSet(this.options);var a=Spry.Utils.getRecordSetFromXMLDoc(q.ds_XMLNode,this.xpath);b.setDataFromArray(a.data,true);var l=new Object;l.ancestor=q.ds_XMLNode;l.dataSet=b;this.nestedDataSets.push(l);if(q.ds_XMLNode==c){this.currentDS=b;this.currentDSAncestor=this.ds_XMLNode}b.addObserver(function(r,i,j){p.notifyObservers(r,j)})}}}}this.pendingRequest=new Object;this.dataWasLoaded=false;this.pendingRequest.timer=setTimeout(function(){p.pendingRequest=null;p.dataWasLoaded=true;p.notifyObservers("onPostLoad");p.notifyObservers("onDataChanged")},0)};Spry.Data.NestedXMLDataSet.prototype.getData=function(a){if(this.currentDS){return this.currentDS.getData(a)}return[]};Spry.Data.NestedXMLDataSet.prototype.getRowCount=function(a){if(this.currentDS){return this.currentDS.getRowCount(a)}return 0};Spry.Data.NestedXMLDataSet.prototype.getRowByID=function(a){if(this.currentDS){return this.currentDS.getRowByID(a)}return undefined};Spry.Data.NestedXMLDataSet.prototype.getRowByRowNumber=function(a,b){if(this.currentDS){return this.currentDS.getRowByRowNumber(a,b)}return null};Spry.Data.NestedXMLDataSet.prototype.getCurrentRow=function(){if(this.currentDS){return this.currentDS.getCurrentRow()}return null};Spry.Data.NestedXMLDataSet.prototype.setCurrentRow=function(a){if(this.currentDS){return this.currentDS.setCurrentRow(a)}};Spry.Data.NestedXMLDataSet.prototype.getRowNumber=function(a){if(this.currentDS){return this.currentDS.getRowNumber(a)}return 0};Spry.Data.NestedXMLDataSet.prototype.getCurrentRowNumber=function(){if(this.currentDS){return this.currentDS.getCurrentRowNumber()}return 0};Spry.Data.NestedXMLDataSet.prototype.getCurrentRowID=function(){if(this.currentDS){return this.currentDS.getCurrentRowID()}return 0};Spry.Data.NestedXMLDataSet.prototype.setCurrentRowNumber=function(a){if(this.currentDS){return this.currentDS.setCurrentRowNumber(a)}};Spry.Data.NestedXMLDataSet.prototype.findRowsWithColumnValues=function(c,b,a){if(this.currentDS){return this.currentDS.findRowsWithColumnValues(c,b,a)}return b?null:[]};Spry.Data.NestedXMLDataSet.prototype.setColumnType=function(e,c){if(e){var d=this.nestedDataSets;var a=d.length;for(var b=0;b<a;b++){d[b].dataSet.setColumnType(e,c)}}};Spry.Data.NestedXMLDataSet.prototype.getColumnType=function(a){if(this.currentDS){return this.currentDS.getColumnType(a)}return"string"};Spry.Data.NestedXMLDataSet.prototype.distinct=function(d){if(d){var c=this.nestedDataSets;var a=c.length;for(var b=0;b<a;b++){c[b].dataSet.distinct(d)}}};Spry.Data.NestedXMLDataSet.prototype.getSortColumn=function(){if(this.currentDS){return this.currentDS.getSortColumn()}return""};Spry.Data.NestedXMLDataSet.prototype.getSortOrder=function(){if(this.currentDS){return this.currentDS.getSortOrder()}return""};Spry.Data.NestedXMLDataSet.prototype.sort=function(e,c){if(e){var d=this.nestedDataSets;var a=d.length;for(var b=0;b<a;b++){d[b].dataSet.sort(e,c)}}};Spry.Data.NestedXMLDataSet.prototype.filterData=function(d,c){if(columnNames){var e=this.nestedDataSets;var a=e.length;for(var b=0;b<a;b++){e[b].dataSet.filterData(d,c)}}};Spry.Data.NestedXMLDataSet.prototype.filter=function(d,c){if(columnNames){var e=this.nestedDataSets;var a=e.length;for(var b=0;b<a;b++){e[b].dataSet.filter(d,c)}}};
