{"version":3,"sources":["kendo.pivotgrid.js"],"names":["f","define","$","undefined","normalizeMeasures","measure","descriptor","name","descriptors","toString","call","map","d","type","normalizeMembers","member","expand","slice","normalizeName","indexOf","accumulateMembers","accumulator","rootTuple","tuple","level","idx","length","children","members","kendo","stringify","buildPath","descriptorsForAxes","tuples","k","result","push","parseJSON","addMissingPathMembers","axis","tupleMembers","found","j","firstTuple","getName","hierarchy","tupleToDescriptors","descriptorsForMembers","measures","tupletoSearch","MEASURES","findExistingTuple","createAggregateGetter","m","measureGetter","getter","field","aggregatorContext","state","aggregate","dataItem","isNumber","val","isNaN","isDate","getTime","flatColumns","columns","concat","sortItemsTree","items","sortFunction","i","parentName","sort","fillSortTree","currentItem","isEmptyObject","childrenMap","extend","addEmptyDataItem","value","fmtValue","ordinal","validateAxis","newAxis","membersCount","adjustDataByColumn","sourceTuples","targetTuples","rowsLength","data","columnIdx","rowIdx","dataIdx","columnsLength","targetColumnsLength","measuresLength","tupleIndex","adjustDataByRow","collection","index","queue","current","shift","apply","normalizeAxis","findDataIndex","memberIndex","counter","Math","max","mergeTuples","target","source","targetMembers","sourceMembers","parsedRoot","equalTuples","first","second","equal","toFind","membersLength","addMembers","len","path","findParentMember","parentMember","parentPath","measurePosition","normalizeTupleMeasures","dataIndex","splice","parseSource","measureIndex","prepareDataOnRows","indices","rowIndex","columnIndex","targetIndex","sourceIndex","calcIndex","buildDataIndices","parseInt","prepareDataOnColumns","spliceIndex","baseHierarchyPath","memberName","parts","split","expandMemberDescriptor","names","sortDescriptor","sortDescriptorForMember","dir","crossJoin","r","pop","crossJoinCommand","tmp","measureNames","join","getRootNames","mapNames","rootNames","rootName","rootLength","expandedIdx","uniquePath","parseDescriptors","l","hierarchyName","expanded","child","root","serializeMembers","crossJoinCommands","command","serializeExpression","expression","operator","format","filterFunctionFormats","serializeFilters","filter","cube","filters","serializeOptions","parentTagName","options","capitalize","key","replace","toUpperCase","asArray","object","translateAxis","memberIdx","captionGetter","unameGetter","levelNameGetter","levelNumGetter","childrenGetter","hierarchyGetter","parentNameGetter","Member","caption","levelName","levelNum","hasChildren","xmlaDiscoverCommands","convertersMap","XmlaTransport","schemaDataReaderMap","xmlaReaderMethods","XmlaDataReader","sortExpr","removeExpr","PivotGrid","element","htmlNode","createMetadata","tupleName","ColumnBuilder","RowBuilder","ContentBuilder","PivotExcelMixin","window","ui","Class","Comparer","Widget","DataSource","outerWidth","_outerWidth","outerHeight","_outerHeight","identity","o","isFunction","CHANGE","ERROR","PROGRESS","STATERESET","AUTO","DIV","NS","ROW_TOTAL_KEY","DATABINDING","DATABOUND","EXPANDMEMBER","COLLAPSEMEMBER","STATE_EXPANDED","STATE_COLLAPSED","HEADER_TEMPLATE","KPISTATUS_TEMPLATE","KPITREND_TEMPLATE","DATACELL_TEMPLATE","LAYOUT_TABLE","AXIS_ROWS","AXIS_COLUMNS","functions","sum","count","average","min","PivotCubeBuilder","init","this","dimensions","_normalizeDescriptors","keyField","fields","_rootTuples","measureAggregators","aggregatorsLength","dimensionsSchema","measureIdx","rootNamesLength","keys","_sortMap","sortDescriptors","mapItem","sortedMaps","sortTree","flattenTree","directParentName","create","_expandedTuples","currentKeys","memberInfo","expandedNames","accumulatorKeys","_findExpandedMember","_asTuples","rootInfo","expandedInfo","_measuresInfo","rowAxis","aggregateNames","resultFuncs","formats","_toDataArray","measuresInfo","rowKeys","columnKeys","aggregates","n","row","column","columnKey","columnMeasureNames","rowMeasureNamesLength","rowMeasureNames","rowLength","columnLength","_addData","resultFunc","_matchDescriptors","getters","parentField","expectedValue","_calculateAggregate","totalItem","aggregator","_processColumns","rowTotal","updateColumn","_measureAggregators","defaultAggregate","measureDescriptors","aggregators","toLowerCase","Error","_buildGetters","_parseDescriptors","parsedDescriptors","_filter","expr","_normalizeFilter","Query","logic","process","measuresRowAxis","columnDescriptors","rowDescriptors","aggregatedData","rows","rowValue","columnGetters","rowGetters","processed","expandedColumns","expandedRows","hasExpandedRows","rowDescriptor","rowName","columnsInfo","rowsInfo","measuresAxis","axes","PivotTransport","transport","discover","read","update","destroy","success","catalog","connection","PivotDataSource","schema","cubes","catalogs","hierarchies","levels","_cubeSchema","cubeBuilder","fn","_columns","_rows","values","_measures","_measuresAxis","_skipNormalize","_axes","uniqueName","defaultHierarchy","proxy","response","restrictions","levelUniqueName","memberUniqueName","schemaData","dataGetter","_rawData","distinct","treeOp","childrenCardinality","dimensionUniqueName","hierarchyUniqueName","serverSorting","serverPaging","serverFiltering","serverGrouping","serverAggregates","_mergeState","_clearAxesData","query","rowsAxisDescriptors","columnsAxisDescriptors","_expandPath","origin","other","memberToExpand","_lastExpanded","_descriptorsForAxis","_query","_process","e","_view","trigger","that","page","pageSize","group","_data","_params","_updateLocalData","_pristineData","Deferred","resolve","promise","expandColumn","expandRow","originalData","reader","_processResult","processedData","columnIndexes","rowIndexes","resultAxis","axisToSkip","hasColumnTuples","_requestData","_rowMeasures","_normalizeTuples","_columnMeasures","_normalizeData","_mergeAxes","_readData","newData","_createTuple","buildRoot","_hasRoot","isRoot","sourceAxes","startIndex","mergedColumns","mergedRows","offset","columnMeasures","rowMeasures","oldRowsLength","newRowsLength","oldColumnsLength","newColumnsLength","_mergeColumnData","_mergeRowData","toAdd","toJSON","drop","_observe","_ranges","_addRange","_total","_pristineTotal","last","roots","indexes","_addMissingDataItems","metadata","_normalizeOrdinals","lastOrdinal","converter","deferred","parse","_handleCustomErrors","error","status","reject","done","schemaMeasures","catalogName","cubeName","schemaKPIs","kpis","schemaDimensions","schemaHierarchies","dimensionName","schemaLevels","schemaCubes","schemaCatalogs","schemaMembers","dataSource","contains","doesnotcontain","startswith","endswith","eq","neq","properties","Catalog","RemoteTransport","originalOptions","url","setup","dataType","contentType","parameterMap","ajax","description","groupName","displayFolder","defaultFormat","goal","trend","statusGraphic","trendGraphic","defaultMember","orderingProperty","XmlDataReader","_extend","methodName","option","xml","errors","fault","faultstring","faultcode","cells","ordinalGetter","valueGetter","fmtValueGetter","_mapSchema","obj","transports","xmla","readers","expressions","PivotSettingTarget","addClass","_refreshHandler","refresh","template","ns","enabled","emptyTemplate","_sortable","on","closest","attr","hasClass","remove","sortable","currentTarget","find","filterable","fieldMenu","PivotFieldMenu","messages","setting","empty","setDataSource","unbind","kendoSortable","connectWith","hint","cursor","start","item","focus","blur","change","action","add","move","newIndex","_indexOf","_isKPI","validate","isMeasure","isArray","sortExpressions","_sort","allowUnsort","skipExpr","html","sortIcon","_sortIcon","off","icon","columnBuilder","rowBuilder","_dataSource","_bindConfigurator","_wrapper","_createLayout","_columnBuilder","_rowBuilder","_contentBuilder","_templates","columnsHeader","rowsHeader","eventName","request","button","builder","eventArgs","parent","is","childrenLoaded","maxChildren","toggleClass","_scrollable","autoBind","fetch","notify","events","reorderable","height","columnWidth","configurator","columnHeaderTemplate","rowHeaderTemplate","dataCellTemplate","kpiStatusTemplate","kpiTrendTemplate","measureFields","columnFields","rowFields","columnTemplate","rowTemplate","dataTemplate","useWithBlock","kendoPivotConfigurator","cellInfoByElement","cellInfo","contentBuilder","columnInfo","rowInfo","columnTuple","rowTuple","view","measuresTarget","rowsTarget","columnsTarget","setOptions","clearTimeout","_headerReflowTimeout","_stateResetHandler","_progressHandler","_errorHandler","_requestStart","_stateReset","_error","bind","_progress","reset","wrapper","css","_measureFields","_createSettingTarget","icons","_initSettingTargets","layoutTable","leftContainer","rightContainer","gridWrapper","wrap","support","scrollbar","content","append","columnsHeaderTree","dom","Tree","rowsHeaderTree","contentTree","toggle","progress","_resize","firstChild","_setSectionsWidth","_setSectionsHeight","_setContentWidth","_setContentHeight","_columnHeaderReflow","columnTable","browser","mozilla","setTimeout","leftColumn","width","measureFieldsHeight","columnFieldsHeight","rowFieldsHeight","innerHeight","columnsHeight","padding","firstRowHeight","secondRowHeight","contentTable","calculatedWidth","minWidth","ceil","_resetColspan","skipScrollbar","offsetHeight","clientHeight","cell","_colspan","_layoutTimeout","_axisMeasures","hasMeasure","touchScroller","columnAxis","render","build","_indexes","contentResized","movable","scrollLeft","sender","x","scrollTop","y","scroll","_wheelScroll","delta","ctrlKey","wheelDeltaY","preventDefault","one","maxMembers","tbody","_tbody","colgroup","_colGroup","_rowLength","_buildRows","_normalize","cellsLength","cellIdx","rowSpan","tupleAll","_rowIndex","colSpan","_row","parentRow","rowKey","notFirst","collapsed","className","measureRow","_cell","_content","childRow","childrenLength","allCell","cellAttr","nextMember","cellChildren","memberCollapsed","rootLevelNum","maxcolSpan","allRow","firstMemberName","expandIconAttr","tuplePath","hasChild","axisInfo","total","axisInfoMember","skipChildren","firstEmpty","_buildRow","templateInfo","cellContent","startIdx","plugin","PivotExcelExporter","widget","columnHeaderTable","rowHeaderTable","columnHeaderLength","rowHeaderLength","autoWidth","_cells","callback","background","color","dataCallback","rowRows","columnHeaderRows","rowHeaderRows","contentRows","columnRows","_freezePane","colSplit","rowSplit","workbook","then","sheets","freezePane","proto","excel","saveAsExcel","proxyURL","fileName","exporter","book","ooxml","Workbook","toDataURLAsync","dataURI","saveAs","forceProxy","prototype","PDFMixin","_drawPDF","_drawPDFShadow","avoidLinks","pdf","jQuery","amd","a1","a2","a3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAwBC,SAAUA,EAAGC,QACVA,OAAO,mBACH,YACA,cACDD,IACL,WAgnIE,MAhkIC,UAAUE,EAAGC,GAMV,QAASC,GAAkBC,GAA3B,GACQC,GAAgC,gBAAZD,KAA0BE,KAAMF,IAAaA,EACjEG,EAA4C,mBAA9BC,GAASC,KAAKJ,GAAmCA,EAAaA,IAAeH,GAAaG,KAC5G,OAAOK,IAAIH,EAAa,SAAUI,GAC9B,MAAiB,gBAANA,IACEL,KAAMK,IAGfL,KAAMK,EAAEL,KACRM,KAAMD,EAAEC,QAIpB,QAASC,GAAiBC,GAA1B,GACQT,GAA+B,gBAAXS,KAChBR,MAAOQ,GACPC,QAAQ,IACPD,EACLP,EAA4C,mBAA9BC,GAASC,KAAKJ,GAAmCA,EAAaA,IAAeH,GAAaG,KAC5G,OAAOK,IAAIH,EAAa,SAAUI,GAC9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AAIC,IACrEA,GAAMD","file":"kendo.pivotgrid.min.js","sourcesContent":["/*!\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n*/\n(function (f, define) {\n define('kendo.pivotgrid', [\n 'kendo.dom',\n 'kendo.data'\n ], f);\n}(function () {\n var __meta__ = {\n id: 'pivotgrid',\n name: 'PivotGrid',\n category: 'web',\n description: 'The PivotGrid widget is a data summarization tool.',\n depends: [\n 'dom',\n 'data',\n 'data.xml',\n 'sortable'\n ],\n features: [\n {\n id: 'pivotgrid-configurator',\n name: 'Configurator',\n description: 'The PivotConfigurator widget allows the user to select data slices displayed in PivotGrid',\n depends: ['pivot.configurator']\n },\n {\n id: 'pivotgrid-filtering',\n name: 'Filtering',\n description: 'Support for filtering',\n depends: ['pivot.fieldmenu']\n },\n {\n id: 'pivotgrid-excel-export',\n name: 'Excel export',\n description: 'Export pivot grid data as Excel spreadsheet',\n depends: ['ooxml']\n },\n {\n id: 'pivotgrid-pdf-export',\n name: 'PDF export',\n description: 'Export pivot grid data as PDF',\n depends: [\n 'pdf',\n 'drawing'\n ]\n },\n {\n id: 'mobile-scroller',\n name: 'Mobile scroller',\n description: 'Support for kinetic scrolling in mobile device',\n depends: ['mobile.scroller']\n }\n ]\n };\n (function ($, undefined) {\n var kendo = window.kendo, ui = kendo.ui, Class = kendo.Class, Comparer = kendo.data.Comparer, Widget = ui.Widget, DataSource = kendo.data.DataSource, outerWidth = kendo._outerWidth, outerHeight = kendo._outerHeight, toString = {}.toString, identity = function (o) {\n return o;\n }, map = $.map, extend = $.extend, isFunction = kendo.isFunction, CHANGE = 'change', ERROR = 'error', MEASURES = 'Measures', PROGRESS = 'progress', STATERESET = 'stateReset', AUTO = 'auto', DIV = '
', NS = '.kendoPivotGrid', ROW_TOTAL_KEY = '__row_total__', DATABINDING = 'dataBinding', DATABOUND = 'dataBound', EXPANDMEMBER = 'expandMember', COLLAPSEMEMBER = 'collapseMember', STATE_EXPANDED = 'k-i-collapse', STATE_COLLAPSED = 'k-i-expand', HEADER_TEMPLATE = '#: data.member.caption || data.member.name #', KPISTATUS_TEMPLATE = ' 0 ? \"open\" : data.dataItem.value < 0 ? \"deny\" : \"hold\"#\" title=\"#:data.dataItem.value#\">', KPITREND_TEMPLATE = ' 0 ? \"increase\" : data.dataItem.value < 0 ? \"decrease\" : \"equal\"#\" title=\"#:data.dataItem.value#\">', DATACELL_TEMPLATE = '#= data.dataItem ? kendo.htmlEncode(data.dataItem.fmtValue || data.dataItem.value) || \" \" : \" \" #', LAYOUT_TABLE = '' + '' + '' + '' + '' + '
' + '
' + '
' + '
' + '
';\n var AXIS_ROWS = 'rows';\n var AXIS_COLUMNS = 'columns';\n function normalizeMeasures(measure) {\n var descriptor = typeof measure === 'string' ? [{ name: measure }] : measure;\n var descriptors = toString.call(descriptor) === '[object Array]' ? descriptor : descriptor !== undefined ? [descriptor] : [];\n return map(descriptors, function (d) {\n if (typeof d === 'string') {\n return { name: d };\n }\n return {\n name: d.name,\n type: d.type\n };\n });\n }\n function normalizeMembers(member) {\n var descriptor = typeof member === 'string' ? [{\n name: [member],\n expand: false\n }] : member;\n var descriptors = toString.call(descriptor) === '[object Array]' ? descriptor : descriptor !== undefined ? [descriptor] : [];\n return map(descriptors, function (d) {\n if (typeof d === 'string') {\n return {\n name: [d],\n expand: false\n };\n }\n return {\n name: toString.call(d.name) === '[object Array]' ? d.name.slice() : [d.name],\n expand: d.expand\n };\n });\n }\n function normalizeName(name) {\n if (name.indexOf(' ') !== -1) {\n name = '[\"' + name + '\"]';\n }\n return name;\n }\n function accumulateMembers(accumulator, rootTuple, tuple, level) {\n var idx, length;\n var children;\n var member;\n if (!tuple) {\n tuple = rootTuple;\n }\n if (!level) {\n level = 0;\n }\n member = tuple.members[level];\n if (!member || member.measure) {\n return;\n }\n children = member.children;\n length = children.length;\n if (tuple === rootTuple) {\n accumulator[kendo.stringify([member.name])] = !!length;\n } else if (length) {\n accumulator[kendo.stringify(buildPath(tuple, level))] = true;\n }\n if (length) {\n for (idx = 0; idx < length; idx++) {\n accumulateMembers(accumulator, rootTuple, children[idx], level);\n }\n }\n accumulateMembers(accumulator, rootTuple, tuple, level + 1);\n }\n function descriptorsForAxes(tuples) {\n var result = {};\n if (tuples.length) {\n accumulateMembers(result, tuples[0]);\n }\n var descriptors = [];\n for (var k in result) {\n descriptors.push({\n name: $.parseJSON(k),\n expand: result[k]\n });\n }\n return descriptors;\n }\n function addMissingPathMembers(members, axis) {\n var tuples = axis.tuples || [];\n var firstTuple = tuples[0];\n if (firstTuple && members.length < firstTuple.members.length) {\n var tupleMembers = firstTuple.members;\n for (var idx = 0; idx < tupleMembers.length; idx++) {\n if (tupleMembers[idx].measure) {\n continue;\n }\n var found = false;\n for (var j = 0; j < members.length; j++) {\n if (getName(members[j]).indexOf(tupleMembers[idx].hierarchy) === 0) {\n found = true;\n break;\n }\n }\n if (!found) {\n members.push({\n name: [tupleMembers[idx].name],\n expand: false\n });\n }\n }\n }\n }\n function tupleToDescriptors(tuple) {\n var result = [];\n var members = tuple.members;\n for (var idx = 0; idx < members.length; idx++) {\n if (members[idx].measure) {\n continue;\n }\n result.push({\n name: [members[idx].name],\n expand: members[idx].children.length > 0\n });\n }\n return result;\n }\n function descriptorsForMembers(axis, members, measures) {\n axis = axis || {};\n addMissingPathMembers(members, axis);\n if (measures.length > 1) {\n members.push({\n name: MEASURES,\n measure: true,\n children: normalizeMembers(measures)\n });\n }\n var tupletoSearch = { members: members };\n if (axis.tuples) {\n var result = findExistingTuple(axis.tuples, tupletoSearch);\n if (result.tuple) {\n members = tupleToDescriptors(result.tuple);\n }\n }\n return members;\n }\n function createAggregateGetter(m) {\n var measureGetter = kendo.getter(m.field, true);\n return function (aggregatorContext, state) {\n return m.aggregate(measureGetter(aggregatorContext.dataItem), state, aggregatorContext);\n };\n }\n function isNumber(val) {\n return typeof val === 'number' && !isNaN(val);\n }\n function isDate(val) {\n return val && val.getTime;\n }\n var functions = {\n sum: function (value, state) {\n var accumulator = state.accumulator;\n if (!isNumber(accumulator)) {\n accumulator = value;\n } else if (isNumber(value)) {\n accumulator += value;\n }\n return accumulator;\n },\n count: function (value, state) {\n return (state.accumulator || 0) + 1;\n },\n average: {\n aggregate: function (value, state) {\n var accumulator = state.accumulator;\n if (state.count === undefined) {\n state.count = 0;\n }\n if (!isNumber(accumulator)) {\n accumulator = value;\n } else if (isNumber(value)) {\n accumulator += value;\n }\n if (isNumber(value)) {\n state.count++;\n }\n return accumulator;\n },\n result: function (state) {\n var accumulator = state.accumulator;\n if (isNumber(accumulator)) {\n accumulator = accumulator / state.count;\n }\n return accumulator;\n }\n },\n max: function (value, state) {\n var accumulator = state.accumulator;\n if (!isNumber(accumulator) && !isDate(accumulator)) {\n accumulator = value;\n }\n if (accumulator < value && (isNumber(value) || isDate(value))) {\n accumulator = value;\n }\n return accumulator;\n },\n min: function (value, state) {\n var accumulator = state.accumulator;\n if (!isNumber(accumulator) && !isDate(accumulator)) {\n accumulator = value;\n }\n if (accumulator > value && (isNumber(value) || isDate(value))) {\n accumulator = value;\n }\n return accumulator;\n }\n };\n var PivotCubeBuilder = Class.extend({\n init: function (options) {\n this.options = extend({}, this.options, options);\n this.dimensions = this._normalizeDescriptors('field', this.options.dimensions);\n this.measures = this._normalizeDescriptors('name', this.options.measures);\n },\n _normalizeDescriptors: function (keyField, descriptors) {\n descriptors = descriptors || {};\n var fields = {};\n var field;\n if (toString.call(descriptors) === '[object Array]') {\n for (var idx = 0, length = descriptors.length; idx < length; idx++) {\n field = descriptors[idx];\n if (typeof field === 'string') {\n fields[field] = {};\n } else if (field[keyField]) {\n fields[field[keyField]] = field;\n }\n }\n descriptors = fields;\n }\n return descriptors;\n },\n _rootTuples: function (rootNames, measureAggregators) {\n var aggregatorsLength = measureAggregators.length || 1;\n var dimensionsSchema = this.dimensions || [];\n var root, name, parts;\n var measureIdx = 0;\n var idx;\n var rootNamesLength = rootNames.length;\n var result = [];\n var keys = [];\n if (rootNamesLength || measureAggregators.length) {\n for (measureIdx = 0; measureIdx < aggregatorsLength; measureIdx++) {\n root = { members: [] };\n for (idx = 0; idx < rootNamesLength; idx++) {\n name = rootNames[idx];\n parts = name.split('&');\n root.members[root.members.length] = {\n children: [],\n caption: (dimensionsSchema[name] || {}).caption || 'All',\n name: name,\n levelName: name,\n levelNum: '0',\n hasChildren: true,\n parentName: parts.length > 1 ? parts[0] : undefined,\n hierarchy: name\n };\n }\n if (aggregatorsLength > 1) {\n root.members[root.members.length] = {\n children: [],\n caption: measureAggregators[measureIdx].caption,\n name: measureAggregators[measureIdx].descriptor.name,\n levelName: 'MEASURES',\n levelNum: '0',\n hasChildren: false,\n parentName: undefined,\n hierarchy: 'MEASURES'\n };\n }\n result[result.length] = root;\n }\n keys.push(ROW_TOTAL_KEY);\n }\n return {\n keys: keys,\n tuples: result\n };\n },\n _sortMap: function (map, sortDescriptors) {\n var sortedMaps = [];\n var sortTree = [];\n var flattenTree = [];\n var mapItem;\n var key;\n for (key in map) {\n if (!map[key].directParentName) {\n sortTree.push($.extend({}, {\n name: key,\n parentName: map[key].parentName\n }));\n }\n }\n if (!sortTree.length) {\n for (key in map) {\n sortTree.push($.extend({}, {\n name: key,\n parentName: map[key].parentName\n }));\n }\n }\n fillSortTree(sortTree, map);\n for (var i = 0; i < sortDescriptors.length; i++) {\n sortItemsTree(sortDescriptors[i].field.split('.').pop(), sortTree, Comparer.create({\n field: 'name',\n dir: sortDescriptors[i].dir\n }));\n }\n flattenTree = flatColumns(sortTree);\n for (var j = 0; j < flattenTree.length; j++) {\n mapItem = map[flattenTree[j].name];\n mapItem.index = j;\n sortedMaps[j] = mapItem;\n }\n return sortedMaps;\n },\n _expandedTuples: function (map, expanded, measureAggregators, sortDescriptors) {\n var aggregatorsLength = measureAggregators.length || 1;\n var dimensionsSchema = this.dimensions || [];\n var measureIdx;\n var tuple;\n var key;\n var mapItem;\n var current;\n var currentKeys;\n var accumulator = [];\n var accumulatorKeys = [];\n var memberInfo;\n var expandedNames;\n var parts;\n var name;\n var idx;\n if (sortDescriptors && sortDescriptors.length && !$.isEmptyObject(map)) {\n map = this._sortMap(map, sortDescriptors);\n }\n for (key in map) {\n mapItem = map[key];\n memberInfo = this._findExpandedMember(expanded, mapItem.uniquePath);\n current = accumulator[memberInfo.index] || [];\n currentKeys = accumulatorKeys[memberInfo.index] || [];\n expandedNames = memberInfo.member.names;\n for (measureIdx = 0; measureIdx < aggregatorsLength; measureIdx++) {\n tuple = { members: [] };\n for (idx = 0; idx < expandedNames.length; idx++) {\n if (idx === memberInfo.member.expandedIdx) {\n tuple.members[tuple.members.length] = {\n children: [],\n caption: mapItem.value,\n name: mapItem.name,\n hasChildren: false,\n levelNum: 1,\n levelName: mapItem.parentName + mapItem.name,\n parentName: mapItem.parentName,\n hierarchy: mapItem.parentName + mapItem.name\n };\n if (measureIdx === 0) {\n currentKeys.push(buildPath(tuple, idx).join(''));\n }\n } else {\n name = expandedNames[idx];\n parts = name.split('&');\n tuple.members[tuple.members.length] = {\n children: [],\n caption: (dimensionsSchema[name] || {}).caption || 'All',\n name: name,\n levelName: name,\n levelNum: '0',\n hasChildren: true,\n parentName: parts.length > 1 ? parts[0] : undefined,\n hierarchy: name\n };\n }\n }\n if (aggregatorsLength > 1) {\n tuple.members[tuple.members.length] = {\n children: [],\n caption: measureAggregators[measureIdx].caption,\n name: measureAggregators[measureIdx].descriptor.name,\n levelName: 'MEASURES',\n levelNum: '0',\n hasChildren: true,\n parentName: undefined,\n hierarchy: 'MEASURES'\n };\n }\n current[current.length] = tuple;\n }\n accumulator[memberInfo.index] = current;\n accumulatorKeys[memberInfo.index] = currentKeys;\n }\n return {\n keys: accumulatorKeys,\n tuples: accumulator\n };\n },\n _findExpandedMember: function (members, parentName) {\n for (var idx = 0; idx < members.length; idx++) {\n if (members[idx].uniquePath === parentName) {\n return {\n member: members[idx],\n index: idx\n };\n }\n }\n },\n _asTuples: function (map, descriptor, measureAggregators, sortDescriptors) {\n measureAggregators = measureAggregators || [];\n var rootInfo = this._rootTuples(descriptor.root, measureAggregators);\n var expandedInfo = this._expandedTuples(map, descriptor.expanded, measureAggregators, sortDescriptors);\n return {\n keys: [].concat.apply(rootInfo.keys, expandedInfo.keys),\n tuples: [].concat.apply(rootInfo.tuples, expandedInfo.tuples)\n };\n },\n _measuresInfo: function (measures, rowAxis) {\n var idx = 0;\n var length = measures && measures.length;\n var aggregateNames = [];\n var resultFuncs = {};\n var formats = {};\n var descriptors = this.measures || {};\n var measure;\n var name;\n for (; idx < length; idx++) {\n name = measures[idx].descriptor.name;\n measure = descriptors[name] || {};\n aggregateNames.push(name);\n if (measure.result) {\n resultFuncs[name] = measure.result;\n }\n if (measure.format) {\n formats[name] = measure.format;\n }\n }\n return {\n names: aggregateNames,\n formats: formats,\n resultFuncs: resultFuncs,\n rowAxis: rowAxis\n };\n },\n _toDataArray: function (map, measuresInfo, rowKeys, columnKeys) {\n var result = [];\n var aggregates;\n var name, i, j, k, n;\n var row, column, columnKey;\n var rowMeasureNamesLength = 1;\n var rowMeasureNames = [];\n var columnMeasureNames;\n var rowLength = rowKeys.length || 1;\n var columnLength = columnKeys.length || 1;\n if (measuresInfo.rowAxis) {\n rowMeasureNames = measuresInfo.names;\n rowMeasureNamesLength = rowMeasureNames.length;\n } else {\n columnMeasureNames = measuresInfo.names;\n }\n for (i = 0; i < rowLength; i++) {\n row = map[rowKeys[i] || ROW_TOTAL_KEY];\n for (n = 0; n < rowMeasureNamesLength; n++) {\n if (measuresInfo.rowAxis) {\n columnMeasureNames = [rowMeasureNames[n]];\n }\n for (j = 0; j < columnLength; j++) {\n columnKey = columnKeys[j] || ROW_TOTAL_KEY;\n column = row.items[columnKey];\n if (columnKey === ROW_TOTAL_KEY) {\n aggregates = row.aggregates;\n } else {\n aggregates = column ? column.aggregates : {};\n }\n for (k = 0; k < columnMeasureNames.length; k++) {\n name = columnMeasureNames[k];\n this._addData(result, aggregates[name], measuresInfo.formats[name], measuresInfo.resultFuncs[name]);\n }\n }\n }\n }\n return result;\n },\n _addData: function (result, value, format, resultFunc) {\n var fmtValue = '';\n var ordinal;\n if (value) {\n value = resultFunc ? resultFunc(value) : value.accumulator;\n fmtValue = format ? kendo.format(format, value) : value;\n }\n ordinal = result.length;\n result[ordinal] = {\n ordinal: ordinal,\n value: value || '',\n fmtValue: fmtValue\n };\n },\n _matchDescriptors: function (dataItem, descriptor, getters) {\n var parts;\n var parentField;\n var expectedValue;\n var names = descriptor.names;\n var idx = descriptor.expandedIdx;\n var value;\n while (idx > 0) {\n parts = names[--idx].split('&');\n if (parts.length > 1) {\n parentField = parts[0];\n expectedValue = parts[1];\n value = getters[parentField](dataItem);\n value = value !== undefined && value !== null ? value.toString() : value;\n if (value != expectedValue) {\n return false;\n }\n }\n }\n return true;\n },\n _calculateAggregate: function (measureAggregators, aggregatorContext, totalItem) {\n var result = {};\n var state;\n var name;\n for (var measureIdx = 0; measureIdx < measureAggregators.length; measureIdx++) {\n name = measureAggregators[measureIdx].descriptor.name;\n state = totalItem.aggregates[name] || {};\n state.accumulator = measureAggregators[measureIdx].aggregator(aggregatorContext, state);\n result[name] = state;\n }\n return result;\n },\n _processColumns: function (measureAggregators, descriptors, getters, columns, aggregatorContext, rowTotal, state, updateColumn) {\n var value;\n var descriptor;\n var column;\n var totalItem;\n var key, name, parentName, path;\n var dataItem = aggregatorContext.dataItem;\n var idx = 0;\n for (; idx < descriptors.length; idx++) {\n descriptor = descriptors[idx];\n if (!this._matchDescriptors(dataItem, descriptor, getters)) {\n continue;\n }\n path = descriptor.names.slice(0, descriptor.expandedIdx).join('');\n name = descriptor.names[descriptor.expandedIdx];\n value = getters[name](dataItem);\n value = value !== undefined && value !== null ? value.toString() : value;\n parentName = name;\n name = name + '&' + value;\n key = path + name;\n column = columns[key] || {\n index: state.columnIndex,\n parentName: parentName,\n name: name,\n directParentName: path.indexOf('&') !== -1 ? path : '',\n uniquePath: path + parentName,\n childrenMap: {},\n value: value\n };\n if (path && columns[path] && !columns[path].childrenMap[path + parentName + '&' + value]) {\n columns[path].childrenMap[path + parentName + '&' + value] = true;\n }\n totalItem = rowTotal.items[key] || { aggregates: {} };\n rowTotal.items[key] = {\n index: column.index,\n aggregates: this._calculateAggregate(measureAggregators, aggregatorContext, totalItem)\n };\n if (updateColumn) {\n if (!columns[key]) {\n state.columnIndex++;\n }\n columns[key] = column;\n }\n }\n },\n _measureAggregators: function (options) {\n var measureDescriptors = options.measures || [];\n var measures = this.measures || {};\n var aggregators = [];\n var descriptor, measure, idx, length;\n var defaultAggregate, aggregate;\n if (measureDescriptors.length) {\n for (idx = 0, length = measureDescriptors.length; idx < length; idx++) {\n descriptor = measureDescriptors[idx];\n measure = measures[descriptor.name];\n defaultAggregate = null;\n if (measure) {\n aggregate = measure.aggregate;\n if (typeof aggregate === 'string') {\n defaultAggregate = functions[aggregate.toLowerCase()];\n if (!defaultAggregate) {\n throw new Error('There is no such aggregate function');\n }\n measure.aggregate = defaultAggregate.aggregate || defaultAggregate;\n measure.result = defaultAggregate.result;\n }\n aggregators.push({\n descriptor: descriptor,\n caption: measure.caption,\n result: measure.result,\n aggregator: createAggregateGetter(measure)\n });\n }\n }\n } else {\n aggregators.push({\n descriptor: { name: 'default' },\n caption: 'default',\n aggregator: function () {\n return 1;\n }\n });\n }\n return aggregators;\n },\n _buildGetters: function (names) {\n var result = {};\n var parts;\n var name;\n for (var idx = 0; idx < names.length; idx++) {\n name = names[idx];\n parts = name.split('&');\n if (parts.length > 1) {\n result[parts[0]] = kendo.getter(parts[0], true);\n } else {\n result[name] = kendo.getter(normalizeName(name), true);\n }\n }\n return result;\n },\n _parseDescriptors: function (descriptors) {\n var parsedDescriptors = parseDescriptors(descriptors);\n var rootNames = getRootNames(parsedDescriptors.root);\n var expanded = parsedDescriptors.expanded;\n var result = [];\n for (var idx = 0; idx < expanded.length; idx++) {\n result.push(mapNames(expanded[idx].name, rootNames));\n }\n return {\n root: rootNames,\n expanded: result\n };\n },\n _filter: function (data, filter) {\n if (!filter) {\n return data;\n }\n var expr;\n var idx = 0;\n var filters = filter.filters;\n for (; idx < filters.length; idx++) {\n expr = filters[idx];\n if (expr.operator === 'in') {\n filters[idx] = this._normalizeFilter(expr);\n }\n }\n return new kendo.data.Query(data).filter(filter).data;\n },\n _normalizeFilter: function (filter) {\n var value = filter.value.split(',');\n var result = [];\n if (!value.length) {\n return value;\n }\n for (var idx = 0; idx < value.length; idx++) {\n result.push({\n field: filter.field,\n operator: 'eq',\n value: value[idx]\n });\n }\n return {\n logic: 'or',\n filters: result\n };\n },\n process: function (data, options) {\n data = data || [];\n options = options || {};\n data = this._filter(data, options.filter);\n var measures = options.measures || [];\n var measuresRowAxis = options.measuresAxis === 'rows';\n var columnDescriptors = options.columns || [];\n var rowDescriptors = options.rows || [];\n if (!columnDescriptors.length && rowDescriptors.length && (!measures.length || measures.length && measuresRowAxis)) {\n columnDescriptors = rowDescriptors;\n rowDescriptors = [];\n measuresRowAxis = false;\n }\n if (!columnDescriptors.length && !rowDescriptors.length) {\n measuresRowAxis = false;\n }\n if (!columnDescriptors.length && measures.length) {\n columnDescriptors = normalizeMembers(options.measures);\n }\n columnDescriptors = this._parseDescriptors(columnDescriptors);\n rowDescriptors = this._parseDescriptors(rowDescriptors);\n var aggregatedData = {};\n var columns = {};\n var rows = {};\n var rowValue;\n var state = { columnIndex: 0 };\n var measureAggregators = this._measureAggregators(options);\n var columnGetters = this._buildGetters(columnDescriptors.root);\n var rowGetters = this._buildGetters(rowDescriptors.root);\n var processed = false;\n var expandedColumns = columnDescriptors.expanded;\n var expandedRows = rowDescriptors.expanded;\n var dataItem;\n var aggregatorContext;\n var hasExpandedRows = expandedRows.length !== 0;\n var rowIdx, rowDescriptor, rowName, rowTotal;\n var key, path, parentName, value;\n var columnsInfo, rowsInfo;\n var length = data.length;\n var idx = 0;\n if (columnDescriptors.root.length || rowDescriptors.root.length) {\n processed = true;\n for (idx = 0; idx < length; idx++) {\n dataItem = data[idx];\n aggregatorContext = {\n dataItem: dataItem,\n index: idx\n };\n rowTotal = aggregatedData[ROW_TOTAL_KEY] || {\n items: {},\n aggregates: {}\n };\n this._processColumns(measureAggregators, expandedColumns, columnGetters, columns, aggregatorContext, rowTotal, state, !hasExpandedRows);\n rowTotal.aggregates = this._calculateAggregate(measureAggregators, aggregatorContext, rowTotal);\n aggregatedData[ROW_TOTAL_KEY] = rowTotal;\n for (rowIdx = 0; rowIdx < expandedRows.length; rowIdx++) {\n rowDescriptor = expandedRows[rowIdx];\n if (!this._matchDescriptors(dataItem, rowDescriptor, rowGetters)) {\n this._processColumns(measureAggregators, expandedColumns, columnGetters, columns, aggregatorContext, {\n items: {},\n aggregates: {}\n }, state, true);\n continue;\n }\n path = rowDescriptor.names.slice(0, rowDescriptor.expandedIdx).join('');\n rowName = rowDescriptor.names[rowDescriptor.expandedIdx];\n parentName = rowName;\n rowValue = rowGetters[rowName](dataItem);\n rowValue = rowValue !== undefined ? rowValue.toString() : rowValue;\n rowName = rowName + '&' + rowValue;\n key = path + rowName;\n rows[key] = {\n uniquePath: path + parentName,\n parentName: parentName,\n name: rowName,\n value: rowValue\n };\n value = aggregatedData[key] || {\n items: {},\n aggregates: {}\n };\n this._processColumns(measureAggregators, expandedColumns, columnGetters, columns, aggregatorContext, value, state, true);\n value.aggregates = this._calculateAggregate(measureAggregators, aggregatorContext, value);\n aggregatedData[key] = value;\n }\n }\n }\n if (processed && length) {\n if (measureAggregators.length > 1 && (!options.columns || !options.columns.length)) {\n columnDescriptors = {\n root: [],\n expanded: []\n };\n }\n columnsInfo = this._asTuples(columns, columnDescriptors, measuresRowAxis ? [] : measureAggregators, options.sort ? options.sort : []);\n rowsInfo = this._asTuples(rows, rowDescriptors, measuresRowAxis ? measureAggregators : [], options.sort ? options.sort : []);\n columns = columnsInfo.tuples;\n rows = rowsInfo.tuples;\n aggregatedData = this._toDataArray(aggregatedData, this._measuresInfo(measureAggregators, measuresRowAxis), rowsInfo.keys, columnsInfo.keys);\n } else {\n aggregatedData = columns = rows = [];\n }\n return {\n axes: {\n columns: { tuples: columns },\n rows: { tuples: rows }\n },\n data: aggregatedData\n };\n }\n });\n var PivotTransport = Class.extend({\n init: function (options, transport) {\n this.transport = transport;\n this.options = transport.options || {};\n if (!this.transport.discover) {\n if (isFunction(options.discover)) {\n this.discover = options.discover;\n }\n }\n },\n read: function (options) {\n return this.transport.read(options);\n },\n update: function (options) {\n return this.transport.update(options);\n },\n create: function (options) {\n return this.transport.create(options);\n },\n destroy: function (options) {\n return this.transport.destroy(options);\n },\n discover: function (options) {\n if (this.transport.discover) {\n return this.transport.discover(options);\n }\n options.success({});\n },\n catalog: function (val) {\n var options = this.options || {};\n if (val === undefined) {\n return (options.connection || {}).catalog;\n }\n var connection = options.connection || {};\n connection.catalog = val;\n this.options.connection = connection;\n $.extend(this.transport.options, { connection: connection });\n },\n cube: function (val) {\n var options = this.options || {};\n if (val === undefined) {\n return (options.connection || {}).cube;\n }\n var connection = options.connection || {};\n connection.cube = val;\n this.options.connection = connection;\n extend(true, this.transport.options, { connection: connection });\n }\n });\n var PivotDataSource = DataSource.extend({\n init: function (options) {\n var cube = ((options || {}).schema || {}).cube;\n var measuresAxis = 'columns';\n var measures;\n var schema = {\n axes: identity,\n cubes: identity,\n catalogs: identity,\n measures: identity,\n dimensions: identity,\n hierarchies: identity,\n levels: identity,\n members: identity\n };\n if (cube) {\n schema = $.extend(schema, this._cubeSchema(cube));\n this.cubeBuilder = new PivotCubeBuilder(cube);\n }\n DataSource.fn.init.call(this, extend(true, {}, { schema: schema }, options));\n this.transport = new PivotTransport(this.options.transport || {}, this.transport);\n this._columns = normalizeMembers(this.options.columns);\n this._rows = normalizeMembers(this.options.rows);\n measures = this.options.measures || [];\n if (toString.call(measures) === '[object Object]') {\n measuresAxis = measures.axis || 'columns';\n measures = measures.values || [];\n }\n this._measures = normalizeMeasures(measures);\n this._measuresAxis = measuresAxis;\n this._skipNormalize = 0;\n this._axes = {};\n },\n _cubeSchema: function (cube) {\n return {\n dimensions: function () {\n var result = [];\n var dimensions = cube.dimensions;\n for (var key in dimensions) {\n result.push({\n name: key,\n caption: dimensions[key].caption || key,\n uniqueName: key,\n defaultHierarchy: key,\n type: 1\n });\n }\n if (cube.measures) {\n result.push({\n name: MEASURES,\n caption: MEASURES,\n uniqueName: MEASURES,\n type: 2\n });\n }\n return result;\n },\n hierarchies: function () {\n return [];\n },\n measures: function () {\n var result = [];\n var measures = cube.measures;\n for (var key in measures) {\n result.push({\n name: key,\n caption: key,\n uniqueName: key,\n aggregator: key\n });\n }\n return result;\n },\n members: $.proxy(function (response, restrictions) {\n var name = restrictions.levelUniqueName || restrictions.memberUniqueName;\n var schemaData = this.options.schema.data;\n var dataGetter = isFunction(schemaData) ? schemaData : kendo.getter(schemaData, true);\n var data = this.options.data && dataGetter(this.options.data) || this._rawData || [];\n var result = [];\n var getter;\n var value;\n var idx = 0;\n var distinct = {};\n if (name) {\n name = name.split('.')[0];\n }\n if (!restrictions.treeOp) {\n result.push({\n caption: cube.dimensions[name].caption || name,\n childrenCardinality: '1',\n dimensionUniqueName: name,\n hierarchyUniqueName: name,\n levelUniqueName: name,\n name: name,\n uniqueName: name\n });\n return result;\n }\n getter = kendo.getter(normalizeName(name), true);\n for (; idx < data.length; idx++) {\n value = getter(data[idx]);\n if ((value || value === 0) && !distinct[value]) {\n distinct[value] = true;\n result.push({\n caption: value,\n childrenCardinality: '0',\n dimensionUniqueName: name,\n hierarchyUniqueName: name,\n levelUniqueName: name,\n name: value,\n uniqueName: value\n });\n }\n }\n return result;\n }, this)\n };\n },\n options: {\n serverSorting: true,\n serverPaging: true,\n serverFiltering: true,\n serverGrouping: true,\n serverAggregates: true\n },\n catalog: function (val) {\n if (val === undefined) {\n return this.transport.catalog();\n }\n this.transport.catalog(val);\n this._mergeState({});\n this._axes = {};\n this.data([]);\n },\n cube: function (val) {\n if (val === undefined) {\n return this.transport.cube();\n }\n this.transport.cube(val);\n this._axes = {};\n this._mergeState({});\n this.data([]);\n },\n axes: function () {\n return this._axes;\n },\n columns: function (val) {\n if (val === undefined) {\n return this._columns;\n }\n this._skipNormalize += 1;\n this._clearAxesData = true;\n this._columns = normalizeMembers(val);\n this.query({\n columns: val,\n rows: this.rowsAxisDescriptors(),\n measures: this.measures(),\n sort: this.sort(),\n filter: this.filter()\n });\n },\n rows: function (val) {\n if (val === undefined) {\n return this._rows;\n }\n this._skipNormalize += 1;\n this._clearAxesData = true;\n this._rows = normalizeMembers(val);\n this.query({\n columns: this.columnsAxisDescriptors(),\n rows: val,\n measures: this.measures(),\n sort: this.sort(),\n filter: this.filter()\n });\n },\n measures: function (val) {\n if (val === undefined) {\n return this._measures;\n }\n this._skipNormalize += 1;\n this._clearAxesData = true;\n this.query({\n columns: this.columnsAxisDescriptors(),\n rows: this.rowsAxisDescriptors(),\n measures: normalizeMeasures(val),\n sort: this.sort(),\n filter: this.filter()\n });\n },\n measuresAxis: function () {\n return this._measuresAxis || 'columns';\n },\n _expandPath: function (path, axis) {\n var origin = axis === 'columns' ? 'columns' : 'rows';\n var other = axis === 'columns' ? 'rows' : 'columns';\n var members = normalizeMembers(path);\n var memberToExpand = getName(members[members.length - 1]);\n this._lastExpanded = origin;\n members = descriptorsForMembers(this.axes()[origin], members, this.measures());\n for (var idx = 0; idx < members.length; idx++) {\n var memberName = getName(members[idx]);\n if (memberName === memberToExpand) {\n if (members[idx].expand) {\n return;\n }\n members[idx].expand = true;\n } else {\n members[idx].expand = false;\n }\n }\n var descriptors = {};\n descriptors[origin] = members;\n descriptors[other] = this._descriptorsForAxis(other);\n this._query(descriptors);\n },\n _descriptorsForAxis: function (axis) {\n var axes = this.axes();\n var descriptors = this[axis]() || [];\n if (axes && axes[axis] && axes[axis].tuples && axes[axis].tuples[0]) {\n descriptors = descriptorsForAxes(axes[axis].tuples || []);\n }\n return descriptors;\n },\n columnsAxisDescriptors: function () {\n return this._descriptorsForAxis('columns');\n },\n rowsAxisDescriptors: function () {\n return this._descriptorsForAxis('rows');\n },\n _process: function (data, e) {\n this._view = data;\n e = e || {};\n e.items = e.items || this._view;\n this.trigger(CHANGE, e);\n },\n _query: function (options) {\n var that = this;\n if (!options) {\n this._skipNormalize += 1;\n this._clearAxesData = true;\n }\n return that.query(extend({}, {\n page: that.page(),\n pageSize: that.pageSize(),\n sort: that.sort(),\n filter: that.filter(),\n group: that.group(),\n aggregate: that.aggregate(),\n columns: this.columnsAxisDescriptors(),\n rows: this.rowsAxisDescriptors(),\n measures: this.measures()\n }, options));\n },\n query: function (options) {\n var state = this._mergeState(options);\n if (this._data.length && this.cubeBuilder) {\n this._params(state);\n this._updateLocalData(this._pristineData);\n return $.Deferred().resolve().promise();\n }\n return this.read(state);\n },\n _mergeState: function (options) {\n options = DataSource.fn._mergeState.call(this, options);\n if (options !== undefined) {\n this._measures = normalizeMeasures(options.measures);\n if (options.columns) {\n options.columns = normalizeMembers(options.columns);\n } else if (!options.columns) {\n this._columns = [];\n }\n if (options.rows) {\n options.rows = normalizeMembers(options.rows);\n } else if (!options.rows) {\n this._rows = [];\n }\n }\n return options;\n },\n filter: function (val) {\n if (val === undefined) {\n return this._filter;\n }\n this._skipNormalize += 1;\n this._clearAxesData = true;\n this._query({\n filter: val,\n page: 1\n });\n },\n expandColumn: function (path) {\n this._expandPath(path, 'columns');\n },\n expandRow: function (path) {\n this._expandPath(path, 'rows');\n },\n success: function (data) {\n var originalData;\n if (this.cubeBuilder) {\n originalData = (this.reader.data(data) || []).slice(0);\n }\n DataSource.fn.success.call(this, data);\n if (originalData) {\n this._pristineData = originalData;\n }\n },\n _processResult: function (data, axes) {\n if (this.cubeBuilder) {\n var processedData = this.cubeBuilder.process(data, this._requestData);\n data = processedData.data;\n axes = processedData.axes;\n }\n var columnIndexes, rowIndexes;\n var tuples, resultAxis, measures, axisToSkip;\n var columnDescriptors = this.columns();\n var rowDescriptors = this.rows();\n var hasColumnTuples = axes.columns && axes.columns.tuples;\n if (!columnDescriptors.length && rowDescriptors.length && hasColumnTuples && (this._rowMeasures().length || !this.measures().length)) {\n axes = {\n columns: {},\n rows: axes.columns\n };\n }\n if (!columnDescriptors.length && !rowDescriptors.length && this.measuresAxis() === 'rows' && hasColumnTuples) {\n axes = {\n columns: {},\n rows: axes.columns\n };\n }\n this._axes = {\n columns: normalizeAxis(this._axes.columns),\n rows: normalizeAxis(this._axes.rows)\n };\n axes = {\n columns: normalizeAxis(axes.columns),\n rows: normalizeAxis(axes.rows)\n };\n columnIndexes = this._normalizeTuples(axes.columns.tuples, this._axes.columns.tuples, columnDescriptors, this._columnMeasures());\n rowIndexes = this._normalizeTuples(axes.rows.tuples, this._axes.rows.tuples, rowDescriptors, this._rowMeasures());\n if (this._skipNormalize > 0) {\n this._skipNormalize -= 1;\n }\n if (!this.cubeBuilder) {\n data = this._normalizeData({\n columnsLength: axes.columns.tuples.length,\n rowsLength: axes.rows.tuples.length,\n columnIndexes: columnIndexes,\n rowIndexes: rowIndexes,\n data: data\n });\n }\n if (this._lastExpanded == 'rows') {\n tuples = axes.columns.tuples;\n measures = this._columnMeasures();\n resultAxis = validateAxis(axes.columns, this._axes.columns, measures);\n if (resultAxis) {\n axisToSkip = 'columns';\n axes.columns = resultAxis;\n adjustDataByColumn(tuples, resultAxis.tuples, axes.rows.tuples.length, measures, data);\n if (!this.cubeBuilder) {\n data = this._normalizeData({\n columnsLength: membersCount(axes.columns.tuples, measures),\n rowsLength: axes.rows.tuples.length,\n data: data\n });\n }\n }\n } else if (this._lastExpanded == 'columns') {\n tuples = axes.rows.tuples;\n measures = this._rowMeasures();\n resultAxis = validateAxis(axes.rows, this._axes.rows, measures);\n if (resultAxis) {\n axisToSkip = 'rows';\n axes.rows = resultAxis;\n adjustDataByRow(tuples, resultAxis.tuples, axes.columns.tuples.length, measures, data);\n if (!this.cubeBuilder) {\n data = this._normalizeData({\n columnsLength: membersCount(axes.rows.tuples, measures),\n rowsLength: axes.columns.tuples.length,\n data: data\n });\n }\n }\n }\n this._lastExpanded = null;\n var result = this._mergeAxes(axes, data, axisToSkip);\n this._axes = result.axes;\n return result.data;\n },\n _readData: function (data) {\n var axes = this.reader.axes(data);\n var newData = this.reader.data(data);\n if (this.cubeBuilder) {\n this._rawData = newData;\n }\n return this._processResult(newData, axes);\n },\n _createTuple: function (tuple, measure, buildRoot) {\n var members = tuple.members;\n var length = members.length;\n var root = { members: [] };\n var levelName, levelNum;\n var name, parentName;\n var hasChildren;\n var hierarchy;\n var caption;\n var member;\n var idx = 0;\n if (measure) {\n length -= 1;\n }\n for (; idx < length; idx++) {\n member = members[idx];\n levelNum = Number(member.levelNum);\n name = member.name;\n parentName = member.parentName;\n caption = member.caption || name;\n hasChildren = member.hasChildren;\n hierarchy = member.hierarchy;\n levelName = member.levelName;\n if (buildRoot) {\n caption = 'All';\n if (levelNum === 0) {\n parentName = member.name;\n } else {\n levelNum -= 1;\n }\n hasChildren = true;\n name = hierarchy = levelName = parentName;\n }\n root.members.push({\n name: name,\n children: [],\n caption: caption,\n levelName: levelName,\n levelNum: levelNum.toString(),\n hasChildren: hasChildren,\n hierarchy: hierarchy,\n parentName: !buildRoot ? parentName : ''\n });\n }\n if (measure) {\n root.members.push({\n name: measure.name,\n children: []\n });\n }\n return root;\n },\n _hasRoot: function (target, source, descriptors) {\n if (source.length) {\n return findExistingTuple(source, target).tuple;\n }\n var members = target.members;\n var member;\n var descriptor;\n var isRoot = true;\n var levelNum;\n for (var idx = 0, length = members.length; idx < length; idx++) {\n member = members[idx];\n levelNum = Number(member.levelNum) || 0;\n descriptor = descriptors[idx];\n if (!(levelNum === 0 || descriptor && member.name === getName(descriptor))) {\n isRoot = false;\n break;\n }\n }\n return isRoot;\n },\n _mergeAxes: function (sourceAxes, data, axisToSkip) {\n var columnMeasures = this._columnMeasures();\n var rowMeasures = this._rowMeasures();\n var axes = this.axes();\n var startIndex, tuples;\n var oldRowsLength = membersCount(axes.rows.tuples, rowMeasures);\n var newRowsLength = sourceAxes.rows.tuples.length;\n var oldColumnsLength = membersCount(axes.columns.tuples, columnMeasures);\n var newColumnsLength = sourceAxes.columns.tuples.length;\n if (axisToSkip == 'columns') {\n newColumnsLength = oldColumnsLength;\n tuples = sourceAxes.columns.tuples;\n } else {\n tuples = parseSource(sourceAxes.columns.tuples, columnMeasures);\n data = prepareDataOnColumns(tuples, data);\n }\n var mergedColumns = mergeTuples(axes.columns.tuples, tuples, columnMeasures);\n if (axisToSkip == 'rows') {\n newRowsLength = membersCount(sourceAxes.rows.tuples, rowMeasures);\n tuples = sourceAxes.rows.tuples;\n } else {\n tuples = parseSource(sourceAxes.rows.tuples, rowMeasures);\n data = prepareDataOnRows(tuples, data);\n }\n var mergedRows = mergeTuples(axes.rows.tuples, tuples, rowMeasures);\n axes.columns.tuples = mergedColumns.tuples;\n axes.rows.tuples = mergedRows.tuples;\n if (oldColumnsLength !== membersCount(axes.columns.tuples, columnMeasures)) {\n startIndex = mergedColumns.index + findDataIndex(mergedColumns.parsedRoot, mergedColumns.memberIndex, columnMeasures);\n var offset = oldColumnsLength + newColumnsLength;\n data = this._mergeColumnData(data, startIndex, newRowsLength, newColumnsLength, offset);\n } else if (oldRowsLength !== membersCount(axes.rows.tuples, rowMeasures)) {\n startIndex = mergedRows.index + findDataIndex(mergedRows.parsedRoot, mergedRows.memberIndex, rowMeasures);\n data = this._mergeRowData(data, startIndex, newRowsLength, newColumnsLength);\n }\n if (axes.columns.tuples.length === 0 && axes.rows.tuples.length === 0) {\n data = [];\n }\n return {\n axes: axes,\n data: data\n };\n },\n _mergeColumnData: function (newData, columnIndex, rowsLength, columnsLength, offset) {\n var data = this.data().toJSON();\n var rowIndex, index, drop = 0, toAdd;\n var columnMeasures = Math.max(this._columnMeasures().length, 1);\n rowsLength = Math.max(rowsLength, 1);\n if (data.length > 0) {\n drop = columnMeasures;\n offset -= columnMeasures;\n }\n for (rowIndex = 0; rowIndex < rowsLength; rowIndex++) {\n index = columnIndex + rowIndex * offset;\n toAdd = newData.splice(0, columnsLength);\n toAdd.splice(0, drop);\n [].splice.apply(data, [\n index,\n 0\n ].concat(toAdd));\n }\n return data;\n },\n _mergeRowData: function (newData, rowIndex, rowsLength, columnsLength) {\n var data = this.data().toJSON();\n var idx, dataIndex, toAdd;\n var rowMeasures = Math.max(this._rowMeasures().length, 1);\n columnsLength = Math.max(columnsLength, 1);\n if (data.length > 0) {\n rowsLength -= rowMeasures;\n newData.splice(0, columnsLength * rowMeasures);\n }\n for (idx = 0; idx < rowsLength; idx++) {\n toAdd = newData.splice(0, columnsLength);\n dataIndex = rowIndex * columnsLength + idx * columnsLength;\n [].splice.apply(data, [\n dataIndex,\n 0\n ].concat(toAdd));\n }\n return data;\n },\n _columnMeasures: function () {\n var measures = this.measures();\n var columnMeasures = [];\n if (this.measuresAxis() === 'columns') {\n if (this.columns().length === 0) {\n columnMeasures = measures;\n } else if (measures.length > 1) {\n columnMeasures = measures;\n }\n }\n return columnMeasures;\n },\n _rowMeasures: function () {\n var measures = this.measures();\n var rowMeasures = [];\n if (this.measuresAxis() === 'rows') {\n if (this.rows().length === 0) {\n rowMeasures = measures;\n } else if (measures.length > 1) {\n rowMeasures = measures;\n }\n }\n return rowMeasures;\n },\n _updateLocalData: function (data, state) {\n if (this.cubeBuilder) {\n if (state) {\n this._requestData = state;\n }\n data = this._processResult(data);\n }\n this._data = this._observe(data);\n this._ranges = [];\n this._addRange(this._data);\n this._total = this._data.length;\n this._pristineTotal = this._total;\n this._process(this._data);\n },\n data: function (value) {\n var that = this;\n if (value !== undefined) {\n this._pristineData = value.slice(0);\n this._updateLocalData(value, {\n columns: this.columns(),\n rows: this.rows(),\n measures: this.measures()\n });\n } else {\n return that._data;\n }\n },\n _normalizeTuples: function (tuples, source, descriptors, measures) {\n var length = measures.length || 1;\n var idx = 0;\n var roots = [];\n var indexes = {};\n var measureIdx = 0;\n var tuple, memberIdx, last;\n if (!tuples.length) {\n return;\n }\n if (this._skipNormalize <= 0 && !this._hasRoot(tuples[0], source, descriptors)) {\n this._skipNormalize = 0;\n for (; idx < length; idx++) {\n roots.push(this._createTuple(tuples[0], measures[idx], true));\n indexes[idx] = idx;\n }\n tuples.splice.apply(tuples, [\n 0,\n tuples.length\n ].concat(roots).concat(tuples));\n idx = length;\n }\n if (measures.length) {\n last = tuple = tuples[idx];\n memberIdx = tuple.members.length - 1;\n while (tuple) {\n if (measureIdx >= length) {\n measureIdx = 0;\n }\n if (tuple.members[memberIdx].name !== measures[measureIdx].name) {\n tuples.splice(idx, 0, this._createTuple(tuple, measures[measureIdx]));\n indexes[idx] = idx;\n }\n idx += 1;\n measureIdx += 1;\n tuple = tuples[idx];\n if (length > measureIdx && (!tuple || tupleName(last, memberIdx - 1) !== tupleName(tuple, memberIdx - 1))) {\n for (; measureIdx < length; measureIdx++) {\n tuples.splice(idx, 0, this._createTuple(last, measures[measureIdx]));\n indexes[idx] = idx;\n idx += 1;\n }\n tuple = tuples[idx];\n }\n last = tuple;\n }\n }\n return indexes;\n },\n _addMissingDataItems: function (result, metadata) {\n while (metadata.rowIndexes[parseInt(result.length / metadata.columnsLength, 10)] !== undefined) {\n for (var idx = 0; idx < metadata.columnsLength; idx++) {\n result = addEmptyDataItem(result);\n }\n }\n while (metadata.columnIndexes[result.length % metadata.columnsLength] !== undefined) {\n result = addEmptyDataItem(result);\n }\n return result;\n },\n _normalizeOrdinals: function (result, dataItem, metadata) {\n var lastOrdinal = metadata.lastOrdinal;\n if (!dataItem) {\n return addEmptyDataItem(result);\n }\n if (dataItem.ordinal - lastOrdinal > 1) {\n lastOrdinal += 1;\n while (lastOrdinal < dataItem.ordinal && result.length < metadata.length) {\n result = this._addMissingDataItems(addEmptyDataItem(result), metadata);\n lastOrdinal += 1;\n }\n }\n dataItem.ordinal = result.length;\n result[result.length] = dataItem;\n return result;\n },\n _normalizeData: function (options) {\n var data = options.data;\n var dataIdx = 0;\n var dataItem;\n var result = [];\n var lastOrdinal;\n var length;\n options.lastOrdinal = 0;\n options.columnIndexes = options.columnIndexes || {};\n options.rowIndexes = options.rowIndexes || {};\n options.columnsLength = options.columnsLength || 1;\n options.rowsLength = options.rowsLength || 1;\n options.length = options.columnsLength * options.rowsLength;\n length = options.length;\n if (data.length === length) {\n return data;\n }\n while (result.length < length) {\n dataItem = data[dataIdx++];\n if (dataItem) {\n lastOrdinal = dataItem.ordinal;\n }\n result = this._normalizeOrdinals(this._addMissingDataItems(result, options), dataItem, options);\n options.lastOrdinal = lastOrdinal;\n }\n return result;\n },\n discover: function (options, converter) {\n var that = this, transport = that.transport;\n return $.Deferred(function (deferred) {\n transport.discover(extend({\n success: function (response) {\n response = that.reader.parse(response);\n if (that._handleCustomErrors(response)) {\n return;\n }\n if (converter) {\n response = converter(response);\n }\n deferred.resolve(response);\n },\n error: function (response, status, error) {\n deferred.reject(response);\n that.error(response, status, error);\n }\n }, options));\n }).promise().done(function () {\n that.trigger('schemaChange');\n });\n },\n schemaMeasures: function () {\n var that = this;\n return that.discover({\n data: {\n command: 'schemaMeasures',\n restrictions: {\n catalogName: that.transport.catalog(),\n cubeName: that.transport.cube()\n }\n }\n }, function (response) {\n return that.reader.measures(response);\n });\n },\n schemaKPIs: function () {\n var that = this;\n return that.discover({\n data: {\n command: 'schemaKPIs',\n restrictions: {\n catalogName: that.transport.catalog(),\n cubeName: that.transport.cube()\n }\n }\n }, function (response) {\n return that.reader.kpis(response);\n });\n },\n schemaDimensions: function () {\n var that = this;\n return that.discover({\n data: {\n command: 'schemaDimensions',\n restrictions: {\n catalogName: that.transport.catalog(),\n cubeName: that.transport.cube()\n }\n }\n }, function (response) {\n return that.reader.dimensions(response);\n });\n },\n schemaHierarchies: function (dimensionName) {\n var that = this;\n return that.discover({\n data: {\n command: 'schemaHierarchies',\n restrictions: {\n catalogName: that.transport.catalog(),\n cubeName: that.transport.cube(),\n dimensionUniqueName: dimensionName\n }\n }\n }, function (response) {\n return that.reader.hierarchies(response);\n });\n },\n schemaLevels: function (hierarchyName) {\n var that = this;\n return that.discover({\n data: {\n command: 'schemaLevels',\n restrictions: {\n catalogName: that.transport.catalog(),\n cubeName: that.transport.cube(),\n hierarchyUniqueName: hierarchyName\n }\n }\n }, function (response) {\n return that.reader.levels(response);\n });\n },\n schemaCubes: function () {\n var that = this;\n return that.discover({\n data: {\n command: 'schemaCubes',\n restrictions: { catalogName: that.transport.catalog() }\n }\n }, function (response) {\n return that.reader.cubes(response);\n });\n },\n schemaCatalogs: function () {\n var that = this;\n return that.discover({ data: { command: 'schemaCatalogs' } }, function (response) {\n return that.reader.catalogs(response);\n });\n },\n schemaMembers: function (restrictions) {\n var that = this;\n var success = function (restrictions) {\n return function (response) {\n return that.reader.members(response, restrictions);\n };\n }(restrictions);\n return that.discover({\n data: {\n command: 'schemaMembers',\n restrictions: extend({\n catalogName: that.transport.catalog(),\n cubeName: that.transport.cube()\n }, restrictions)\n }\n }, success);\n },\n _params: function (data) {\n if (this._clearAxesData) {\n this._axes = {};\n this._data = this._observe([]);\n this._clearAxesData = false;\n this.trigger(STATERESET);\n }\n var options = DataSource.fn._params.call(this, data);\n options = extend({\n measures: this.measures(),\n measuresAxis: this.measuresAxis(),\n columns: this.columns(),\n rows: this.rows()\n }, options);\n if (this.cubeBuilder) {\n this._requestData = options;\n }\n return options;\n }\n });\n function flatColumns(columns) {\n var result = [];\n for (var idx = 0; idx < columns.length; idx++) {\n result.push(columns[idx]);\n if (columns[idx].children) {\n result = result.concat(flatColumns(columns[idx].children));\n }\n }\n return result;\n }\n function sortItemsTree(field, items, sortFunction) {\n for (var i = 0; i < items.length; i++) {\n if (items[i].children && items[i].children.length) {\n sortItemsTree(field, items[i].children, sortFunction);\n }\n }\n if (items[0].parentName != field) {\n return;\n }\n items = items.sort(sortFunction);\n }\n function fillSortTree(items, map) {\n for (var i = 0; i < items.length; i++) {\n var currentItem = map[items[i].name];\n if (!$.isEmptyObject(currentItem.childrenMap)) {\n items[i].children = [];\n for (var name in currentItem.childrenMap) {\n items[i].children.push($.extend({}, {\n name: name,\n parentName: map[name].parentName\n }));\n }\n fillSortTree(items[i].children, map);\n }\n }\n }\n function addEmptyDataItem(result) {\n result[result.length] = {\n value: '',\n fmtValue: '',\n ordinal: result.length\n };\n return result;\n }\n function validateAxis(newAxis, axis, measures) {\n if (newAxis.tuples.length < membersCount(axis.tuples, measures)) {\n return axis;\n }\n return;\n }\n function adjustDataByColumn(sourceTuples, targetTuples, rowsLength, measures, data) {\n var columnIdx, rowIdx, dataIdx;\n var columnsLength = sourceTuples.length;\n var targetColumnsLength = membersCount(targetTuples, measures);\n var measuresLength = measures.length || 1;\n for (rowIdx = 0; rowIdx < rowsLength; rowIdx++) {\n for (columnIdx = 0; columnIdx < columnsLength; columnIdx++) {\n dataIdx = tupleIndex(sourceTuples[columnIdx], targetTuples) * measuresLength;\n dataIdx += columnIdx % measuresLength;\n data[rowIdx * columnsLength + columnIdx].ordinal = rowIdx * targetColumnsLength + dataIdx;\n }\n }\n }\n function adjustDataByRow(sourceTuples, targetTuples, columnsLength, measures, data) {\n var columnIdx, rowIdx, dataIdx;\n var rowsLength = sourceTuples.length;\n var measuresLength = measures.length || 1;\n for (rowIdx = 0; rowIdx < rowsLength; rowIdx++) {\n dataIdx = tupleIndex(sourceTuples[rowIdx], targetTuples);\n dataIdx *= measuresLength;\n dataIdx += rowIdx % measuresLength;\n for (columnIdx = 0; columnIdx < columnsLength; columnIdx++) {\n data[rowIdx * columnsLength + columnIdx].ordinal = dataIdx * columnsLength + columnIdx;\n }\n }\n }\n function tupleIndex(tuple, collection) {\n return findExistingTuple(collection, tuple).index;\n }\n function membersCount(tuples, measures) {\n if (!tuples.length) {\n return 0;\n }\n var queue = tuples.slice();\n var current = queue.shift();\n var result = 1;\n while (current) {\n if (current.members) {\n [].push.apply(queue, current.members);\n } else if (current.children) {\n if (!current.measure) {\n result += current.children.length;\n }\n [].push.apply(queue, current.children);\n }\n current = queue.shift();\n }\n if (measures.length) {\n result = result * measures.length;\n }\n return result;\n }\n function normalizeAxis(axis) {\n if (!axis) {\n axis = { tuples: [] };\n }\n if (!axis.tuples) {\n axis.tuples = [];\n }\n return axis;\n }\n function findDataIndex(tuple, memberIndex, measures) {\n if (!tuple) {\n return 0;\n }\n var measuresLength = Math.max(measures.length, 1);\n var tuples = tuple.members.slice(0, memberIndex);\n var current = tuples.shift();\n var counter = measuresLength;\n while (current) {\n if (current.name === MEASURES) {\n counter += measuresLength - 1;\n } else if (current.children) {\n [].push.apply(tuples, current.children);\n } else {\n counter++;\n [].push.apply(tuples, current.members);\n }\n current = tuples.shift();\n }\n return counter;\n }\n function mergeTuples(target, source, measures) {\n if (!source[0]) {\n return {\n parsedRoot: null,\n tuples: target,\n memberIndex: 0,\n index: 0\n };\n }\n var result = findExistingTuple(target, source[0]);\n if (!result.tuple) {\n return {\n parsedRoot: null,\n tuples: source,\n memberIndex: 0,\n index: 0\n };\n }\n var targetMembers = result.tuple.members;\n var sourceMembers = source[0].members;\n var memberIndex = -1;\n if (targetMembers.length !== sourceMembers.length) {\n return {\n parsedRoot: null,\n tuples: source,\n memberIndex: 0,\n index: 0\n };\n }\n for (var idx = 0, length = targetMembers.length; idx < length; idx++) {\n if (!targetMembers[idx].measure && sourceMembers[idx].children[0]) {\n if (memberIndex == -1 && sourceMembers[idx].children.length) {\n memberIndex = idx;\n }\n targetMembers[idx].children = sourceMembers[idx].children;\n }\n }\n measures = Math.max(measures.length, 1);\n return {\n parsedRoot: result.tuple,\n index: result.index * measures,\n memberIndex: memberIndex,\n tuples: target\n };\n }\n function equalTuples(first, second) {\n var equal = true;\n var idx, length;\n first = first.members;\n second = second.members;\n for (idx = 0, length = first.length; idx < length; idx++) {\n if (first[idx].measure || second[idx].measure) {\n continue;\n }\n equal = equal && getName(first[idx]) === getName(second[idx]);\n }\n return equal;\n }\n function findExistingTuple(tuples, toFind) {\n var idx, length, tuple, found, counter = 0;\n var memberIndex, membersLength, member;\n for (idx = 0, length = tuples.length; idx < length; idx++) {\n tuple = tuples[idx];\n if (equalTuples(tuple, toFind)) {\n return {\n tuple: tuple,\n index: counter\n };\n }\n counter++;\n for (memberIndex = 0, membersLength = tuple.members.length; memberIndex < membersLength; memberIndex++) {\n member = tuple.members[memberIndex];\n if (member.measure) {\n continue;\n }\n found = findExistingTuple(member.children, toFind);\n counter += found.index;\n if (found.tuple) {\n return {\n tuple: found.tuple,\n index: counter\n };\n }\n }\n }\n return { index: counter };\n }\n function addMembers(members, map) {\n var member, i, len, path = '';\n for (i = 0, len = members.length; i < len; i++) {\n member = members[i];\n path += member.name;\n if (!map[path]) {\n map[path] = member;\n }\n }\n }\n function findParentMember(tuple, map) {\n var members = tuple.members;\n var i, len, member, path = '';\n var parentPath = '';\n var parentMember;\n for (i = 0, len = members.length; i < len; i++) {\n member = members[i];\n if (parentMember) {\n if (map[path + member.name]) {\n path += member.name;\n parentMember = map[path];\n continue;\n } else if (map[path + member.parentName]) {\n return map[path + member.parentName];\n } else if (map[parentPath + member.parentName]) {\n return map[parentPath + member.parentName];\n } else {\n return map[parentPath];\n }\n }\n path += member.name;\n parentMember = map[member.parentName];\n if (!parentMember) {\n parentMember = map[path];\n if (!parentMember) {\n return null;\n }\n }\n if (parentMember) {\n parentPath += parentMember.name;\n }\n }\n return parentMember;\n }\n function measurePosition(tuple, measures) {\n if (measures.length === 0) {\n return -1;\n }\n var measure = measures[0];\n var members = tuple.members;\n for (var idx = 0, len = members.length; idx < len; idx++) {\n if (members[idx].name == measure.name) {\n return idx;\n }\n }\n }\n function normalizeTupleMeasures(tuple, index) {\n if (index < 0) {\n return;\n }\n var member = {\n name: MEASURES,\n measure: true,\n children: [$.extend({\n members: [],\n dataIndex: tuple.dataIndex\n }, tuple.members[index])]\n };\n tuple.members.splice(index, 1, member);\n tuple.dataIndex = undefined;\n }\n function parseSource(tuples, measures) {\n if (tuples.length < 1) {\n return [];\n }\n var result = [];\n var map = {};\n var measureIndex = measurePosition(tuples[0], measures);\n for (var i = 0; i < tuples.length; i++) {\n var tuple = tuples[i];\n tuple.dataIndex = i;\n normalizeTupleMeasures(tuple, measureIndex);\n var parentMember = findParentMember(tuple, map);\n if (parentMember) {\n if (measureIndex < 0 || !parentMember.measure) {\n parentMember.children.push(tuple);\n } else {\n parentMember.children.push(tuple.members[measureIndex].children[0]);\n }\n } else {\n result.push(tuple);\n }\n addMembers(tuple.members, map);\n }\n return result;\n }\n function prepareDataOnRows(tuples, data) {\n if (!tuples || !tuples.length) {\n return data;\n }\n var result = [];\n var indices = buildDataIndices(tuples);\n var rowsLength = indices.length;\n var columnsLength = Math.max(data.length / rowsLength, 1);\n var rowIndex, columnIndex, targetIndex, sourceIndex;\n var calcIndex;\n for (rowIndex = 0; rowIndex < rowsLength; rowIndex++) {\n targetIndex = columnsLength * rowIndex;\n sourceIndex = columnsLength * indices[rowIndex];\n for (columnIndex = 0; columnIndex < columnsLength; columnIndex++) {\n calcIndex = parseInt(sourceIndex + columnIndex, 10);\n result[parseInt(targetIndex + columnIndex, 10)] = data[calcIndex] || {\n value: '',\n fmtValue: '',\n ordinal: calcIndex\n };\n }\n }\n return result;\n }\n function prepareDataOnColumns(tuples, data) {\n if (!tuples || !tuples.length) {\n return data;\n }\n var result = [];\n var indices = buildDataIndices(tuples);\n var columnsLength = indices.length;\n var rowsLength = Math.max(data.length / columnsLength, 1);\n var columnIndex, rowIndex, dataIndex, calcIndex;\n for (rowIndex = 0; rowIndex < rowsLength; rowIndex++) {\n dataIndex = columnsLength * rowIndex;\n for (columnIndex = 0; columnIndex < columnsLength; columnIndex++) {\n calcIndex = indices[columnIndex] + dataIndex;\n result[dataIndex + columnIndex] = data[calcIndex] || {\n value: '',\n fmtValue: '',\n ordinal: calcIndex\n };\n }\n }\n return result;\n }\n function buildDataIndices(tuples) {\n tuples = tuples.slice();\n var result = [];\n var tuple = tuples.shift();\n var idx, length, spliceIndex, children, member;\n while (tuple) {\n if (tuple.dataIndex !== undefined) {\n result.push(tuple.dataIndex);\n }\n spliceIndex = 0;\n for (idx = 0, length = tuple.members.length; idx < length; idx++) {\n member = tuple.members[idx];\n children = member.children;\n if (member.measure) {\n [].splice.apply(tuples, [\n 0,\n 0\n ].concat(children));\n } else {\n [].splice.apply(tuples, [\n spliceIndex,\n 0\n ].concat(children));\n }\n spliceIndex += children.length;\n }\n tuple = tuples.shift();\n }\n return result;\n }\n PivotDataSource.create = function (options) {\n options = options && options.push ? { data: options } : options;\n var dataSource = options || {}, data = dataSource.data;\n dataSource.data = data;\n if (!(dataSource instanceof PivotDataSource) && dataSource instanceof kendo.data.DataSource) {\n throw new Error('Incorrect DataSource type. Only PivotDataSource instances are supported');\n }\n return dataSource instanceof PivotDataSource ? dataSource : new PivotDataSource(dataSource);\n };\n function baseHierarchyPath(memberName) {\n var parts = memberName.split('.');\n if (parts.length > 2) {\n return parts[0] + '.' + parts[1];\n }\n return memberName;\n }\n function expandMemberDescriptor(names, sort) {\n var idx = names.length - 1;\n var name = names[idx];\n var sortDescriptor;\n sortDescriptor = sortDescriptorForMember(sort, name);\n if (sortDescriptor && sortDescriptor.dir) {\n name = 'ORDER(' + name + '.Children,' + sortDescriptor.field + '.CurrentMember.MEMBER_CAPTION,' + sortDescriptor.dir + ')';\n } else {\n name += '.Children';\n }\n names[idx] = name;\n return names;\n }\n function sortDescriptorForMember(sort, member) {\n for (var idx = 0, length = sort.length; idx < length; idx++) {\n if (member.indexOf(sort[idx].field) === 0) {\n return sort[idx];\n }\n }\n return null;\n }\n function crossJoin(names) {\n var result = 'CROSSJOIN({';\n var r;\n if (names.length > 2) {\n r = names.pop();\n result += crossJoin(names);\n } else {\n result += names.shift();\n r = names.pop();\n }\n result += '},{';\n result += r;\n result += '})';\n return result;\n }\n function crossJoinCommand(members, measures) {\n var tmp = members.slice(0);\n if (measures.length > 1) {\n tmp.push('{' + measureNames(measures).join(',') + '}');\n }\n return crossJoin(tmp);\n }\n function measureNames(measures) {\n var idx = 0;\n var length = measures.length;\n var result = [];\n var measure;\n for (; idx < length; idx++) {\n measure = measures[idx];\n result.push(measure.name !== undefined ? measure.name : measure);\n }\n return result;\n }\n function getName(name) {\n name = name.name || name;\n if (toString.call(name) === '[object Array]') {\n name = name[name.length - 1];\n }\n return name;\n }\n function getRootNames(members) {\n var length = members.length;\n var names = [];\n var idx = 0;\n for (; idx < length; idx++) {\n names.push(members[idx].name[0]);\n }\n return names;\n }\n function mapNames(names, rootNames) {\n var name;\n var rootName;\n var j;\n var idx = 0;\n var length = names.length;\n var rootLength = rootNames.length;\n rootNames = rootNames.slice(0);\n for (; idx < length; idx++) {\n name = names[idx];\n for (j = 0; j < rootLength; j++) {\n rootName = baseHierarchyPath(rootNames[j]);\n if (name.indexOf(rootName) !== -1) {\n rootNames[j] = name;\n break;\n }\n }\n }\n return {\n names: rootNames,\n expandedIdx: j,\n uniquePath: rootNames.slice(0, j + 1).join('')\n };\n }\n function parseDescriptors(members) {\n var expanded = [];\n var child = [];\n var root = [];\n var member;\n var j, l;\n var idx = 0;\n var length = members.length;\n var name;\n var hierarchyName;\n var found;\n for (; idx < length; idx++) {\n member = members[idx];\n name = member.name;\n found = false;\n if (toString.call(name) !== '[object Array]') {\n member.name = name = [name];\n }\n if (name.length > 1) {\n child.push(member);\n } else {\n hierarchyName = baseHierarchyPath(name[0]);\n for (j = 0, l = root.length; j < l; j++) {\n if (root[j].name[0].indexOf(hierarchyName) === 0) {\n found = true;\n break;\n }\n }\n if (!found) {\n root.push(member);\n }\n if (member.expand) {\n expanded.push(member);\n }\n }\n }\n expanded = expanded.concat(child);\n return {\n root: root,\n expanded: expanded\n };\n }\n function serializeMembers(members, measures, sort) {\n var command = '';\n members = members || [];\n var expanded = parseDescriptors(members);\n var root = expanded.root;\n var rootNames = getRootNames(root);\n var crossJoinCommands = [];\n expanded = expanded.expanded;\n var length = expanded.length;\n var idx = 0;\n var memberName;\n var names = [];\n if (rootNames.length > 1 || measures.length > 1) {\n crossJoinCommands.push(crossJoinCommand(rootNames, measures));\n for (; idx < length; idx++) {\n memberName = expandMemberDescriptor(expanded[idx].name, sort);\n names = mapNames(memberName, rootNames).names;\n crossJoinCommands.push(crossJoinCommand(names, measures));\n }\n command += crossJoinCommands.join(',');\n } else {\n for (; idx < length; idx++) {\n memberName = expandMemberDescriptor(expanded[idx].name, sort);\n names.push(memberName[0]);\n }\n command += rootNames.concat(names).join(',');\n }\n return command;\n }\n var filterFunctionFormats = {\n contains: ', InStr({0}.CurrentMember.MEMBER_CAPTION,\"{1}\") > 0',\n doesnotcontain: ', InStr({0}.CurrentMember.MEMBER_CAPTION,\"{1}\")',\n startswith: ', Left({0}.CurrentMember.MEMBER_CAPTION,Len(\"{1}\"))=\"{1}\"',\n endswith: ', Right({0}.CurrentMember.MEMBER_CAPTION,Len(\"{1}\"))=\"{1}\"',\n eq: ', {0}.CurrentMember.MEMBER_CAPTION = \"{1}\"',\n neq: ', {0}.CurrentMember.MEMBER_CAPTION = \"{1}\"'\n };\n function serializeExpression(expression) {\n var command = '';\n var value = expression.value;\n var field = expression.field;\n var operator = expression.operator;\n if (operator == 'in') {\n command += '{';\n command += value;\n command += '}';\n } else {\n command += operator == 'neq' || operator == 'doesnotcontain' ? '-' : '';\n command += 'Filter(';\n command += field + '.MEMBERS';\n command += kendo.format(filterFunctionFormats[operator], field, value);\n command += ')';\n }\n return command;\n }\n function serializeFilters(filter, cube) {\n var command = '', current;\n var filters = filter.filters;\n var length = filters.length;\n var idx;\n for (idx = length - 1; idx >= 0; idx--) {\n current = 'SELECT (';\n current += serializeExpression(filters[idx]);\n current += ') ON 0';\n if (idx == length - 1) {\n current += ' FROM [' + cube + ']';\n command = current;\n } else {\n command = current + ' FROM ( ' + command + ' )';\n }\n }\n return command;\n }\n function serializeOptions(parentTagName, options, capitalize) {\n var result = '';\n if (options) {\n result += '<' + parentTagName + '>';\n var value;\n for (var key in options) {\n value = options[key];\n if (capitalize) {\n key = key.replace(/([A-Z]+(?=$|[A-Z][a-z])|[A-Z]?[a-z]+)/g, '$1_').toUpperCase().replace(/_$/, '');\n }\n result += '<' + key + '>' + value + '';\n }\n result += '';\n } else {\n result += '<' + parentTagName + '/>';\n }\n return result;\n }\n var xmlaDiscoverCommands = {\n schemaCubes: 'MDSCHEMA_CUBES',\n schemaCatalogs: 'DBSCHEMA_CATALOGS',\n schemaMeasures: 'MDSCHEMA_MEASURES',\n schemaDimensions: 'MDSCHEMA_DIMENSIONS',\n schemaHierarchies: 'MDSCHEMA_HIERARCHIES',\n schemaLevels: 'MDSCHEMA_LEVELS',\n schemaMembers: 'MDSCHEMA_MEMBERS',\n schemaKPIs: 'MDSCHEMA_KPIS'\n };\n var convertersMap = {\n read: function (options) {\n var command = '
';\n command += 'SELECT NON EMPTY {';\n var columns = options.columns || [];\n var rows = options.rows || [];\n var measures = options.measures || [];\n var measuresRowAxis = options.measuresAxis === 'rows';\n var sort = options.sort || [];\n if (!columns.length && rows.length && (!measures.length || measures.length && measuresRowAxis)) {\n columns = rows;\n rows = [];\n measuresRowAxis = false;\n }\n if (!columns.length && !rows.length) {\n measuresRowAxis = false;\n }\n if (columns.length) {\n command += serializeMembers(columns, !measuresRowAxis ? measures : [], sort);\n } else if (measures.length && !measuresRowAxis) {\n command += measureNames(measures).join(',');\n }\n command += '} DIMENSION PROPERTIES CHILDREN_CARDINALITY, PARENT_UNIQUE_NAME ON COLUMNS';\n if (rows.length || measuresRowAxis && measures.length > 1) {\n command += ', NON EMPTY {';\n if (rows.length) {\n command += serializeMembers(rows, measuresRowAxis ? measures : [], sort);\n } else {\n command += measureNames(measures).join(',');\n }\n command += '} DIMENSION PROPERTIES CHILDREN_CARDINALITY, PARENT_UNIQUE_NAME ON ROWS';\n }\n if (options.filter) {\n command += ' FROM ';\n command += '(';\n command += serializeFilters(options.filter, options.connection.cube);\n command += ')';\n } else {\n command += ' FROM [' + options.connection.cube + ']';\n }\n if (measures.length == 1 && columns.length) {\n command += ' WHERE (' + measureNames(measures).join(',') + ')';\n }\n command += '' + options.connection.catalog + 'Multidimensional';\n return command.replace(/\\&/g, '&');\n },\n discover: function (options) {\n options = options || {};\n var command = '
';\n command += '' + (xmlaDiscoverCommands[options.command] || options.command) + '';\n command += '' + serializeOptions('RestrictionList', options.restrictions, true) + '';\n if (options.connection && options.connection.catalog) {\n options.properties = $.extend({}, { Catalog: options.connection.catalog }, options.properties);\n }\n command += '' + serializeOptions('PropertyList', options.properties) + '';\n command += '';\n return command;\n }\n };\n var XmlaTransport = kendo.data.RemoteTransport.extend({\n init: function (options) {\n var originalOptions = options;\n options = this.options = extend(true, {}, this.options, options);\n kendo.data.RemoteTransport.call(this, options);\n if (isFunction(originalOptions.discover)) {\n this.discover = originalOptions.discover;\n } else if (typeof originalOptions.discover === 'string') {\n this.options.discover = { url: originalOptions.discover };\n } else if (!originalOptions.discover) {\n this.options.discover = this.options.read;\n }\n },\n setup: function (options, type) {\n options.data = options.data || {};\n $.extend(true, options.data, { connection: this.options.connection });\n return kendo.data.RemoteTransport.fn.setup.call(this, options, type);\n },\n options: {\n read: {\n dataType: 'text',\n contentType: 'text/xml',\n type: 'POST'\n },\n discover: {\n dataType: 'text',\n contentType: 'text/xml',\n type: 'POST'\n },\n parameterMap: function (options, type) {\n return convertersMap[type](options, type);\n }\n },\n discover: function (options) {\n return $.ajax(this.setup(options, 'discover'));\n }\n });\n function asArray(object) {\n if (object == null) {\n return [];\n }\n var type = toString.call(object);\n if (type !== '[object Array]') {\n return [object];\n }\n return object;\n }\n function translateAxis(axis) {\n var result = { tuples: [] };\n var tuples = asArray(kendo.getter('Tuples.Tuple', true)(axis));\n var captionGetter = kendo.getter('Caption[\\'#text\\']');\n var unameGetter = kendo.getter('UName[\\'#text\\']');\n var levelNameGetter = kendo.getter('LName[\\'#text\\']');\n var levelNumGetter = kendo.getter('LNum[\\'#text\\']');\n var childrenGetter = kendo.getter('CHILDREN_CARDINALITY[\\'#text\\']', true);\n var hierarchyGetter = kendo.getter('[\\'@Hierarchy\\']');\n var parentNameGetter = kendo.getter('PARENT_UNIQUE_NAME[\\'#text\\']', true);\n for (var idx = 0; idx < tuples.length; idx++) {\n var members = [];\n var member = asArray(tuples[idx].Member);\n for (var memberIdx = 0; memberIdx < member.length; memberIdx++) {\n members.push({\n children: [],\n caption: captionGetter(member[memberIdx]),\n name: unameGetter(member[memberIdx]),\n levelName: levelNameGetter(member[memberIdx]),\n levelNum: levelNumGetter(member[memberIdx]),\n hasChildren: parseInt(childrenGetter(member[memberIdx]), 10) > 0,\n parentName: parentNameGetter(member[memberIdx]),\n hierarchy: hierarchyGetter(member[memberIdx])\n });\n }\n result.tuples.push({ members: members });\n }\n return result;\n }\n var schemaDataReaderMap = {\n cubes: {\n name: kendo.getter('CUBE_NAME[\\'#text\\']', true),\n caption: kendo.getter('CUBE_CAPTION[\\'#text\\']', true),\n description: kendo.getter('DESCRIPTION[\\'#text\\']', true),\n type: kendo.getter('CUBE_TYPE[\\'#text\\']', true)\n },\n catalogs: {\n name: kendo.getter('CATALOG_NAME[\\'#text\\']', true),\n description: kendo.getter('DESCRIPTION[\\'#text\\']', true)\n },\n measures: {\n name: kendo.getter('MEASURE_NAME[\\'#text\\']', true),\n caption: kendo.getter('MEASURE_CAPTION[\\'#text\\']', true),\n uniqueName: kendo.getter('MEASURE_UNIQUE_NAME[\\'#text\\']', true),\n description: kendo.getter('DESCRIPTION[\\'#text\\']', true),\n aggregator: kendo.getter('MEASURE_AGGREGATOR[\\'#text\\']', true),\n groupName: kendo.getter('MEASUREGROUP_NAME[\\'#text\\']', true),\n displayFolder: kendo.getter('MEASURE_DISPLAY_FOLDER[\\'#text\\']', true),\n defaultFormat: kendo.getter('DEFAULT_FORMAT_STRING[\\'#text\\']', true)\n },\n kpis: {\n name: kendo.getter('KPI_NAME[\\'#text\\']', true),\n caption: kendo.getter('KPI_CAPTION[\\'#text\\']', true),\n value: kendo.getter('KPI_VALUE[\\'#text\\']', true),\n goal: kendo.getter('KPI_GOAL[\\'#text\\']', true),\n status: kendo.getter('KPI_STATUS[\\'#text\\']', true),\n trend: kendo.getter('KPI_TREND[\\'#text\\']', true),\n statusGraphic: kendo.getter('KPI_STATUS_GRAPHIC[\\'#text\\']', true),\n trendGraphic: kendo.getter('KPI_TREND_GRAPHIC[\\'#text\\']', true),\n description: kendo.getter('KPI_DESCRIPTION[\\'#text\\']', true),\n groupName: kendo.getter('MEASUREGROUP_NAME[\\'#text\\']', true)\n },\n dimensions: {\n name: kendo.getter('DIMENSION_NAME[\\'#text\\']', true),\n caption: kendo.getter('DIMENSION_CAPTION[\\'#text\\']', true),\n description: kendo.getter('DESCRIPTION[\\'#text\\']', true),\n uniqueName: kendo.getter('DIMENSION_UNIQUE_NAME[\\'#text\\']', true),\n defaultHierarchy: kendo.getter('DEFAULT_HIERARCHY[\\'#text\\']', true),\n type: kendo.getter('DIMENSION_TYPE[\\'#text\\']', true)\n },\n hierarchies: {\n name: kendo.getter('HIERARCHY_NAME[\\'#text\\']', true),\n caption: kendo.getter('HIERARCHY_CAPTION[\\'#text\\']', true),\n description: kendo.getter('DESCRIPTION[\\'#text\\']', true),\n uniqueName: kendo.getter('HIERARCHY_UNIQUE_NAME[\\'#text\\']', true),\n dimensionUniqueName: kendo.getter('DIMENSION_UNIQUE_NAME[\\'#text\\']', true),\n displayFolder: kendo.getter('HIERARCHY_DISPLAY_FOLDER[\\'#text\\']', true),\n origin: kendo.getter('HIERARCHY_ORIGIN[\\'#text\\']', true),\n defaultMember: kendo.getter('DEFAULT_MEMBER[\\'#text\\']', true)\n },\n levels: {\n name: kendo.getter('LEVEL_NAME[\\'#text\\']', true),\n caption: kendo.getter('LEVEL_CAPTION[\\'#text\\']', true),\n description: kendo.getter('DESCRIPTION[\\'#text\\']', true),\n uniqueName: kendo.getter('LEVEL_UNIQUE_NAME[\\'#text\\']', true),\n dimensionUniqueName: kendo.getter('DIMENSION_UNIQUE_NAME[\\'#text\\']', true),\n displayFolder: kendo.getter('LEVEL_DISPLAY_FOLDER[\\'#text\\']', true),\n orderingProperty: kendo.getter('LEVEL_ORDERING_PROPERTY[\\'#text\\']', true),\n origin: kendo.getter('LEVEL_ORIGIN[\\'#text\\']', true),\n hierarchyUniqueName: kendo.getter('HIERARCHY_UNIQUE_NAME[\\'#text\\']', true)\n },\n members: {\n name: kendo.getter('MEMBER_NAME[\\'#text\\']', true),\n caption: kendo.getter('MEMBER_CAPTION[\\'#text\\']', true),\n uniqueName: kendo.getter('MEMBER_UNIQUE_NAME[\\'#text\\']', true),\n dimensionUniqueName: kendo.getter('DIMENSION_UNIQUE_NAME[\\'#text\\']', true),\n hierarchyUniqueName: kendo.getter('HIERARCHY_UNIQUE_NAME[\\'#text\\']', true),\n levelUniqueName: kendo.getter('LEVEL_UNIQUE_NAME[\\'#text\\']', true),\n childrenCardinality: kendo.getter('CHILDREN_CARDINALITY[\\'#text\\']', true)\n }\n };\n var xmlaReaderMethods = [\n 'axes',\n 'catalogs',\n 'cubes',\n 'dimensions',\n 'hierarchies',\n 'levels',\n 'measures'\n ];\n var XmlaDataReader = kendo.data.XmlDataReader.extend({\n init: function (options) {\n kendo.data.XmlDataReader.call(this, options);\n this._extend(options);\n },\n _extend: function (options) {\n var idx = 0;\n var length = xmlaReaderMethods.length;\n var methodName;\n var option;\n for (; idx < length; idx++) {\n methodName = xmlaReaderMethods[idx];\n option = options[methodName];\n if (option && option !== identity) {\n this[methodName] = option;\n }\n }\n },\n parse: function (xml) {\n var result = kendo.data.XmlDataReader.fn.parse(xml.replace(/<(\\/?)(\\w|-)+:/g, '<$1'));\n return kendo.getter('[\\'Envelope\\'][\\'Body\\']', true)(result);\n },\n errors: function (root) {\n var fault = kendo.getter('[\\'Fault\\']', true)(root);\n if (fault) {\n return [{\n faultstring: kendo.getter('faultstring[\\'#text\\']', true)(fault),\n faultcode: kendo.getter('faultcode[\\'#text\\']', true)(fault)\n }];\n }\n return null;\n },\n axes: function (root) {\n root = kendo.getter('ExecuteResponse[\"return\"].root', true)(root);\n var axes = asArray(kendo.getter('Axes.Axis', true)(root));\n var axis;\n var result = {\n columns: {},\n rows: {}\n };\n for (var idx = 0; idx < axes.length; idx++) {\n axis = axes[idx];\n if (axis['@name'].toLowerCase() !== 'sliceraxis') {\n if (!result.columns.tuples) {\n result.columns = translateAxis(axis);\n } else {\n result.rows = translateAxis(axis);\n }\n }\n }\n return result;\n },\n data: function (root) {\n root = kendo.getter('ExecuteResponse[\"return\"].root', true)(root);\n var cells = asArray(kendo.getter('CellData.Cell', true)(root));\n var result = [];\n var ordinalGetter = kendo.getter('[\\'@CellOrdinal\\']');\n var valueGetter = kendo.getter('Value[\\'#text\\']');\n var fmtValueGetter = kendo.getter('FmtValue[\\'#text\\']');\n for (var idx = 0; idx < cells.length; idx++) {\n result.push({\n value: valueGetter(cells[idx]),\n fmtValue: fmtValueGetter(cells[idx]),\n ordinal: parseInt(ordinalGetter(cells[idx]), 10)\n });\n }\n return result;\n },\n _mapSchema: function (root, getters) {\n root = kendo.getter('DiscoverResponse[\"return\"].root', true)(root);\n var rows = asArray(kendo.getter('row', true)(root));\n var result = [];\n for (var idx = 0; idx < rows.length; idx++) {\n var obj = {};\n for (var key in getters) {\n obj[key] = getters[key](rows[idx]);\n }\n result.push(obj);\n }\n return result;\n },\n measures: function (root) {\n return this._mapSchema(root, schemaDataReaderMap.measures);\n },\n kpis: function (root) {\n return this._mapSchema(root, schemaDataReaderMap.kpis);\n },\n hierarchies: function (root) {\n return this._mapSchema(root, schemaDataReaderMap.hierarchies);\n },\n levels: function (root) {\n return this._mapSchema(root, schemaDataReaderMap.levels);\n },\n dimensions: function (root) {\n return this._mapSchema(root, schemaDataReaderMap.dimensions);\n },\n cubes: function (root) {\n return this._mapSchema(root, schemaDataReaderMap.cubes);\n },\n catalogs: function (root) {\n return this._mapSchema(root, schemaDataReaderMap.catalogs);\n },\n members: function (root) {\n return this._mapSchema(root, schemaDataReaderMap.members);\n }\n });\n extend(true, kendo.data, {\n PivotDataSource: PivotDataSource,\n XmlaTransport: XmlaTransport,\n XmlaDataReader: XmlaDataReader,\n PivotCubeBuilder: PivotCubeBuilder,\n transports: { xmla: XmlaTransport },\n readers: { xmla: XmlaDataReader }\n });\n var sortExpr = function (expressions, name) {\n if (!expressions) {\n return null;\n }\n for (var idx = 0, length = expressions.length; idx < length; idx++) {\n if (expressions[idx].field === name) {\n return expressions[idx];\n }\n }\n return null;\n };\n var removeExpr = function (expressions, name) {\n var result = [];\n for (var idx = 0, length = expressions.length; idx < length; idx++) {\n if (expressions[idx].field !== name) {\n result.push(expressions[idx]);\n }\n }\n return result;\n };\n kendo.ui.PivotSettingTarget = Widget.extend({\n init: function (element, options) {\n var that = this;\n Widget.fn.init.call(that, element, options);\n that.element.addClass('k-pivot-setting');\n that.dataSource = kendo.data.PivotDataSource.create(options.dataSource);\n that._refreshHandler = $.proxy(that.refresh, that);\n that.dataSource.first(CHANGE, that._refreshHandler);\n if (!options.template) {\n that.options.template = '
${data.name || data}' + (that.options.enabled ? '' : '') + '
';\n }\n that.template = kendo.template(that.options.template);\n that.emptyTemplate = kendo.template(that.options.emptyTemplate);\n that._sortable();\n that.element.on('click' + NS, '.k-button,.k-item', function (e) {\n var target = $(e.target);\n var name = target.closest('[' + kendo.attr('name') + ']').attr(kendo.attr('name'));\n if (!name) {\n return;\n }\n if (target.hasClass('k-i-close')) {\n that.remove(name);\n } else if (that.options.sortable && target[0] === e.currentTarget) {\n that.sort({\n field: name,\n dir: target.find('.k-i-sort-asc-sm')[0] ? 'desc' : 'asc'\n });\n }\n });\n if (options.filterable || options.sortable) {\n that.fieldMenu = new ui.PivotFieldMenu(that.element, {\n messages: that.options.messages.fieldMenu,\n filter: '.k-setting-fieldmenu',\n filterable: options.filterable,\n sortable: options.sortable,\n dataSource: that.dataSource\n });\n }\n that.refresh();\n },\n options: {\n name: 'PivotSettingTarget',\n template: null,\n filterable: false,\n sortable: false,\n emptyTemplate: '
${data}
',\n setting: 'columns',\n enabled: true,\n messages: { empty: 'Drop Fields Here' }\n },\n setDataSource: function (dataSource) {\n this.dataSource.unbind(CHANGE, this._refreshHandler);\n this.dataSource = this.options.dataSource = dataSource;\n if (this.fieldMenu) {\n this.fieldMenu.setDataSource(dataSource);\n }\n dataSource.first(CHANGE, this._refreshHandler);\n this.refresh();\n },\n _sortable: function () {\n var that = this;\n if (that.options.enabled) {\n this.sortable = this.element.kendoSortable({\n connectWith: this.options.connectWith,\n hint: that.options.hint,\n filter: '>*:not(.k-empty)',\n cursor: 'move',\n start: function (e) {\n e.item.focus().blur();\n },\n change: function (e) {\n var name = e.item.attr(kendo.attr('name'));\n if (e.action == 'receive') {\n that.add(name);\n } else if (e.action == 'remove') {\n that.remove(name);\n } else if (e.action == 'sort') {\n that.move(name, e.newIndex);\n }\n }\n }).data('kendoSortable');\n }\n },\n _indexOf: function (name, items) {\n var idx, length, index = -1;\n for (idx = 0, length = items.length; idx < length; idx++) {\n if (getName(items[idx]) === name) {\n index = idx;\n break;\n }\n }\n return index;\n },\n _isKPI: function (data) {\n return data.type === 'kpi' || data.measure;\n },\n validate: function (data) {\n var isMeasure = data.type == 2 || 'aggregator' in data || this._isKPI(data);\n if (isMeasure) {\n return this.options.setting === 'measures';\n }\n if (this.options.setting === 'measures') {\n return isMeasure;\n }\n var items = this.dataSource[this.options.setting]();\n var name = data.defaultHierarchy || data.uniqueName;\n if (this._indexOf(name, items) > -1) {\n return false;\n }\n items = this.dataSource[this.options.setting === 'columns' ? 'rows' : 'columns']();\n if (this._indexOf(name, items) > -1) {\n return false;\n }\n return true;\n },\n add: function (name) {\n var items = this.dataSource[this.options.setting]();\n var i, l;\n name = $.isArray(name) ? name.slice(0) : [name];\n for (i = 0, l = name.length; i < l; i++) {\n if (this._indexOf(name[i], items) !== -1) {\n name.splice(i, 1);\n i -= 1;\n l -= 1;\n }\n }\n if (name.length) {\n items = items.concat(name);\n this.dataSource[this.options.setting](items);\n }\n },\n move: function (name, index) {\n var items = this.dataSource[this.options.setting]();\n var idx = this._indexOf(name, items);\n if (idx > -1) {\n name = items.splice(idx, 1)[0];\n items.splice(index, 0, name);\n this.dataSource[this.options.setting](items);\n }\n },\n remove: function (name) {\n var items = this.dataSource[this.options.setting]();\n var idx = this._indexOf(name, items);\n var sortExpressions = this.dataSource.sort();\n var filter = this.dataSource.filter();\n if (idx > -1) {\n if (filter) {\n filter.filters = removeExpr(filter.filters, name);\n this.dataSource._filter.filters = filter.filters;\n if (!filter.filters.length) {\n this.dataSource._filter = null;\n }\n }\n if (sortExpressions) {\n sortExpressions = removeExpr(sortExpressions, name);\n this.dataSource._sort = sortExpressions;\n }\n items.splice(idx, 1);\n this.dataSource[this.options.setting](items);\n }\n },\n sort: function (expr) {\n var sortable = this.options.sortable;\n var allowUnsort = sortable === true || sortable.allowUnsort;\n var skipExpr = allowUnsort && expr.dir === 'asc';\n var expressions = this.dataSource.sort() || [];\n var result = removeExpr(expressions, expr.field);\n if (skipExpr && expressions.length !== result.length) {\n expr = null;\n }\n if (expr) {\n result.push(expr);\n }\n this.dataSource.sort(result);\n },\n refresh: function () {\n var html = '';\n var items = this.dataSource[this.options.setting]();\n var length = items.length;\n var idx = 0;\n var item;\n if (length) {\n for (; idx < length; idx++) {\n item = items[idx];\n item = item.name === undefined ? { name: item } : item;\n html += this.template(extend({ sortIcon: this._sortIcon(item.name) }, item));\n }\n } else {\n html = this.emptyTemplate(this.options.messages.empty);\n }\n this.element.html(html);\n },\n destroy: function () {\n Widget.fn.destroy.call(this);\n this.dataSource.unbind(CHANGE, this._refreshHandler);\n this.element.off(NS);\n if (this.sortable) {\n this.sortable.destroy();\n }\n if (this.fieldMenu) {\n this.fieldMenu.destroy();\n }\n this.element = null;\n this._refreshHandler = null;\n },\n _sortIcon: function (name) {\n var expressions = this.dataSource.sort();\n var expr = sortExpr(expressions, getName(name));\n var icon = '';\n if (expr) {\n icon = 'k-i-sort-' + expr.dir;\n }\n return icon;\n }\n });\n var PivotGrid = Widget.extend({\n init: function (element, options) {\n var that = this;\n var columnBuilder;\n var rowBuilder;\n Widget.fn.init.call(that, element, options);\n that._dataSource();\n that._bindConfigurator();\n that._wrapper();\n that._createLayout();\n that._columnBuilder = columnBuilder = new ColumnBuilder();\n that._rowBuilder = rowBuilder = new RowBuilder();\n that._contentBuilder = new ContentBuilder();\n that._templates();\n that.columnsHeader.add(that.rowsHeader).on('click', 'span.k-icon', function () {\n var button = $(this);\n var builder = columnBuilder;\n var action = 'expandColumn';\n var eventName;\n var path = button.attr(kendo.attr('path'));\n var eventArgs = {\n axis: 'columns',\n path: $.parseJSON(path)\n };\n if (button.parent().is('td')) {\n builder = rowBuilder;\n action = 'expandRow';\n eventArgs.axis = 'rows';\n }\n var expanded = button.hasClass(STATE_EXPANDED);\n var metadata = builder.metadata[path];\n var request = metadata.expanded === undefined;\n eventName = expanded ? COLLAPSEMEMBER : EXPANDMEMBER;\n eventArgs.childrenLoaded = metadata.maxChildren > metadata.children;\n if (that.trigger(eventName, eventArgs)) {\n return;\n }\n builder.metadata[path].expanded = !expanded;\n button.toggleClass(STATE_EXPANDED, !expanded).toggleClass(STATE_COLLAPSED, expanded);\n if (!expanded && request) {\n that.dataSource[action](eventArgs.path);\n } else {\n that.refresh();\n }\n });\n that._scrollable();\n if (that.options.autoBind) {\n that.dataSource.fetch();\n }\n kendo.notify(that);\n },\n events: [\n DATABINDING,\n DATABOUND,\n EXPANDMEMBER,\n COLLAPSEMEMBER\n ],\n options: {\n name: 'PivotGrid',\n autoBind: true,\n reorderable: true,\n filterable: false,\n sortable: false,\n height: null,\n columnWidth: 100,\n configurator: '',\n columnHeaderTemplate: null,\n rowHeaderTemplate: null,\n dataCellTemplate: null,\n kpiStatusTemplate: null,\n kpiTrendTemplate: null,\n messages: {\n measureFields: 'Drop Data Fields Here',\n columnFields: 'Drop Column Fields Here',\n rowFields: 'Drop Rows Fields Here'\n }\n },\n _templates: function () {\n var columnTemplate = this.options.columnHeaderTemplate;\n var rowTemplate = this.options.rowHeaderTemplate;\n var dataTemplate = this.options.dataCellTemplate;\n var kpiStatusTemplate = this.options.kpiStatusTemplate;\n var kpiTrendTemplate = this.options.kpiTrendTemplate;\n this._columnBuilder.template = kendo.template(columnTemplate || HEADER_TEMPLATE, { useWithBlock: !!columnTemplate });\n this._contentBuilder.dataTemplate = kendo.template(dataTemplate || DATACELL_TEMPLATE, { useWithBlock: !!dataTemplate });\n this._contentBuilder.kpiStatusTemplate = kendo.template(kpiStatusTemplate || KPISTATUS_TEMPLATE, { useWithBlock: !!kpiStatusTemplate });\n this._contentBuilder.kpiTrendTemplate = kendo.template(kpiTrendTemplate || KPITREND_TEMPLATE, { useWithBlock: !!kpiTrendTemplate });\n this._rowBuilder.template = kendo.template(rowTemplate || HEADER_TEMPLATE, { useWithBlock: !!rowTemplate });\n },\n _bindConfigurator: function () {\n var configurator = this.options.configurator;\n if (configurator) {\n $(configurator).kendoPivotConfigurator('setDataSource', this.dataSource);\n }\n },\n cellInfoByElement: function (element) {\n element = $(element);\n return this.cellInfo(element.index(), element.parent('tr').index());\n },\n cellInfo: function (columnIndex, rowIndex) {\n var contentBuilder = this._contentBuilder;\n var columnInfo = contentBuilder.columnIndexes[columnIndex || 0];\n var rowInfo = contentBuilder.rowIndexes[rowIndex || 0];\n var dataIndex;\n if (!columnInfo || !rowInfo) {\n return null;\n }\n dataIndex = rowInfo.index * contentBuilder.rowLength + columnInfo.index;\n return {\n columnTuple: columnInfo.tuple,\n rowTuple: rowInfo.tuple,\n measure: columnInfo.measure || rowInfo.measure,\n dataItem: this.dataSource.view()[dataIndex]\n };\n },\n setDataSource: function (dataSource) {\n this.options.dataSource = dataSource;\n this._dataSource();\n if (this.measuresTarget) {\n this.measuresTarget.setDataSource(dataSource);\n }\n if (this.rowsTarget) {\n this.rowsTarget.setDataSource(dataSource);\n }\n if (this.columnsTarget) {\n this.columnsTarget.setDataSource(dataSource);\n }\n this._bindConfigurator();\n if (this.options.autoBind) {\n dataSource.fetch();\n }\n },\n setOptions: function (options) {\n Widget.fn.setOptions.call(this, options);\n this._templates();\n },\n destroy: function () {\n Widget.fn.destroy.call(this);\n clearTimeout(this._headerReflowTimeout);\n },\n _dataSource: function () {\n var that = this;\n var dataSource = that.options.dataSource;\n dataSource = $.isArray(dataSource) ? { data: dataSource } : dataSource;\n if (that.dataSource && this._refreshHandler) {\n that.dataSource.unbind(CHANGE, that._refreshHandler).unbind(STATERESET, that._stateResetHandler).unbind(PROGRESS, that._progressHandler).unbind(ERROR, that._errorHandler);\n } else {\n that._refreshHandler = $.proxy(that.refresh, that);\n that._progressHandler = $.proxy(that._requestStart, that);\n that._stateResetHandler = $.proxy(that._stateReset, that);\n that._errorHandler = $.proxy(that._error, that);\n }\n that.dataSource = kendo.data.PivotDataSource.create(dataSource).bind(CHANGE, that._refreshHandler).bind(PROGRESS, that._progressHandler).bind(STATERESET, that._stateResetHandler).bind(ERROR, that._errorHandler);\n },\n _error: function () {\n this._progress(false);\n },\n _requestStart: function () {\n this._progress(true);\n },\n _stateReset: function () {\n this._columnBuilder.reset();\n this._rowBuilder.reset();\n },\n _wrapper: function () {\n var height = this.options.height;\n this.wrapper = this.element.addClass('k-widget k-pivot');\n if (height) {\n this.wrapper.css('height', height);\n }\n },\n _measureFields: function () {\n this.measureFields = $(DIV).addClass('k-pivot-toolbar k-header k-settings-measures');\n this.measuresTarget = this._createSettingTarget(this.measureFields, {\n setting: 'measures',\n messages: { empty: this.options.messages.measureFields }\n });\n },\n _createSettingTarget: function (element, options) {\n var template = '${data.name}';\n var sortable = options.sortable;\n var icons = '';\n if (sortable) {\n icons += '#if (data.sortIcon) {#';\n icons += '';\n icons += '#}#';\n }\n if (options.filterable || sortable) {\n icons += '';\n }\n if (this.options.reorderable) {\n icons += '';\n }\n if (icons) {\n template += '' + icons + '';\n }\n template += '';\n return new kendo.ui.PivotSettingTarget(element, $.extend({\n template: template,\n emptyTemplate: '${data}',\n enabled: this.options.reorderable,\n dataSource: this.dataSource\n }, options));\n },\n _initSettingTargets: function () {\n this.columnsTarget = this._createSettingTarget(this.columnFields, {\n connectWith: this.rowFields,\n setting: 'columns',\n filterable: this.options.filterable,\n sortable: this.options.sortable,\n messages: {\n empty: this.options.messages.columnFields,\n fieldMenu: this.options.messages.fieldMenu\n }\n });\n this.rowsTarget = this._createSettingTarget(this.rowFields, {\n connectWith: this.columnFields,\n setting: 'rows',\n filterable: this.options.filterable,\n sortable: this.options.sortable,\n messages: {\n empty: this.options.messages.rowFields,\n fieldMenu: this.options.messages.fieldMenu\n }\n });\n },\n _createLayout: function () {\n var that = this;\n var layoutTable = $(LAYOUT_TABLE);\n var leftContainer = layoutTable.find('.k-pivot-rowheaders');\n var rightContainer = layoutTable.find('.k-pivot-table');\n var gridWrapper = $(DIV).addClass('k-grid k-widget');\n that._measureFields();\n that.columnFields = $(DIV).addClass('k-pivot-toolbar k-header k-settings-columns');\n that.rowFields = $(DIV).addClass('k-pivot-toolbar k-header k-settings-rows');\n that.columnsHeader = $('
').wrap('
');\n that.columnsHeader.parent().css('padding-right', kendo.support.scrollbar());\n that.rowsHeader = $('
');\n that.content = $('
');\n leftContainer.append(that.measureFields);\n leftContainer.append(that.rowFields);\n leftContainer.append(that.rowsHeader);\n gridWrapper.append(that.columnsHeader.parent());\n gridWrapper.append(that.content);\n rightContainer.append(that.columnFields);\n rightContainer.append(gridWrapper);\n that.wrapper.append(layoutTable);\n that.columnsHeaderTree = new kendo.dom.Tree(that.columnsHeader[0]);\n that.rowsHeaderTree = new kendo.dom.Tree(that.rowsHeader[0]);\n that.contentTree = new kendo.dom.Tree(that.content[0]);\n that._initSettingTargets();\n },\n _progress: function (toggle) {\n kendo.ui.progress(this.wrapper, toggle);\n },\n _resize: function () {\n if (this.content[0].firstChild) {\n this._setSectionsWidth();\n this._setSectionsHeight();\n this._setContentWidth();\n this._setContentHeight();\n this._columnHeaderReflow();\n }\n },\n _columnHeaderReflow: function () {\n var columnTable = this.columnsHeader.children('table');\n if (!kendo.support.browser.mozilla) {\n return;\n }\n clearTimeout(this._headerReflowTimeout);\n columnTable.css('table-layout', 'auto');\n this._headerReflowTimeout = setTimeout(function () {\n columnTable.css('table-layout', '');\n });\n },\n _setSectionsWidth: function () {\n var rowsHeader = this.rowsHeader;\n var leftColumn = rowsHeader.parent('.k-pivot-rowheaders').width(AUTO);\n var width;\n width = Math.max(outerWidth(this.measureFields), outerWidth(this.rowFields));\n width = Math.max(rowsHeader.children('table').width(), width);\n leftColumn.width(width);\n },\n _setSectionsHeight: function () {\n var measureFieldsHeight = this.measureFields.height(AUTO).height();\n var columnFieldsHeight = this.columnFields.height(AUTO).height();\n var rowFieldsHeight = this.rowFields.height(AUTO).innerHeight();\n var columnsHeight = this.columnsHeader.height(AUTO).innerHeight();\n var padding = rowFieldsHeight - this.rowFields.height();\n var firstRowHeight = columnFieldsHeight > measureFieldsHeight ? columnFieldsHeight : measureFieldsHeight;\n var secondRowHeight = columnsHeight > rowFieldsHeight ? columnsHeight : rowFieldsHeight;\n this.measureFields.height(firstRowHeight);\n this.columnFields.height(firstRowHeight);\n this.rowFields.height(secondRowHeight - padding);\n this.columnsHeader.height(secondRowHeight);\n },\n _setContentWidth: function () {\n var contentTable = this.content.find('table');\n var columnTable = this.columnsHeader.children('table');\n var rowLength = contentTable.children('colgroup').children().length;\n var calculatedWidth = rowLength * this.options.columnWidth;\n var minWidth = Math.ceil(calculatedWidth / this.content.width() * 100);\n if (minWidth < 100) {\n minWidth = 100;\n }\n contentTable.add(columnTable).css('width', minWidth + '%');\n this._resetColspan(columnTable);\n },\n _setContentHeight: function () {\n var that = this;\n var content = that.content;\n var rowsHeader = that.rowsHeader;\n var innerHeight = that.wrapper.innerHeight();\n var scrollbar = kendo.support.scrollbar();\n var skipScrollbar = content[0].offsetHeight === content[0].clientHeight;\n var height = that.options.height;\n if (that.wrapper.is(':visible')) {\n if (!innerHeight || !height) {\n if (skipScrollbar) {\n scrollbar = 0;\n }\n content.height('auto');\n rowsHeader.height(content.height() - scrollbar);\n return;\n }\n innerHeight -= outerHeight(that.columnFields);\n innerHeight -= outerHeight(that.columnsHeader.parent());\n if (innerHeight <= scrollbar * 2) {\n innerHeight = scrollbar * 2 + 1;\n if (!skipScrollbar) {\n innerHeight += scrollbar;\n }\n }\n content.height(innerHeight);\n if (skipScrollbar) {\n scrollbar = 0;\n }\n rowsHeader.height(innerHeight - scrollbar);\n }\n },\n _resetColspan: function (columnTable) {\n var that = this;\n var cell = columnTable.children('tbody').children(':first').children(':first');\n if (that._colspan === undefined) {\n that._colspan = cell.attr('colspan');\n }\n cell.attr('colspan', 1);\n clearTimeout(that._layoutTimeout);\n that._layoutTimeout = setTimeout(function () {\n cell.attr('colspan', that._colspan);\n that._colspan = undefined;\n });\n },\n _axisMeasures: function (axis) {\n var result = [];\n var dataSource = this.dataSource;\n var measures = dataSource.measures();\n var hasMeasure = measures.length > 1 || measures[0] && measures[0].type;\n if (dataSource.measuresAxis() === axis) {\n if (dataSource[axis]().length === 0 || hasMeasure) {\n result = measures;\n }\n }\n return result;\n },\n items: function () {\n return [];\n },\n refresh: function () {\n var that = this;\n var dataSource = that.dataSource;\n var axes = dataSource.axes();\n var columns = (axes.columns || {}).tuples || [];\n var rows = (axes.rows || {}).tuples || [];\n var columnBuilder = that._columnBuilder;\n var rowBuilder = that._rowBuilder;\n var columnAxis = {};\n var rowAxis = {};\n if (that.trigger(DATABINDING, { action: 'rebind' })) {\n return;\n }\n columnBuilder.measures = that._axisMeasures(AXIS_COLUMNS);\n rowBuilder.measures = that._axisMeasures(AXIS_ROWS);\n that.columnsHeaderTree.render(columnBuilder.build(columns));\n that.rowsHeaderTree.render(rowBuilder.build(rows));\n columnAxis = {\n indexes: columnBuilder._indexes,\n measures: columnBuilder.measures,\n metadata: columnBuilder.metadata\n };\n rowAxis = {\n indexes: rowBuilder._indexes,\n measures: rowBuilder.measures,\n metadata: rowBuilder.metadata\n };\n that.contentTree.render(that._contentBuilder.build(dataSource.view(), columnAxis, rowAxis));\n that._resize();\n if (that.touchScroller) {\n that.touchScroller.contentResized();\n } else {\n var touchScroller = kendo.touchScroller(that.content);\n if (touchScroller && touchScroller.movable) {\n that.touchScroller = touchScroller;\n touchScroller.movable.bind('change', function (e) {\n that.columnsHeader.scrollLeft(-e.sender.x);\n that.rowsHeader.scrollTop(-e.sender.y);\n });\n }\n }\n that._progress(false);\n that.trigger(DATABOUND);\n },\n _scrollable: function () {\n var that = this;\n var columnsHeader = that.columnsHeader;\n var rowsHeader = that.rowsHeader;\n that.content.scroll(function () {\n columnsHeader.scrollLeft(this.scrollLeft);\n rowsHeader.scrollTop(this.scrollTop);\n });\n rowsHeader.bind('DOMMouseScroll' + NS + ' mousewheel' + NS, $.proxy(that._wheelScroll, that));\n },\n _wheelScroll: function (e) {\n if (e.ctrlKey) {\n return;\n }\n var delta = kendo.wheelDeltaY(e);\n var scrollTop = this.content.scrollTop();\n if (delta) {\n e.preventDefault();\n $(e.currentTarget).one('wheel' + NS, false);\n this.rowsHeader.scrollTop(scrollTop + -delta);\n this.content.scrollTop(scrollTop + -delta);\n }\n }\n });\n var element = kendo.dom.element;\n var htmlNode = kendo.dom.html;\n var createMetadata = function (levelNum, memberIdx) {\n return {\n maxChildren: 0,\n children: 0,\n maxMembers: 0,\n members: 0,\n measures: 1,\n levelNum: levelNum,\n parentMember: memberIdx !== 0\n };\n };\n var buildPath = function (tuple, index) {\n var path = [];\n var idx = 0;\n for (; idx <= index; idx++) {\n path.push(tuple.members[idx].name);\n }\n return path;\n };\n var tupleName = function (tuple, index) {\n var name = '';\n var idx = 0;\n for (; idx <= index; idx++) {\n name += tuple.members[idx].name;\n }\n return name;\n };\n var ColumnBuilder = Class.extend({\n init: function () {\n this.measures = 1;\n this.metadata = {};\n },\n build: function (tuples) {\n var tbody = this._tbody(tuples);\n var colgroup = this._colGroup();\n return [element('table', null, [\n colgroup,\n tbody\n ])];\n },\n reset: function () {\n this.metadata = {};\n },\n _colGroup: function () {\n var length = this._rowLength();\n var children = [];\n var idx = 0;\n for (; idx < length; idx++) {\n children.push(element('col', null));\n }\n return element('colgroup', null, children);\n },\n _tbody: function (tuples) {\n var root = tuples[0];\n this.map = {};\n this.rows = [];\n this.rootTuple = root;\n this._indexes = [];\n if (root) {\n this._buildRows(root, 0);\n this._normalize();\n } else {\n this.rows.push(element('tr', null, [element('th', null, [htmlNode(' ')])]));\n }\n return element('tbody', null, this.rows);\n },\n _normalize: function () {\n var rows = this.rows;\n var rowsLength = rows.length;\n var rowIdx = 0;\n var row;\n var cellsLength;\n var cellIdx;\n var cells;\n var cell;\n for (; rowIdx < rowsLength; rowIdx++) {\n row = rows[rowIdx];\n if (row.rowSpan === 1) {\n continue;\n }\n cells = row.children;\n cellIdx = 0;\n cellsLength = cells.length;\n for (; cellIdx < cellsLength; cellIdx++) {\n cell = cells[cellIdx];\n if (cell.tupleAll) {\n cell.attr.rowSpan = row.rowSpan;\n }\n }\n }\n },\n _rowIndex: function (row) {\n var rows = this.rows;\n var length = rows.length;\n var idx = 0;\n for (; idx < length; idx++) {\n if (rows[idx] === row) {\n break;\n }\n }\n return idx;\n },\n _rowLength: function () {\n var cells = this.rows[0] ? this.rows[0].children : [];\n var length = cells.length;\n var rowLength = 0;\n var idx = 0;\n if (length) {\n for (; idx < length; idx++) {\n rowLength += cells[idx].attr.colSpan || 1;\n }\n }\n if (!rowLength) {\n rowLength = this.measures;\n }\n return rowLength;\n },\n _row: function (tuple, memberIdx, parentMember) {\n var rootName = this.rootTuple.members[memberIdx].name;\n var levelNum = tuple.members[memberIdx].levelNum;\n var rowKey = rootName + levelNum;\n var map = this.map;\n var parentRow;\n var children;\n var row = map[rowKey];\n if (!row) {\n row = element('tr', null, []);\n row.parentMember = parentMember;\n row.collapsed = 0;\n row.colSpan = 0;\n row.rowSpan = 1;\n map[rowKey] = row;\n parentRow = map[rootName + (Number(levelNum) - 1)];\n if (parentRow) {\n children = parentRow.children;\n if (children[1] && children[1].attr.className.indexOf('k-alt') === -1) {\n row.notFirst = true;\n } else {\n row.notFirst = parentRow.notFirst;\n }\n }\n this.rows.splice(this._rowIndex(parentRow) + 1, 0, row);\n } else {\n row.notFirst = false;\n if (!row.parentMember || row.parentMember !== parentMember) {\n row.parentMember = parentMember;\n row.collapsed = 0;\n row.colSpan = 0;\n }\n }\n return row;\n },\n _measures: function (measures, tuple, className) {\n var map = this.map;\n var row = map.measureRow;\n var measure;\n if (!row) {\n row = element('tr', null, []);\n map.measureRow = row;\n this.rows.push(row);\n }\n for (var idx = 0, length = measures.length; idx < length; idx++) {\n measure = measures[idx];\n row.children.push(this._cell(className || '', [this._content(measure, tuple)], measure));\n }\n return length;\n },\n _content: function (member, tuple) {\n return htmlNode(this.template({\n member: member,\n tuple: tuple\n }));\n },\n _cell: function (className, children, member) {\n var cell = element('th', { className: 'k-header' + className }, children);\n cell.value = member.caption || member.name;\n return cell;\n },\n _buildRows: function (tuple, memberIdx, parentMember) {\n var members = tuple.members;\n var member = members[memberIdx];\n var nextMember = members[memberIdx + 1];\n var row, childRow, children, childrenLength;\n var cell, allCell, cellAttr;\n var cellChildren = [];\n var path;\n var idx = 0;\n var metadata;\n var colSpan;\n var collapsed = 0;\n var memberCollapsed = 0;\n if (member.measure) {\n this._measures(member.children, tuple);\n return;\n }\n path = kendo.stringify(buildPath(tuple, memberIdx));\n row = this._row(tuple, memberIdx, parentMember);\n children = member.children;\n childrenLength = children.length;\n metadata = this.metadata[path];\n if (!metadata) {\n this.metadata[path] = metadata = createMetadata(Number(member.levelNum), memberIdx);\n metadata.rootLevelNum = Number(this.rootTuple.members[memberIdx].levelNum);\n }\n this._indexes.push({\n path: path,\n tuple: tuple\n });\n if (member.hasChildren) {\n if (metadata.expanded === false) {\n collapsed = metadata.maxChildren;\n row.collapsed += collapsed;\n metadata.children = 0;\n childrenLength = 0;\n }\n cellAttr = { className: 'k-icon ' + (childrenLength ? STATE_EXPANDED : STATE_COLLAPSED) };\n cellAttr[kendo.attr('path')] = path;\n cellChildren.push(element('span', cellAttr));\n }\n cellChildren.push(this._content(member, tuple));\n cell = this._cell(row.notFirst ? ' k-first' : '', cellChildren, member);\n row.children.push(cell);\n row.colSpan += 1;\n if (childrenLength) {\n allCell = this._cell(' k-alt', [this._content(member, tuple)], member);\n row.children.push(allCell);\n for (; idx < childrenLength; idx++) {\n childRow = this._buildRows(children[idx], memberIdx, member);\n }\n colSpan = childRow.colSpan;\n collapsed = childRow.collapsed;\n cell.attr.colSpan = colSpan;\n metadata.children = colSpan;\n metadata.members = 1;\n row.colSpan += colSpan;\n row.collapsed += collapsed;\n row.rowSpan = childRow.rowSpan + 1;\n if (nextMember) {\n if (nextMember.measure) {\n colSpan = this._measures(nextMember.children, tuple, ' k-alt');\n } else {\n childRow = this._buildRows(tuple, memberIdx + 1);\n colSpan = childRow.colSpan;\n row.collapsed += childRow.collapsed;\n memberCollapsed = childRow.collapsed;\n }\n allCell.attr.colSpan = colSpan;\n colSpan -= 1;\n metadata.members += colSpan;\n row.colSpan += colSpan;\n }\n } else if (nextMember) {\n if (nextMember.measure) {\n colSpan = this._measures(nextMember.children, tuple);\n } else {\n childRow = this._buildRows(tuple, memberIdx + 1);\n colSpan = childRow.colSpan;\n row.collapsed += childRow.collapsed;\n memberCollapsed = childRow.collapsed;\n }\n metadata.members = colSpan;\n if (colSpan > 1) {\n cell.attr.colSpan = colSpan;\n row.colSpan += colSpan - 1;\n }\n }\n if (metadata.maxMembers < metadata.members + memberCollapsed) {\n metadata.maxMembers = metadata.members + memberCollapsed;\n }\n children = metadata.children + collapsed;\n if (metadata.maxChildren < children) {\n metadata.maxChildren = children;\n }\n (allCell || cell).tupleAll = true;\n return row;\n }\n });\n var RowBuilder = Class.extend({\n init: function () {\n this.metadata = {};\n },\n build: function (tuples) {\n var tbody = this._tbody(tuples);\n var colgroup = this._colGroup();\n return [element('table', null, [\n colgroup,\n tbody\n ])];\n },\n reset: function () {\n this.metadata = {};\n },\n _rowLength: function () {\n var children = this.rows[0].children;\n var length = 0;\n var idx = 0;\n var cell = children[idx];\n while (cell) {\n length += cell.attr.colSpan || 1;\n cell = children[++idx];\n }\n return length;\n },\n _colGroup: function () {\n var length = this._rowLength();\n var children = [];\n var idx = 0;\n for (; idx < length; idx++) {\n children.push(element('col', null));\n }\n return element('colgroup', null, children);\n },\n _tbody: function (tuples) {\n var root = tuples[0];\n this.rootTuple = root;\n this.rows = [];\n this.map = {};\n this._indexes = [];\n if (root) {\n this._buildRows(root, 0);\n this._normalize();\n } else {\n this.rows.push(element('tr', null, [element('td', null, [htmlNode(' ')])]));\n }\n return element('tbody', null, this.rows);\n },\n _normalize: function () {\n var rows = this.rows;\n var rowsLength = rows.length;\n var rowIdx = 0;\n var members = this.rootTuple.members;\n var firstMemberName = members[0].name;\n var membersLength = members.length;\n var memberIdx = 0;\n var row;\n var cell;\n var maxcolSpan;\n var map = this.map;\n var allRow;\n for (; rowIdx < rowsLength; rowIdx++) {\n row = rows[rowIdx];\n for (memberIdx = 0; memberIdx < membersLength; memberIdx++) {\n maxcolSpan = this[members[memberIdx].name];\n cell = row.colSpan['dim' + memberIdx];\n if (cell && cell.colSpan < maxcolSpan) {\n cell.attr.colSpan = maxcolSpan - cell.colSpan + 1;\n }\n }\n }\n row = map[firstMemberName];\n allRow = map[firstMemberName + 'all'];\n if (row) {\n row.children[0].attr.className = 'k-first';\n }\n if (allRow) {\n allRow.children[0].attr.className += ' k-first';\n }\n },\n _row: function (children) {\n var row = element('tr', null, children);\n row.rowSpan = 1;\n row.colSpan = {};\n this.rows.push(row);\n return row;\n },\n _content: function (member, tuple) {\n return htmlNode(this.template({\n member: member,\n tuple: tuple\n }));\n },\n _cell: function (className, children, member) {\n var cell = element('td', { className: className }, children);\n cell.value = member.caption || member.name;\n return cell;\n },\n _buildRows: function (tuple, memberIdx) {\n var map = this.map;\n var path;\n var members = tuple.members;\n var member = members[memberIdx];\n var nextMember = members[memberIdx + 1];\n var children = member.children;\n var childrenLength = children.length;\n var levelNum = Number(member.levelNum);\n var rootName = this.rootTuple.members[memberIdx].name;\n var tuplePath = buildPath(tuple, memberIdx - 1).join('');\n var rootLevelNum = Number(this.rootTuple.members[memberIdx].levelNum);\n var parentName = tuplePath + (rootLevelNum === levelNum ? '' : member.parentName || '');\n var row = map[parentName + 'all'] || map[parentName];\n var colSpan = levelNum + 1;\n var cell, allCell;\n var childRow, allRow;\n var metadata;\n var className;\n var cellChildren = [];\n var expandIconAttr;\n var idx;\n if (!row || row.hasChild) {\n row = this._row();\n } else {\n row.hasChild = true;\n }\n if (member.measure) {\n className = row.allCell ? 'k-grid-footer' : '';\n row.children.push(this._cell(className, [this._content(children[0], tuple)], children[0]));\n row.rowSpan = childrenLength;\n for (idx = 1; idx < childrenLength; idx++) {\n this._row([this._cell(className, [this._content(children[idx], tuple)], children[idx])]);\n }\n return row;\n }\n map[tuplePath + member.name] = row;\n path = kendo.stringify(buildPath(tuple, memberIdx));\n metadata = this.metadata[path];\n if (!metadata) {\n this.metadata[path] = metadata = createMetadata(levelNum, memberIdx);\n metadata.rootLevelNum = rootLevelNum;\n }\n this._indexes.push({\n path: path,\n tuple: tuple\n });\n if (member.hasChildren) {\n if (metadata.expanded === false) {\n childrenLength = 0;\n metadata.children = 0;\n }\n expandIconAttr = { className: 'k-icon ' + (childrenLength ? STATE_EXPANDED : STATE_COLLAPSED) };\n expandIconAttr[kendo.attr('path')] = path;\n cellChildren.push(element('span', expandIconAttr));\n }\n cellChildren.push(this._content(member, tuple));\n className = row.allCell && !childrenLength ? 'k-grid-footer' : '';\n cell = this._cell(className, cellChildren, member);\n cell.colSpan = colSpan;\n row.children.push(cell);\n row.colSpan['dim' + memberIdx] = cell;\n if (!this[rootName] || this[rootName] < colSpan) {\n this[rootName] = colSpan;\n }\n if (childrenLength) {\n row.allCell = false;\n row.hasChild = false;\n for (idx = 0; idx < childrenLength; idx++) {\n childRow = this._buildRows(children[idx], memberIdx);\n if (row !== childRow) {\n row.rowSpan += childRow.rowSpan;\n }\n }\n if (row.rowSpan > 1) {\n cell.attr.rowSpan = row.rowSpan;\n }\n metadata.children = row.rowSpan;\n allCell = this._cell('k-grid-footer', [this._content(member, tuple)], member);\n allCell.colSpan = colSpan;\n allRow = this._row([allCell]);\n allRow.colSpan['dim' + memberIdx] = allCell;\n allRow.allCell = true;\n map[tuplePath + member.name + 'all'] = allRow;\n if (nextMember) {\n childRow = this._buildRows(tuple, memberIdx + 1);\n allCell.attr.rowSpan = childRow.rowSpan;\n }\n row.rowSpan += allRow.rowSpan;\n metadata.members = allRow.rowSpan;\n } else if (nextMember) {\n row.hasChild = false;\n this._buildRows(tuple, memberIdx + 1);\n (allCell || cell).attr.rowSpan = row.rowSpan;\n metadata.members = row.rowSpan;\n }\n if (metadata.maxChildren < metadata.children) {\n metadata.maxChildren = metadata.children;\n }\n if (metadata.maxMembers < metadata.members) {\n metadata.maxMembers = metadata.members;\n }\n return row;\n }\n });\n var ContentBuilder = Class.extend({\n init: function () {\n this.columnAxis = {};\n this.rowAxis = {};\n },\n build: function (data, columnAxis, rowAxis) {\n var index = columnAxis.indexes[0];\n var metadata = columnAxis.metadata[index ? index.path : undefined];\n this.columnAxis = columnAxis;\n this.rowAxis = rowAxis;\n this.data = data;\n this.rowLength = metadata ? metadata.maxChildren + metadata.maxMembers : columnAxis.measures.length || 1;\n if (!this.rowLength) {\n this.rowLength = 1;\n }\n var tbody = this._tbody();\n var colgroup = this._colGroup();\n return [element('table', null, [\n colgroup,\n tbody\n ])];\n },\n _colGroup: function () {\n var length = this.columnAxis.measures.length || 1;\n var children = [];\n var idx = 0;\n if (this.rows[0]) {\n length = this.rows[0].children.length;\n }\n for (; idx < length; idx++) {\n children.push(element('col', null));\n }\n return element('colgroup', null, children);\n },\n _tbody: function () {\n this.rows = [];\n if (this.data[0]) {\n this.columnIndexes = this._indexes(this.columnAxis, this.rowLength);\n this.rowIndexes = this._indexes(this.rowAxis, Math.ceil(this.data.length / this.rowLength));\n this._buildRows();\n } else {\n this.rows.push(element('tr', null, [element('td', null, [htmlNode(' ')])]));\n }\n return element('tbody', null, this.rows);\n },\n _indexes: function (axisInfo, total) {\n var result = [];\n var axisInfoMember;\n var indexes = axisInfo.indexes;\n var metadata = axisInfo.metadata;\n var measures = axisInfo.measures;\n var measuresLength = measures.length || 1;\n var current;\n var dataIdx = 0;\n var firstEmpty = 0;\n var idx = 0;\n var length = indexes.length;\n var measureIdx;\n var index;\n var children;\n var skipChildren;\n if (!length) {\n for (measureIdx = 0; measureIdx < measuresLength; measureIdx++) {\n result[measureIdx] = {\n index: measureIdx,\n measure: measures[measureIdx],\n tuple: null\n };\n }\n return result;\n }\n for (; idx < length; idx++) {\n axisInfoMember = indexes[idx];\n current = metadata[axisInfoMember.path];\n children = current.children + current.members;\n skipChildren = 0;\n if (children) {\n children -= measuresLength;\n }\n if (current.expanded === false && current.children !== current.maxChildren) {\n skipChildren = current.maxChildren;\n }\n if (current.parentMember && current.levelNum === current.rootLevelNum) {\n children = -1;\n }\n if (children > -1) {\n for (measureIdx = 0; measureIdx < measuresLength; measureIdx++) {\n index = children + measureIdx;\n if (!current.children) {\n index += firstEmpty;\n }\n result[children + firstEmpty + measureIdx] = {\n children: children,\n index: dataIdx,\n measure: measures[measureIdx],\n tuple: axisInfoMember.tuple\n };\n dataIdx += 1;\n }\n while (result[firstEmpty] !== undefined) {\n firstEmpty += 1;\n }\n }\n if (firstEmpty === total) {\n break;\n }\n dataIdx += skipChildren;\n }\n return result;\n },\n _buildRows: function () {\n var rowIndexes = this.rowIndexes;\n var length = rowIndexes.length;\n var idx = 0;\n for (; idx < length; idx++) {\n var rowIndex = rowIndexes[idx];\n if (rowIndex) {\n this.rows.push(this._buildRow(rowIndex));\n }\n }\n },\n _buildRow: function (rowInfo) {\n var startIdx = rowInfo.index * this.rowLength;\n var columnIndexes = this.columnIndexes;\n var length = columnIndexes.length;\n var columnInfo;\n var cells = [];\n var idx = 0;\n var templateInfo;\n var cell, cellContent;\n var attr, dataItem, measure;\n for (; idx < length; idx++) {\n columnInfo = columnIndexes[idx];\n if (columnInfo === undefined) {\n continue;\n }\n attr = {};\n if (columnInfo.children) {\n attr.className = 'k-alt';\n }\n cellContent = '';\n dataItem = this.data[startIdx + columnInfo.index];\n measure = columnInfo.measure || rowInfo.measure;\n templateInfo = {\n columnTuple: columnInfo.tuple,\n rowTuple: rowInfo.tuple,\n measure: measure,\n dataItem: dataItem\n };\n if (dataItem.value !== '' && measure && measure.type) {\n if (measure.type === 'status') {\n cellContent = this.kpiStatusTemplate(templateInfo);\n } else if (measure.type === 'trend') {\n cellContent = this.kpiTrendTemplate(templateInfo);\n }\n }\n if (!cellContent) {\n cellContent = this.dataTemplate(templateInfo);\n }\n cell = element('td', attr, [htmlNode(cellContent)]);\n cell.value = dataItem.value;\n cells.push(cell);\n }\n attr = {};\n if (rowInfo.children) {\n attr.className = 'k-grid-footer';\n }\n return element('tr', attr, cells);\n }\n });\n ui.plugin(PivotGrid);\n kendo.PivotExcelExporter = kendo.Class.extend({\n init: function (options) {\n this.options = options;\n this.widget = options.widget;\n this.dataSource = this.widget.dataSource;\n },\n _columns: function () {\n var columnHeaderTable = this.widget.columnsHeaderTree.children[0];\n var rowHeaderTable = this.widget.rowsHeaderTree.children[0];\n var columnHeaderLength = columnHeaderTable.children[0].children.length;\n var rowHeaderLength = rowHeaderTable.children[0].children.length;\n var width = this.widget.options.columnWidth;\n var result = [];\n var idx;\n if (rowHeaderLength && this.dataSource.data()[0]) {\n for (idx = 0; idx < rowHeaderLength; idx++) {\n result.push({ autoWidth: true });\n }\n }\n for (idx = 0; idx < columnHeaderLength; idx++) {\n result.push({\n autoWidth: false,\n width: width\n });\n }\n return result;\n },\n _cells: function (rows, type, callback) {\n var result = [];\n var i = 0;\n var length = rows.length;\n var cellsLength;\n var row, cells;\n var j, cell;\n for (; i < length; i++) {\n row = [];\n cells = rows[i].children;\n cellsLength = cells.length;\n for (j = 0; j < cellsLength; j++) {\n cell = cells[j];\n row.push({\n background: '#7a7a7a',\n color: '#fff',\n value: cell.value,\n colSpan: cell.attr.colSpan || 1,\n rowSpan: cell.attr.rowSpan || 1\n });\n }\n if (callback) {\n callback(row, i);\n }\n result.push({\n cells: row,\n type: type\n });\n }\n return result;\n },\n _rows: function () {\n var columnHeaderTable = this.widget.columnsHeaderTree.children[0];\n var rowHeaderTable = this.widget.rowsHeaderTree.children[0];\n var columnHeaderLength = columnHeaderTable.children[0].children.length;\n var rowHeaderLength = rowHeaderTable.children[0].children.length;\n var columnHeaderRows = columnHeaderTable.children[1].children;\n var rowHeaderRows = rowHeaderTable.children[1].children;\n var contentRows = this.widget.contentTree.children[0].children[1].children;\n var columnRows = this._cells(columnHeaderRows, 'header');\n if (rowHeaderLength) {\n columnRows[0].cells.splice(0, 0, {\n background: '#7a7a7a',\n color: '#fff',\n value: '',\n colSpan: rowHeaderLength,\n rowSpan: columnHeaderRows.length\n });\n }\n var dataCallback = function (row, index) {\n var j = 0;\n var cell, value;\n var cells = contentRows[index].children;\n for (; j < columnHeaderLength; j++) {\n cell = cells[j];\n value = Number(cell.value);\n if (isNaN(value)) {\n value = cell.value;\n }\n row.push({\n background: '#dfdfdf',\n color: '#333',\n value: value,\n colSpan: 1,\n rowSpan: 1\n });\n }\n };\n var rowRows = this._cells(rowHeaderRows, 'data', dataCallback);\n return columnRows.concat(rowRows);\n },\n _freezePane: function () {\n var columnHeaderTable = this.widget.columnsHeaderTree.children[0];\n var rowHeaderTable = this.widget.rowsHeaderTree.children[0];\n var rowHeaderLength = rowHeaderTable.children[0].children.length;\n var columnHeaderRows = columnHeaderTable.children[1].children;\n return {\n colSplit: rowHeaderLength,\n rowSplit: columnHeaderRows.length\n };\n },\n workbook: function () {\n var promise;\n if (this.dataSource.view()[0]) {\n promise = $.Deferred();\n promise.resolve();\n } else {\n promise = this.dataSource.fetch();\n }\n return promise.then($.proxy(function () {\n return {\n sheets: [{\n columns: this._columns(),\n rows: this._rows(),\n freezePane: this._freezePane(),\n filter: null\n }]\n };\n }, this));\n }\n });\n var PivotExcelMixin = {\n extend: function (proto) {\n proto.events.push('excelExport');\n proto.options.excel = $.extend(proto.options.excel, this.options);\n proto.saveAsExcel = this.saveAsExcel;\n },\n options: {\n proxyURL: '',\n filterable: false,\n fileName: 'Export.xlsx'\n },\n saveAsExcel: function () {\n var excel = this.options.excel || {};\n var exporter = new kendo.PivotExcelExporter({ widget: this });\n exporter.workbook().then($.proxy(function (book) {\n if (!this.trigger('excelExport', { workbook: book })) {\n var workbook = new kendo.ooxml.Workbook(book);\n workbook.toDataURLAsync().then(function (dataURI) {\n kendo.saveAs({\n dataURI: dataURI,\n fileName: book.fileName || excel.fileName,\n proxyURL: excel.proxyURL,\n forceProxy: excel.forceProxy\n });\n });\n }\n }, this));\n }\n };\n kendo.PivotExcelMixin = PivotExcelMixin;\n if (kendo.ooxml && kendo.ooxml.Workbook) {\n PivotExcelMixin.extend(PivotGrid.prototype);\n }\n if (kendo.PDFMixin) {\n kendo.PDFMixin.extend(PivotGrid.prototype);\n PivotGrid.fn._drawPDF = function () {\n return this._drawPDFShadow({ width: this.wrapper.width() }, { avoidLinks: this.options.pdf.avoidLinks });\n };\n }\n }(window.kendo.jQuery));\n return window.kendo;\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));"]}