{"version":3,"sources":["kendo.data.js"],"names":["f","define","$","undefined","eventHandler","context","type","field","prefix","e","key","event","CHANGE","_notifyChange","trigger","equal","x","y","xtype","ytype","getTime","getFieldByName","obj","name","fieldName","isPlainObject","Query","data","this","normalizeSort","dir","descriptor","STRING","descriptors","isArray","grep","d","normalizeOperator","expression","idx","length","filter","operator","filters","operatorMap","toLowerCase","normalizeFilter","isEmptyObject","logic","compareDescriptor","f1","f2","value","normalizeDescriptor","fieldComparer","a","b","compareFilters","expr1","expr2","filters1","filters2","slice","sort","normalizeAggregate","expressions","normalizeGroup","map","aggregates","groupValueComparer","calculateAggregate","accumulator","item","index","state","aggr","functionName","len","aggregate","functions","kendo","accessor","isNumber","val","isNaN","isDate","toJSON","array","result","Array","serializeRecords","getters","modelInstance","originalFieldNames","fieldNames","record","getter","originalName","setters","setter","convertRecords","_parse","convertGroup","hasSubgroups","items","wrapDataAccess","originalFunction","model","converter","toString","call","ObservableArray","mergeGroups","target","dest","skip","take","group","concat","splice","flattenGroups","itemIndex","at","push","wrapGroupItems","LazyObservableArray","eachGroupItems","func","replaceInRanges","ranges","observable","replaceInRange","replaceWithObservable","view","serverGrouping","viewIndex","removeModel","dataItem","uid","indexOfPristineModel","indexOf","idField","id","_defaultId","indexOfModel","comparer","fieldNameFromModel","fields","from","isFunction","convertFilterDescriptorsField","convertDescriptorsField","inferSelect","select","options","firstField","secondField","optgroup","option","parentNode","disabled","label","text","attributes","specified","inferTable","table","fieldIndex","cells","cell","empty","tbody","tBodies","rows","fieldCount","nodeName","innerHTML","dataMethod","_data","DataSource","fn","apply","arguments","_attachBubbleHandlers","inferList","list","elements","collection","tagName","add","find","textChild","className","children","textField","urlField","spriteCssClassField","imageUrlField","_loaded","eq","firstChild","attr","nodeType","nodeValue","prop","trim","replace","hasChildren","ObservableObject","parsers","defaultValues","Model","Comparer","StableComparer","operators","LocalTransport","RemoteTransport","Cache","DataReader","Transport","Node","HierarchicalDataSource","Buffer","BatchBuffer","extend","proxy","ajax","each","noop","window","Observable","Class","FUNCTION","CREATE","READ","UPDATE","DESTROY","SYNC","GET","ERROR","REQUESTSTART","PROGRESS","REQUESTEND","crud","identity","o","stringify","math","Math","join","pop","shift","unshift","stableSort","support","dateRegExp","init","that","wrapAll","json","parent","source","wrap","object","bind","node","action","howMany","i","unbind","forEach","callback","thisArg","reduce","reduceRight","every","some","remove","Symbol","iterator","prototype","_parent","member","_handlers","charAt","guid","shouldSerialize","hasOwnProperty","get","_set","paths","path","composite","split","set","isSetPrevented","current","change","isObservableArray","isDataSource","number","parseFloat","date","parseDate","boolean","string","default","Date","defaults","_initializers","dirty","dirtyFields","parse","editable","initiator","accept","isNew","base","proto","functionFields","nullable","defaultValue","selector","compare","localeCompare","create","combine","comparers","asc","valueA","valueB","__position","desc","quote","str","JSON","textOp","impl","ignore","op","exec","getMatchRegexp","pattern","rx","esc","ch","neq","gt","gte","lt","lte","startswith","doesnotstartwith","endswith","n","doesnotendwith","contains","doesnotcontain","matches","substring","doesnotmatch","isempty","isnotempty","isnull","isnotnull","isnullorempty","isnotnullorempty","filterExpr","expr","and","or","fieldFunctions","operatorFunctions","match","ignoreCase","==","equals","isequalto","equalto","!=","ne","notequals","isnotequalto","notequalto","notequal","<","islessthan","lessthan","less","<=","le","islessthanorequalto","lessthanequal",">","isgreaterthan","greaterthan","greater",">=","isgreaterthanorequalto","greaterthanequal","ge","notsubstringof","toArray","range","count","order","inPlace","orderBy","orderByDescending","compiled","predicate","Function","allData","groupBy","currentValue","sorted","_sortForGrouping","groupValue","sum","average","max","min","process","total","query","filterCallback","read","success","update","destroy","parameterMap","url","cache","submit","setup","error","parameters","operation","_store","clear","store","inmemory","schema","dataFunction","groupsFunction","serializeFunction","serializeGetters","modelBase","_dataAccessFunction","groups","serialize","fromName","errors","_map","_prefetch","_pristineData","_ranges","_view","_pristineTotal","_destroyed","_pageSize","pageSize","_page","page","_sort","_filter","_group","_aggregate","_total","_shouldDetachObservableParents","transport","pushCreate","_pushCreate","pushUpdate","_pushUpdate","pushDestroy","_pushDestroy","offlineStorage","_storage","getItem","localStorage","setItem","reader","readers","_detachObservableParents","_observe","_online","serverSorting","serverPaging","serverFiltering","serverAggregates","batch","inPlaceSort","clone","online","sync","Deferred","resolve","promise","offlineData","_isServerGrouped","_push","_readData","_flatData","useRanges","getByUid","_getByUid","dataItems","_storeData","_addRange","_process","_observeView","flatView","insert","_createNewModel","_wrapInEmptyGroup","_insertModelInRange","pushInsert","pushed","autoSync","pristine","rangeSpan","_getCurrentRangeSpan","last","pristineData","_updatePristineForModel","_removeItems","destroyed","found","_eachItem","_removePristineForModel","hasGroups","_removeModelFromRanges","created","updated","promises","_sendSubmit","_send","when","then","_accept","_change","cancelChanges","_cancelModel","_markOfflineUpdatesAsDirty","__state__","hasChanges","models","response","serverGroup","_handleCustomErrors","values","_executeOnPristineForModel","deepExtend","_eachPristineItem","_pristineForModel","_submit","status","reject","deferred","_promise","method","converted","params","_params","_queueRequest","isPrevented","_dequeueRequest","args","_readAggregates","requestParams","itemIds","_aggregateResult","endless","_changeHandler","updatePristine","start","_skip","end","timestamp","_timeStamp","_sortRanges","xhr","errorThrown","_requestInProgress","_pending","_shouldWrap","arrayType","_updateTotalForAction","parseInt","handler","first","_calculateAggregates","_take","_queryProcess","_mergeState","_currentRangeStart","moreItemsCount","remote","fetch","_query","next","totalPages","prev","round","_emptyAggregates","ceil","inRange","_findRange","lastRange","firstItemUid","enableRequestsInProgress","_skipRequestsInProgress","_currentRequestTimeStamp","pageSkip","floor","size","_processRangeData","_rangeExists","prefetch","skipIdx","takeIdx","startIndex","endIndex","rangeData","rangeEnd","processed","flatData","_mergeGroups","prevGroup","temp","paging","sorting","filtering","currentRangeStart","_prefetchSuccessHandler","force","clearTimeout","_timeout","setTimeout","_multiplePrefetch","_updateRangesLength","rangesLength","mismatchFound","mismatchLength","lengthDifference","abs","dataSource","transportOptions","transports","schemas","logToConsole","hasChildrenObject","childrenField","childrenOptions","_childrenOptions","_initChildren","_updateChildrenField","append","loaded","level","_childrenLoaded","load","one","_matchFilter","_hierarchicalFilter","_markHierarchicalQuery","_updateHierarchicalFilter","_find","_dataSource","viewSize","disablePrefetch","_prefetching","buffer","_reset","_syncWithDataSource","setViewSize","_recalculate","itemPresent","dataOffset","prefetchThreshold","midPageThreshold","nextMidRange","nextPageThreshold","nextFullRange","pullBackThreshold","offset","previousMidRange","previousFullRange","_goToRange","nextRange","syncDataSource","prefetchOffset","expanding","_expanding","_syncPending","_firstItemUid","batchSize","batchBuffer","endreached","prefetching","prefetched","reset","resize","jQuery","amd","a1","a2","a3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAwBC,SAAUA,EAAGC,QACVA,OAAO,cACH,aACA,mBACA,kBACDD,IACL,WAs+HE,MA18HC,UAAUE,EAAGC,GAiRV,QAASC,GAAaC,EAASC,EAAMC,EAAOC,GACxC,MAAO,UAAUC,GACb,GAAgBC,GAAZC,IACJ,KAAKD,IAAOD,GACRE,EAAMD,GAAOD,EAAEC,EAGfC,GAAMJ,MADNC,EACcD,EAAQ,IAAME,EAAEF,MAEhBA,EAEdD,GAAQM,IAAUP,EAAQQ,eAC1BR,EAAQQ,cAAcF,GAE1BN,EAAQS,QAAQR,EAAMK,IAkI9B,QAASI,GAAMC,EAAGC,GACd,GAAID,IAAMC,EACN,OAAO,CAEX,IAA0CV,GAAtCW,EAAQhB,EAAEI,KAAKU,GAAIG,EAAQjB,EAAEI,KAAKW,EACtC,IAAIC,IAAUC,EACV,OAAO,CAEX,IAAc,SAAVD,EACA,MAAOF,GAAEI,YAAcH,EAAEG,SAE7B,IAAc,WAAVF,GAAgC,UAAVA,EACtB,OAAO,CAEX,KAAKX,IAASS,GACV,IAAKD,EAAMC,EAAET,GAAQU,EAAEV,IACnB,OAAO,CAGf,QAAO,EA0CX,QAASc,GAAeC,EAAKC,GACzB,GAAIhB,GAAOiB,CACX,KAAKA,IAAaF,GAAK,CAEnB,GADAf,EAAQe,EAAIE,GACRC,GAAclB,IAAUA,EAAMA,O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AQlpB,KAAKkpB,aAK7BK,eAAgB,WACZvpB,KAAKqoB,OAAOkB,kBAEhBzjB,GAAI,SAAUjD,GAAV,GAC2FD,GAIlFoM,EAJLqZ,EAASroB,KAAKqoB,OAAQ9iB,EAAO1C,EAAQ7C,KAAK6pB,UAAWrkB,EAAOxF,KAAK6pB,UAAWpjB,IAIhF,KAHI4hB,EAAOa,OAAS3jB,GAChB8iB,EAAOviB,GAAGuiB,EAAOa,OAAS,GAErBla,EAAI,EAAGA,EAAIxJ,IAChB5C,EAAOylB,EAAOviB,GAAGP,EAAOyJ,GACX,OAATpM,GAFkBoM,IAKtBvI,EAAKV,KAAKnD,EAEd,OAAO6D,IAEXkS,MAAO,WACH,MAAO3Y,MAAKwb,QAEhBvC,QAAS,WACLjZ,KAAKqoB,OAAOpP,UACZjZ,KAAKiP,YAGb7C,IAAO,EAAMhJ,GAAMrD,MACfwc,SAAWhO,KAAMzC,IACjBhM,MAAOA,EACPyJ,WAAYA,GACZ0C,uBAAwBA,GACxBD,KAAMA,GACNZ,iBAAkBA,EAClBjG,gBAAiBA,GACjBc,oBAAqBA,EACrB0F,eAAgBA,EAChBC,gBAAiBA,GACjBC,MAAOA,GACPC,WAAYA,GACZP,MAAOA,EACPW,OAAQA,GACRC,YAAaA,MAEnBM,OAAOrJ,MAAMgnB,QACR3d,OAAOrJ,OACE,kBAAV/E,SAAwBA,OAAOgsB,IAAMhsB,OAAS,SAAUisB,EAAIC,EAAIC,IACrEA,GAAMD","file":"kendo.data.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.data', [\n 'kendo.core',\n 'kendo.data.odata',\n 'kendo.data.xml'\n ], f);\n}(function () {\n var __meta__ = {\n id: 'data',\n name: 'Data source',\n category: 'framework',\n description: 'Powerful component for using local and remote data.Fully supports CRUD, Sorting, Paging, Filtering, Grouping, and Aggregates.',\n depends: ['core'],\n features: [\n {\n id: 'data-odata',\n name: 'OData',\n description: 'Support for accessing Open Data Protocol (OData) services.',\n depends: ['data.odata']\n },\n {\n id: 'data-signalr',\n name: 'SignalR',\n description: 'Support for binding to SignalR hubs.',\n depends: ['data.signalr']\n },\n {\n id: 'data-XML',\n name: 'XML',\n description: 'Support for binding to XML.',\n depends: ['data.xml']\n }\n ]\n };\n (function ($, undefined) {\n var extend = $.extend, proxy = $.proxy, isPlainObject = $.isPlainObject, isEmptyObject = $.isEmptyObject, isArray = $.isArray, grep = $.grep, ajax = $.ajax, map, each = $.each, noop = $.noop, kendo = window.kendo, isFunction = kendo.isFunction, Observable = kendo.Observable, Class = kendo.Class, STRING = 'string', FUNCTION = 'function', CREATE = 'create', READ = 'read', UPDATE = 'update', DESTROY = 'destroy', CHANGE = 'change', SYNC = 'sync', GET = 'get', ERROR = 'error', REQUESTSTART = 'requestStart', PROGRESS = 'progress', REQUESTEND = 'requestEnd', crud = [\n CREATE,\n READ,\n UPDATE,\n DESTROY\n ], identity = function (o) {\n return o;\n }, getter = kendo.getter, stringify = kendo.stringify, math = Math, push = [].push, join = [].join, pop = [].pop, splice = [].splice, shift = [].shift, slice = [].slice, unshift = [].unshift, toString = {}.toString, stableSort = kendo.support.stableSort, dateRegExp = /^\\/Date\\((.*?)\\)\\/$/;\n var ObservableArray = Observable.extend({\n init: function (array, type) {\n var that = this;\n that.type = type || ObservableObject;\n Observable.fn.init.call(that);\n that.length = array.length;\n that.wrapAll(array, that);\n },\n at: function (index) {\n return this[index];\n },\n toJSON: function () {\n var idx, length = this.length, value, json = new Array(length);\n for (idx = 0; idx < length; idx++) {\n value = this[idx];\n if (value instanceof ObservableObject) {\n value = value.toJSON();\n }\n json[idx] = value;\n }\n return json;\n },\n parent: noop,\n wrapAll: function (source, target) {\n var that = this, idx, length, parent = function () {\n return that;\n };\n target = target || [];\n for (idx = 0, length = source.length; idx < length; idx++) {\n target[idx] = that.wrap(source[idx], parent);\n }\n return target;\n },\n wrap: function (object, parent) {\n var that = this, observable;\n if (object !== null && toString.call(object) === '[object Object]') {\n observable = object instanceof that.type || object instanceof Model;\n if (!observable) {\n object = object instanceof ObservableObject ? object.toJSON() : object;\n object = new that.type(object);\n }\n object.parent = parent;\n object.bind(CHANGE, function (e) {\n that.trigger(CHANGE, {\n field: e.field,\n node: e.node,\n index: e.index,\n items: e.items || [this],\n action: e.node ? e.action || 'itemloaded' : 'itemchange'\n });\n });\n }\n return object;\n },\n push: function () {\n var index = this.length, items = this.wrapAll(arguments), result;\n result = push.apply(this, items);\n this.trigger(CHANGE, {\n action: 'add',\n index: index,\n items: items\n });\n return result;\n },\n slice: slice,\n sort: [].sort,\n join: join,\n pop: function () {\n var length = this.length, result = pop.apply(this);\n if (length) {\n this.trigger(CHANGE, {\n action: 'remove',\n index: length - 1,\n items: [result]\n });\n }\n return result;\n },\n splice: function (index, howMany, item) {\n var items = this.wrapAll(slice.call(arguments, 2)), result, i, len;\n result = splice.apply(this, [\n index,\n howMany\n ].concat(items));\n if (result.length) {\n this.trigger(CHANGE, {\n action: 'remove',\n index: index,\n items: result\n });\n for (i = 0, len = result.length; i < len; i++) {\n if (result[i] && result[i].children) {\n result[i].unbind(CHANGE);\n }\n }\n }\n if (item) {\n this.trigger(CHANGE, {\n action: 'add',\n index: index,\n items: items\n });\n }\n return result;\n },\n shift: function () {\n var length = this.length, result = shift.apply(this);\n if (length) {\n this.trigger(CHANGE, {\n action: 'remove',\n index: 0,\n items: [result]\n });\n }\n return result;\n },\n unshift: function () {\n var items = this.wrapAll(arguments), result;\n result = unshift.apply(this, items);\n this.trigger(CHANGE, {\n action: 'add',\n index: 0,\n items: items\n });\n return result;\n },\n indexOf: function (item) {\n var that = this, idx, length;\n for (idx = 0, length = that.length; idx < length; idx++) {\n if (that[idx] === item) {\n return idx;\n }\n }\n return -1;\n },\n forEach: function (callback, thisArg) {\n var idx = 0;\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n callback.call(context, this[idx], idx, this);\n }\n },\n map: function (callback, thisArg) {\n var idx = 0;\n var result = [];\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n result[idx] = callback.call(context, this[idx], idx, this);\n }\n return result;\n },\n reduce: function (callback) {\n var idx = 0, result, length = this.length;\n if (arguments.length == 2) {\n result = arguments[1];\n } else if (idx < length) {\n result = this[idx++];\n }\n for (; idx < length; idx++) {\n result = callback(result, this[idx], idx, this);\n }\n return result;\n },\n reduceRight: function (callback) {\n var idx = this.length - 1, result;\n if (arguments.length == 2) {\n result = arguments[1];\n } else if (idx > 0) {\n result = this[idx--];\n }\n for (; idx >= 0; idx--) {\n result = callback(result, this[idx], idx, this);\n }\n return result;\n },\n filter: function (callback, thisArg) {\n var idx = 0;\n var result = [];\n var item;\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n item = this[idx];\n if (callback.call(context, item, idx, this)) {\n result[result.length] = item;\n }\n }\n return result;\n },\n find: function (callback, thisArg) {\n var idx = 0;\n var item;\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n item = this[idx];\n if (callback.call(context, item, idx, this)) {\n return item;\n }\n }\n },\n every: function (callback, thisArg) {\n var idx = 0;\n var item;\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n item = this[idx];\n if (!callback.call(context, item, idx, this)) {\n return false;\n }\n }\n return true;\n },\n some: function (callback, thisArg) {\n var idx = 0;\n var item;\n var length = this.length;\n var context = thisArg || window;\n for (; idx < length; idx++) {\n item = this[idx];\n if (callback.call(context, item, idx, this)) {\n return true;\n }\n }\n return false;\n },\n remove: function (item) {\n var idx = this.indexOf(item);\n if (idx !== -1) {\n this.splice(idx, 1);\n }\n },\n empty: function () {\n this.splice(0, this.length);\n }\n });\n if (typeof Symbol !== 'undefined' && Symbol.iterator && !ObservableArray.prototype[Symbol.iterator]) {\n ObservableArray.prototype[Symbol.iterator] = [][Symbol.iterator];\n }\n var LazyObservableArray = ObservableArray.extend({\n init: function (data, type) {\n Observable.fn.init.call(this);\n this.type = type || ObservableObject;\n for (var idx = 0; idx < data.length; idx++) {\n this[idx] = data[idx];\n }\n this.length = idx;\n this._parent = proxy(function () {\n return this;\n }, this);\n },\n at: function (index) {\n var item = this[index];\n if (!(item instanceof this.type)) {\n item = this[index] = this.wrap(item, this._parent);\n } else {\n item.parent = this._parent;\n }\n return item;\n }\n });\n function eventHandler(context, type, field, prefix) {\n return function (e) {\n var event = {}, key;\n for (key in e) {\n event[key] = e[key];\n }\n if (prefix) {\n event.field = field + '.' + e.field;\n } else {\n event.field = field;\n }\n if (type == CHANGE && context._notifyChange) {\n context._notifyChange(event);\n }\n context.trigger(type, event);\n };\n }\n var ObservableObject = Observable.extend({\n init: function (value) {\n var that = this, member, field, parent = function () {\n return that;\n };\n Observable.fn.init.call(this);\n this._handlers = {};\n for (field in value) {\n member = value[field];\n if (typeof member === 'object' && member && !member.getTime && field.charAt(0) != '_') {\n member = that.wrap(member, field, parent);\n }\n that[field] = member;\n }\n that.uid = kendo.guid();\n },\n shouldSerialize: function (field) {\n return this.hasOwnProperty(field) && field !== '_handlers' && field !== '_events' && typeof this[field] !== FUNCTION && field !== 'uid';\n },\n forEach: function (f) {\n for (var i in this) {\n if (this.shouldSerialize(i)) {\n f(this[i], i);\n }\n }\n },\n toJSON: function () {\n var result = {}, value, field;\n for (field in this) {\n if (this.shouldSerialize(field)) {\n value = this[field];\n if (value instanceof ObservableObject || value instanceof ObservableArray) {\n value = value.toJSON();\n }\n result[field] = value;\n }\n }\n return result;\n },\n get: function (field) {\n var that = this, result;\n that.trigger(GET, { field: field });\n if (field === 'this') {\n result = that;\n } else {\n result = kendo.getter(field, true)(that);\n }\n return result;\n },\n _set: function (field, value) {\n var that = this;\n var composite = field.indexOf('.') >= 0;\n if (composite) {\n var paths = field.split('.'), path = '';\n while (paths.length > 1) {\n path += paths.shift();\n var obj = kendo.getter(path, true)(that);\n if (obj instanceof ObservableObject) {\n obj.set(paths.join('.'), value);\n return composite;\n }\n path += '.';\n }\n }\n kendo.setter(field)(that, value);\n return composite;\n },\n set: function (field, value) {\n var that = this, isSetPrevented = false, composite = field.indexOf('.') >= 0, current = kendo.getter(field, true)(that);\n if (current !== value) {\n if (current instanceof Observable && this._handlers[field]) {\n if (this._handlers[field].get) {\n current.unbind(GET, this._handlers[field].get);\n }\n current.unbind(CHANGE, this._handlers[field].change);\n }\n isSetPrevented = that.trigger('set', {\n field: field,\n value: value\n });\n if (!isSetPrevented) {\n if (!composite) {\n value = that.wrap(value, field, function () {\n return that;\n });\n }\n if (!that._set(field, value) || field.indexOf('(') >= 0 || field.indexOf('[') >= 0) {\n that.trigger(CHANGE, { field: field });\n }\n }\n }\n return isSetPrevented;\n },\n parent: noop,\n wrap: function (object, field, parent) {\n var that = this;\n var get;\n var change;\n var type = toString.call(object);\n if (object != null && (type === '[object Object]' || type === '[object Array]')) {\n var isObservableArray = object instanceof ObservableArray;\n var isDataSource = object instanceof DataSource;\n if (type === '[object Object]' && !isDataSource && !isObservableArray) {\n if (!(object instanceof ObservableObject)) {\n object = new ObservableObject(object);\n }\n get = eventHandler(that, GET, field, true);\n object.bind(GET, get);\n change = eventHandler(that, CHANGE, field, true);\n object.bind(CHANGE, change);\n that._handlers[field] = {\n get: get,\n change: change\n };\n } else if (type === '[object Array]' || isObservableArray || isDataSource) {\n if (!isObservableArray && !isDataSource) {\n object = new ObservableArray(object);\n }\n change = eventHandler(that, CHANGE, field, false);\n object.bind(CHANGE, change);\n that._handlers[field] = { change: change };\n }\n object.parent = parent;\n }\n return object;\n }\n });\n function equal(x, y) {\n if (x === y) {\n return true;\n }\n var xtype = $.type(x), ytype = $.type(y), field;\n if (xtype !== ytype) {\n return false;\n }\n if (xtype === 'date') {\n return x.getTime() === y.getTime();\n }\n if (xtype !== 'object' && xtype !== 'array') {\n return false;\n }\n for (field in x) {\n if (!equal(x[field], y[field])) {\n return false;\n }\n }\n return true;\n }\n var parsers = {\n 'number': function (value) {\n if (typeof value === STRING && value.toLowerCase() === 'null') {\n return null;\n }\n return kendo.parseFloat(value);\n },\n 'date': function (value) {\n if (typeof value === STRING && value.toLowerCase() === 'null') {\n return null;\n }\n return kendo.parseDate(value);\n },\n 'boolean': function (value) {\n if (typeof value === STRING) {\n if (value.toLowerCase() === 'null') {\n return null;\n } else {\n return value.toLowerCase() === 'true';\n }\n }\n return value != null ? !!value : value;\n },\n 'string': function (value) {\n if (typeof value === STRING && value.toLowerCase() === 'null') {\n return null;\n }\n return value != null ? value + '' : value;\n },\n 'default': function (value) {\n return value;\n }\n };\n var defaultValues = {\n 'string': '',\n 'number': 0,\n 'date': new Date(),\n 'boolean': false,\n 'default': ''\n };\n function getFieldByName(obj, name) {\n var field, fieldName;\n for (fieldName in obj) {\n field = obj[fieldName];\n if (isPlainObject(field) && field.field && field.field === name) {\n return field;\n } else if (field === name) {\n return field;\n }\n }\n return null;\n }\n var Model = ObservableObject.extend({\n init: function (data) {\n var that = this;\n if (!data || $.isEmptyObject(data)) {\n data = $.extend({}, that.defaults, data);\n if (that._initializers) {\n for (var idx = 0; idx < that._initializers.length; idx++) {\n var name = that._initializers[idx];\n data[name] = that.defaults[name]();\n }\n }\n }\n ObservableObject.fn.init.call(that, data);\n that.dirty = false;\n that.dirtyFields = {};\n if (that.idField) {\n that.id = that.get(that.idField);\n if (that.id === undefined) {\n that.id = that._defaultId;\n }\n }\n },\n shouldSerialize: function (field) {\n return ObservableObject.fn.shouldSerialize.call(this, field) && field !== 'uid' && !(this.idField !== 'id' && field === 'id') && field !== 'dirty' && field !== 'dirtyFields' && field !== '_accessors';\n },\n _parse: function (field, value) {\n var that = this, fieldName = field, fields = that.fields || {}, parse;\n field = fields[field];\n if (!field) {\n field = getFieldByName(fields, fieldName);\n }\n if (field) {\n parse = field.parse;\n if (!parse && field.type) {\n parse = parsers[field.type.toLowerCase()];\n }\n }\n return parse ? parse(value) : value;\n },\n _notifyChange: function (e) {\n var action = e.action;\n if (action == 'add' || action == 'remove') {\n this.dirty = true;\n this.dirtyFields[e.field] = true;\n }\n },\n editable: function (field) {\n field = (this.fields || {})[field];\n return field ? field.editable !== false : true;\n },\n set: function (field, value, initiator) {\n var that = this;\n var dirty = that.dirty;\n if (that.editable(field)) {\n value = that._parse(field, value);\n if (!equal(value, that.get(field))) {\n that.dirty = true;\n that.dirtyFields[field] = true;\n if (ObservableObject.fn.set.call(that, field, value, initiator) && !dirty) {\n that.dirty = dirty;\n if (!that.dirty) {\n that.dirtyFields[field] = false;\n }\n }\n } else {\n that.trigger('equalSet', {\n field: field,\n value: value\n });\n }\n }\n },\n accept: function (data) {\n var that = this, parent = function () {\n return that;\n }, field;\n for (field in data) {\n var value = data[field];\n if (field.charAt(0) != '_') {\n value = that.wrap(data[field], field, parent);\n }\n that._set(field, value);\n }\n if (that.idField) {\n that.id = that.get(that.idField);\n }\n that.dirty = false;\n that.dirtyFields = {};\n },\n isNew: function () {\n return this.id === this._defaultId;\n }\n });\n Model.define = function (base, options) {\n if (options === undefined) {\n options = base;\n base = Model;\n }\n var model, proto = extend({ defaults: {} }, options), name, field, type, value, idx, length, fields = {}, originalName, id = proto.id, functionFields = [];\n if (id) {\n proto.idField = id;\n }\n if (proto.id) {\n delete proto.id;\n }\n if (id) {\n proto.defaults[id] = proto._defaultId = '';\n }\n if (toString.call(proto.fields) === '[object Array]') {\n for (idx = 0, length = proto.fields.length; idx < length; idx++) {\n field = proto.fields[idx];\n if (typeof field === STRING) {\n fields[field] = {};\n } else if (field.field) {\n fields[field.field] = field;\n }\n }\n proto.fields = fields;\n }\n for (name in proto.fields) {\n field = proto.fields[name];\n type = field.type || 'default';\n value = null;\n originalName = name;\n name = typeof field.field === STRING ? field.field : name;\n if (!field.nullable) {\n value = proto.defaults[originalName !== name ? originalName : name] = field.defaultValue !== undefined ? field.defaultValue : defaultValues[type.toLowerCase()];\n if (typeof value === 'function') {\n functionFields.push(name);\n }\n }\n if (options.id === name) {\n proto._defaultId = value;\n }\n proto.defaults[originalName !== name ? originalName : name] = value;\n field.parse = field.parse || parsers[type];\n }\n if (functionFields.length > 0) {\n proto._initializers = functionFields;\n }\n model = base.extend(proto);\n model.define = function (options) {\n return Model.define(model, options);\n };\n if (proto.fields) {\n model.fields = proto.fields;\n model.idField = proto.idField;\n }\n return model;\n };\n var Comparer = {\n selector: function (field) {\n return isFunction(field) ? field : getter(field);\n },\n compare: function (field) {\n var selector = this.selector(field);\n return function (a, b) {\n a = selector(a);\n b = selector(b);\n if (a == null && b == null) {\n return 0;\n }\n if (a == null) {\n return -1;\n }\n if (b == null) {\n return 1;\n }\n if (a.localeCompare) {\n return a.localeCompare(b);\n }\n return a > b ? 1 : a < b ? -1 : 0;\n };\n },\n create: function (sort) {\n var compare = sort.compare || this.compare(sort.field);\n if (sort.dir == 'desc') {\n return function (a, b) {\n return compare(b, a, true);\n };\n }\n return compare;\n },\n combine: function (comparers) {\n return function (a, b) {\n var result = comparers[0](a, b), idx, length;\n for (idx = 1, length = comparers.length; idx < length; idx++) {\n result = result || comparers[idx](a, b);\n }\n return result;\n };\n }\n };\n var StableComparer = extend({}, Comparer, {\n asc: function (field) {\n var selector = this.selector(field);\n return function (a, b) {\n var valueA = selector(a);\n var valueB = selector(b);\n if (valueA && valueA.getTime && valueB && valueB.getTime) {\n valueA = valueA.getTime();\n valueB = valueB.getTime();\n }\n if (valueA === valueB) {\n return a.__position - b.__position;\n }\n if (valueA == null) {\n return -1;\n }\n if (valueB == null) {\n return 1;\n }\n if (valueA.localeCompare) {\n return valueA.localeCompare(valueB);\n }\n return valueA > valueB ? 1 : -1;\n };\n },\n desc: function (field) {\n var selector = this.selector(field);\n return function (a, b) {\n var valueA = selector(a);\n var valueB = selector(b);\n if (valueA && valueA.getTime && valueB && valueB.getTime) {\n valueA = valueA.getTime();\n valueB = valueB.getTime();\n }\n if (valueA === valueB) {\n return a.__position - b.__position;\n }\n if (valueA == null) {\n return 1;\n }\n if (valueB == null) {\n return -1;\n }\n if (valueB.localeCompare) {\n return valueB.localeCompare(valueA);\n }\n return valueA < valueB ? 1 : -1;\n };\n },\n create: function (sort) {\n return this[sort.dir](sort.field);\n }\n });\n map = function (array, callback) {\n var idx, length = array.length, result = new Array(length);\n for (idx = 0; idx < length; idx++) {\n result[idx] = callback(array[idx], idx, array);\n }\n return result;\n };\n var operators = function () {\n function quote(str) {\n if (typeof str == 'string') {\n str = str.replace(/[\\r\\n]+/g, '');\n }\n return JSON.stringify(str);\n }\n function textOp(impl) {\n return function (a, b, ignore) {\n b += '';\n if (ignore) {\n a = '(' + a + ' || \\'\\').toLowerCase()';\n b = b.toLowerCase();\n }\n return impl(a, quote(b), ignore);\n };\n }\n function operator(op, a, b, ignore) {\n if (b != null) {\n if (typeof b === STRING) {\n var date = dateRegExp.exec(b);\n if (date) {\n b = new Date(+date[1]);\n } else if (ignore) {\n b = quote(b.toLowerCase());\n a = '((' + a + ' || \\'\\')+\\'\\').toLowerCase()';\n } else {\n b = quote(b);\n }\n }\n if (b.getTime) {\n a = '(' + a + '&&' + a + '.getTime?' + a + '.getTime():' + a + ')';\n b = b.getTime();\n }\n }\n return a + ' ' + op + ' ' + b;\n }\n function getMatchRegexp(pattern) {\n for (var rx = '/^', esc = false, i = 0; i < pattern.length; ++i) {\n var ch = pattern.charAt(i);\n if (esc) {\n rx += '\\\\' + ch;\n } else if (ch == '~') {\n esc = true;\n continue;\n } else if (ch == '*') {\n rx += '.*';\n } else if (ch == '?') {\n rx += '.';\n } else if ('.+^$()[]{}|\\\\/\\n\\r\\u2028\\u2029\\xA0'.indexOf(ch) >= 0) {\n rx += '\\\\' + ch;\n } else {\n rx += ch;\n }\n esc = false;\n }\n return rx + '$/';\n }\n return {\n quote: function (value) {\n if (value && value.getTime) {\n return 'new Date(' + value.getTime() + ')';\n }\n return quote(value);\n },\n eq: function (a, b, ignore) {\n return operator('==', a, b, ignore);\n },\n neq: function (a, b, ignore) {\n return operator('!=', a, b, ignore);\n },\n gt: function (a, b, ignore) {\n return operator('>', a, b, ignore);\n },\n gte: function (a, b, ignore) {\n return operator('>=', a, b, ignore);\n },\n lt: function (a, b, ignore) {\n return operator('<', a, b, ignore);\n },\n lte: function (a, b, ignore) {\n return operator('<=', a, b, ignore);\n },\n startswith: textOp(function (a, b) {\n return a + '.lastIndexOf(' + b + ', 0) == 0';\n }),\n doesnotstartwith: textOp(function (a, b) {\n return a + '.lastIndexOf(' + b + ', 0) == -1';\n }),\n endswith: textOp(function (a, b) {\n var n = b ? b.length - 2 : 0;\n return a + '.indexOf(' + b + ', ' + a + '.length - ' + n + ') >= 0';\n }),\n doesnotendwith: textOp(function (a, b) {\n var n = b ? b.length - 2 : 0;\n return a + '.indexOf(' + b + ', ' + a + '.length - ' + n + ') < 0';\n }),\n contains: textOp(function (a, b) {\n return a + '.indexOf(' + b + ') >= 0';\n }),\n doesnotcontain: textOp(function (a, b) {\n return a + '.indexOf(' + b + ') == -1';\n }),\n matches: textOp(function (a, b) {\n b = b.substring(1, b.length - 1);\n return getMatchRegexp(b) + '.test(' + a + ')';\n }),\n doesnotmatch: textOp(function (a, b) {\n b = b.substring(1, b.length - 1);\n return '!' + getMatchRegexp(b) + '.test(' + a + ')';\n }),\n isempty: function (a) {\n return a + ' === \\'\\'';\n },\n isnotempty: function (a) {\n return a + ' !== \\'\\'';\n },\n isnull: function (a) {\n return '(' + a + ' == null)';\n },\n isnotnull: function (a) {\n return '(' + a + ' != null)';\n },\n isnullorempty: function (a) {\n return '(' + a + ' === null) || (' + a + ' === \\'\\')';\n },\n isnotnullorempty: function (a) {\n return '(' + a + ' !== null) && (' + a + ' !== \\'\\')';\n }\n };\n }();\n function Query(data) {\n this.data = data || [];\n }\n Query.filterExpr = function (expression) {\n var expressions = [], logic = {\n and: ' && ',\n or: ' || '\n }, idx, length, filter, expr, fieldFunctions = [], operatorFunctions = [], field, operator, filters = expression.filters;\n for (idx = 0, length = filters.length; idx < length; idx++) {\n filter = filters[idx];\n field = filter.field;\n operator = filter.operator;\n if (filter.filters) {\n expr = Query.filterExpr(filter);\n filter = expr.expression.replace(/__o\\[(\\d+)\\]/g, function (match, index) {\n index = +index;\n return '__o[' + (operatorFunctions.length + index) + ']';\n }).replace(/__f\\[(\\d+)\\]/g, function (match, index) {\n index = +index;\n return '__f[' + (fieldFunctions.length + index) + ']';\n });\n operatorFunctions.push.apply(operatorFunctions, expr.operators);\n fieldFunctions.push.apply(fieldFunctions, expr.fields);\n } else {\n if (typeof field === FUNCTION) {\n expr = '__f[' + fieldFunctions.length + '](d)';\n fieldFunctions.push(field);\n } else {\n expr = kendo.expr(field);\n }\n if (typeof operator === FUNCTION) {\n filter = '__o[' + operatorFunctions.length + '](' + expr + ', ' + operators.quote(filter.value) + ')';\n operatorFunctions.push(operator);\n } else {\n filter = operators[(operator || 'eq').toLowerCase()](expr, filter.value, filter.ignoreCase !== undefined ? filter.ignoreCase : true);\n }\n }\n expressions.push(filter);\n }\n return {\n expression: '(' + expressions.join(logic[expression.logic]) + ')',\n fields: fieldFunctions,\n operators: operatorFunctions\n };\n };\n function normalizeSort(field, dir) {\n if (field) {\n var descriptor = typeof field === STRING ? {\n field: field,\n dir: dir\n } : field, descriptors = isArray(descriptor) ? descriptor : descriptor !== undefined ? [descriptor] : [];\n return grep(descriptors, function (d) {\n return !!d.dir;\n });\n }\n }\n var operatorMap = {\n '==': 'eq',\n equals: 'eq',\n isequalto: 'eq',\n equalto: 'eq',\n equal: 'eq',\n '!=': 'neq',\n ne: 'neq',\n notequals: 'neq',\n isnotequalto: 'neq',\n notequalto: 'neq',\n notequal: 'neq',\n '<': 'lt',\n islessthan: 'lt',\n lessthan: 'lt',\n less: 'lt',\n '<=': 'lte',\n le: 'lte',\n islessthanorequalto: 'lte',\n lessthanequal: 'lte',\n '>': 'gt',\n isgreaterthan: 'gt',\n greaterthan: 'gt',\n greater: 'gt',\n '>=': 'gte',\n isgreaterthanorequalto: 'gte',\n greaterthanequal: 'gte',\n ge: 'gte',\n notsubstringof: 'doesnotcontain',\n isnull: 'isnull',\n isempty: 'isempty',\n isnotempty: 'isnotempty'\n };\n function normalizeOperator(expression) {\n var idx, length, filter, operator, filters = expression.filters;\n if (filters) {\n for (idx = 0, length = filters.length; idx < length; idx++) {\n filter = filters[idx];\n operator = filter.operator;\n if (operator && typeof operator === STRING) {\n filter.operator = operatorMap[operator.toLowerCase()] || operator;\n }\n normalizeOperator(filter);\n }\n }\n }\n function normalizeFilter(expression) {\n if (expression && !isEmptyObject(expression)) {\n if (isArray(expression) || !expression.filters) {\n expression = {\n logic: 'and',\n filters: isArray(expression) ? expression : [expression]\n };\n }\n normalizeOperator(expression);\n return expression;\n }\n }\n Query.normalizeFilter = normalizeFilter;\n function compareDescriptor(f1, f2) {\n if (f1.logic || f2.logic) {\n return false;\n }\n return f1.field === f2.field && f1.value === f2.value && f1.operator === f2.operator;\n }\n function normalizeDescriptor(filter) {\n filter = filter || {};\n if (isEmptyObject(filter)) {\n return {\n logic: 'and',\n filters: []\n };\n }\n return normalizeFilter(filter);\n }\n function fieldComparer(a, b) {\n if (b.logic || a.field > b.field) {\n return 1;\n } else if (a.field < b.field) {\n return -1;\n } else {\n return 0;\n }\n }\n function compareFilters(expr1, expr2) {\n expr1 = normalizeDescriptor(expr1);\n expr2 = normalizeDescriptor(expr2);\n if (expr1.logic !== expr2.logic) {\n return false;\n }\n var f1, f2;\n var filters1 = (expr1.filters || []).slice();\n var filters2 = (expr2.filters || []).slice();\n if (filters1.length !== filters2.length) {\n return false;\n }\n filters1 = filters1.sort(fieldComparer);\n filters2 = filters2.sort(fieldComparer);\n for (var idx = 0; idx < filters1.length; idx++) {\n f1 = filters1[idx];\n f2 = filters2[idx];\n if (f1.logic && f2.logic) {\n if (!compareFilters(f1, f2)) {\n return false;\n }\n } else if (!compareDescriptor(f1, f2)) {\n return false;\n }\n }\n return true;\n }\n Query.compareFilters = compareFilters;\n function normalizeAggregate(expressions) {\n return isArray(expressions) ? expressions : [expressions];\n }\n function normalizeGroup(field, dir) {\n var descriptor = typeof field === STRING ? {\n field: field,\n dir: dir\n } : field, descriptors = isArray(descriptor) ? descriptor : descriptor !== undefined ? [descriptor] : [];\n return map(descriptors, function (d) {\n return {\n field: d.field,\n dir: d.dir || 'asc',\n aggregates: d.aggregates\n };\n });\n }\n Query.prototype = {\n toArray: function () {\n return this.data;\n },\n range: function (index, count) {\n return new Query(this.data.slice(index, index + count));\n },\n skip: function (count) {\n return new Query(this.data.slice(count));\n },\n take: function (count) {\n return new Query(this.data.slice(0, count));\n },\n select: function (selector) {\n return new Query(map(this.data, selector));\n },\n order: function (selector, dir, inPlace) {\n var sort = { dir: dir };\n if (selector) {\n if (selector.compare) {\n sort.compare = selector.compare;\n } else {\n sort.field = selector;\n }\n }\n if (inPlace) {\n return new Query(this.data.sort(Comparer.create(sort)));\n }\n return new Query(this.data.slice(0).sort(Comparer.create(sort)));\n },\n orderBy: function (selector, inPlace) {\n return this.order(selector, 'asc', inPlace);\n },\n orderByDescending: function (selector, inPlace) {\n return this.order(selector, 'desc', inPlace);\n },\n sort: function (field, dir, comparer, inPlace) {\n var idx, length, descriptors = normalizeSort(field, dir), comparers = [];\n comparer = comparer || Comparer;\n if (descriptors.length) {\n for (idx = 0, length = descriptors.length; idx < length; idx++) {\n comparers.push(comparer.create(descriptors[idx]));\n }\n return this.orderBy({ compare: comparer.combine(comparers) }, inPlace);\n }\n return this;\n },\n filter: function (expressions) {\n var idx, current, length, compiled, predicate, data = this.data, fields, operators, result = [], filter;\n expressions = normalizeFilter(expressions);\n if (!expressions || expressions.filters.length === 0) {\n return this;\n }\n compiled = Query.filterExpr(expressions);\n fields = compiled.fields;\n operators = compiled.operators;\n predicate = filter = new Function('d, __f, __o', 'return ' + compiled.expression);\n if (fields.length || operators.length) {\n filter = function (d) {\n return predicate(d, fields, operators);\n };\n }\n for (idx = 0, length = data.length; idx < length; idx++) {\n current = data[idx];\n if (filter(current)) {\n result.push(current);\n }\n }\n return new Query(result);\n },\n group: function (descriptors, allData) {\n descriptors = normalizeGroup(descriptors || []);\n allData = allData || this.data;\n var that = this, result = new Query(that.data), descriptor;\n if (descriptors.length > 0) {\n descriptor = descriptors[0];\n result = result.groupBy(descriptor).select(function (group) {\n var data = new Query(allData).filter([{\n field: group.field,\n operator: 'eq',\n value: group.value,\n ignoreCase: false\n }]);\n return {\n field: group.field,\n value: group.value,\n items: descriptors.length > 1 ? new Query(group.items).group(descriptors.slice(1), data.toArray()).toArray() : group.items,\n hasSubgroups: descriptors.length > 1,\n aggregates: data.aggregate(descriptor.aggregates)\n };\n });\n }\n return result;\n },\n groupBy: function (descriptor) {\n if (isEmptyObject(descriptor) || !this.data.length) {\n return new Query([]);\n }\n var field = descriptor.field, sorted = this._sortForGrouping(field, descriptor.dir || 'asc'), accessor = kendo.accessor(field), item, groupValue = accessor.get(sorted[0], field), group = {\n field: field,\n value: groupValue,\n items: []\n }, currentValue, idx, len, result = [group];\n for (idx = 0, len = sorted.length; idx < len; idx++) {\n item = sorted[idx];\n currentValue = accessor.get(item, field);\n if (!groupValueComparer(groupValue, currentValue)) {\n groupValue = currentValue;\n group = {\n field: field,\n value: groupValue,\n items: []\n };\n result.push(group);\n }\n group.items.push(item);\n }\n return new Query(result);\n },\n _sortForGrouping: function (field, dir) {\n var idx, length, data = this.data;\n if (!stableSort) {\n for (idx = 0, length = data.length; idx < length; idx++) {\n data[idx].__position = idx;\n }\n data = new Query(data).sort(field, dir, StableComparer).toArray();\n for (idx = 0, length = data.length; idx < length; idx++) {\n delete data[idx].__position;\n }\n return data;\n }\n return this.sort(field, dir).toArray();\n },\n aggregate: function (aggregates) {\n var idx, len, result = {}, state = {};\n if (aggregates && aggregates.length) {\n for (idx = 0, len = this.data.length; idx < len; idx++) {\n calculateAggregate(result, aggregates, this.data[idx], idx, len, state);\n }\n }\n return result;\n }\n };\n function groupValueComparer(a, b) {\n if (a && a.getTime && b && b.getTime) {\n return a.getTime() === b.getTime();\n }\n return a === b;\n }\n function calculateAggregate(accumulator, aggregates, item, index, length, state) {\n aggregates = aggregates || [];\n var idx, aggr, functionName, len = aggregates.length;\n for (idx = 0; idx < len; idx++) {\n aggr = aggregates[idx];\n functionName = aggr.aggregate;\n var field = aggr.field;\n accumulator[field] = accumulator[field] || {};\n state[field] = state[field] || {};\n state[field][functionName] = state[field][functionName] || {};\n accumulator[field][functionName] = functions[functionName.toLowerCase()](accumulator[field][functionName], item, kendo.accessor(field), index, length, state[field][functionName]);\n }\n }\n var functions = {\n sum: function (accumulator, item, accessor) {\n var value = accessor.get(item);\n if (!isNumber(accumulator)) {\n accumulator = value;\n } else if (isNumber(value)) {\n accumulator += value;\n }\n return accumulator;\n },\n count: function (accumulator) {\n return (accumulator || 0) + 1;\n },\n average: function (accumulator, item, accessor, index, length, state) {\n var value = accessor.get(item);\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 if (index == length - 1 && isNumber(accumulator)) {\n accumulator = accumulator / state.count;\n }\n return accumulator;\n },\n max: function (accumulator, item, accessor) {\n var value = accessor.get(item);\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 (accumulator, item, accessor) {\n var value = accessor.get(item);\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 function isNumber(val) {\n return typeof val === 'number' && !isNaN(val);\n }\n function isDate(val) {\n return val && val.getTime;\n }\n function toJSON(array) {\n var idx, length = array.length, result = new Array(length);\n for (idx = 0; idx < length; idx++) {\n result[idx] = array[idx].toJSON();\n }\n return result;\n }\n Query.process = function (data, options, inPlace) {\n options = options || {};\n var query = new Query(data), group = options.group, sort = normalizeGroup(group || []).concat(normalizeSort(options.sort || [])), total, filterCallback = options.filterCallback, filter = options.filter, skip = options.skip, take = options.take;\n if (sort && inPlace) {\n query = query.sort(sort, undefined, undefined, inPlace);\n }\n if (filter) {\n query = query.filter(filter);\n if (filterCallback) {\n query = filterCallback(query);\n }\n total = query.toArray().length;\n }\n if (sort && !inPlace) {\n query = query.sort(sort);\n if (group) {\n data = query.toArray();\n }\n }\n if (skip !== undefined && take !== undefined) {\n query = query.range(skip, take);\n }\n if (group) {\n query = query.group(group, data);\n }\n return {\n total: total,\n data: query.toArray()\n };\n };\n var LocalTransport = Class.extend({\n init: function (options) {\n this.data = options.data;\n },\n read: function (options) {\n options.success(this.data);\n },\n update: function (options) {\n options.success(options.data);\n },\n create: function (options) {\n options.success(options.data);\n },\n destroy: function (options) {\n options.success(options.data);\n }\n });\n var RemoteTransport = Class.extend({\n init: function (options) {\n var that = this, parameterMap;\n options = that.options = extend({}, that.options, options);\n each(crud, function (index, type) {\n if (typeof options[type] === STRING) {\n options[type] = { url: options[type] };\n }\n });\n that.cache = options.cache ? Cache.create(options.cache) : {\n find: noop,\n add: noop\n };\n parameterMap = options.parameterMap;\n that.submit = options.submit;\n if (isFunction(options.push)) {\n that.push = options.push;\n }\n if (!that.push) {\n that.push = identity;\n }\n that.parameterMap = isFunction(parameterMap) ? parameterMap : function (options) {\n var result = {};\n each(options, function (option, value) {\n if (option in parameterMap) {\n option = parameterMap[option];\n if (isPlainObject(option)) {\n value = option.value(value);\n option = option.key;\n }\n }\n result[option] = value;\n });\n return result;\n };\n },\n options: { parameterMap: identity },\n create: function (options) {\n return ajax(this.setup(options, CREATE));\n },\n read: function (options) {\n var that = this, success, error, result, cache = that.cache;\n options = that.setup(options, READ);\n success = options.success || noop;\n error = options.error || noop;\n result = cache.find(options.data);\n if (result !== undefined) {\n success(result);\n } else {\n options.success = function (result) {\n cache.add(options.data, result);\n success(result);\n };\n $.ajax(options);\n }\n },\n update: function (options) {\n return ajax(this.setup(options, UPDATE));\n },\n destroy: function (options) {\n return ajax(this.setup(options, DESTROY));\n },\n setup: function (options, type) {\n options = options || {};\n var that = this, parameters, operation = that.options[type], data = isFunction(operation.data) ? operation.data(options.data) : operation.data;\n options = extend(true, {}, operation, options);\n parameters = extend(true, {}, data, options.data);\n options.data = that.parameterMap(parameters, type);\n if (isFunction(options.url)) {\n options.url = options.url(parameters);\n }\n return options;\n }\n });\n var Cache = Class.extend({\n init: function () {\n this._store = {};\n },\n add: function (key, data) {\n if (key !== undefined) {\n this._store[stringify(key)] = data;\n }\n },\n find: function (key) {\n return this._store[stringify(key)];\n },\n clear: function () {\n this._store = {};\n },\n remove: function (key) {\n delete this._store[stringify(key)];\n }\n });\n Cache.create = function (options) {\n var store = {\n 'inmemory': function () {\n return new Cache();\n }\n };\n if (isPlainObject(options) && isFunction(options.find)) {\n return options;\n }\n if (options === true) {\n return new Cache();\n }\n return store[options]();\n };\n function serializeRecords(data, getters, modelInstance, originalFieldNames, fieldNames) {\n var record, getter, originalName, idx, setters = {}, length;\n for (idx = 0, length = data.length; idx < length; idx++) {\n record = data[idx];\n for (getter in getters) {\n originalName = fieldNames[getter];\n if (originalName && originalName !== getter) {\n if (!setters[originalName]) {\n setters[originalName] = kendo.setter(originalName);\n }\n setters[originalName](record, getters[getter](record));\n delete record[getter];\n }\n }\n }\n }\n function convertRecords(data, getters, modelInstance, originalFieldNames, fieldNames) {\n var record, getter, originalName, idx, length;\n for (idx = 0, length = data.length; idx < length; idx++) {\n record = data[idx];\n for (getter in getters) {\n record[getter] = modelInstance._parse(getter, getters[getter](record));\n originalName = fieldNames[getter];\n if (originalName && originalName !== getter) {\n delete record[originalName];\n }\n }\n }\n }\n function convertGroup(data, getters, modelInstance, originalFieldNames, fieldNames) {\n var record, idx, fieldName, length;\n for (idx = 0, length = data.length; idx < length; idx++) {\n record = data[idx];\n fieldName = originalFieldNames[record.field];\n if (fieldName && fieldName != record.field) {\n record.field = fieldName;\n }\n record.value = modelInstance._parse(record.field, record.value);\n if (record.hasSubgroups) {\n convertGroup(record.items, getters, modelInstance, originalFieldNames, fieldNames);\n } else {\n convertRecords(record.items, getters, modelInstance, originalFieldNames, fieldNames);\n }\n }\n }\n function wrapDataAccess(originalFunction, model, converter, getters, originalFieldNames, fieldNames) {\n return function (data) {\n data = originalFunction(data);\n if (data && !isEmptyObject(getters)) {\n if (toString.call(data) !== '[object Array]' && !(data instanceof ObservableArray)) {\n data = [data];\n }\n converter(data, getters, new model(), originalFieldNames, fieldNames);\n }\n return data || [];\n };\n }\n var DataReader = Class.extend({\n init: function (schema) {\n var that = this, member, get, model, base;\n schema = schema || {};\n for (member in schema) {\n get = schema[member];\n that[member] = typeof get === STRING ? getter(get) : get;\n }\n base = schema.modelBase || Model;\n if (isPlainObject(that.model)) {\n that.model = model = base.define(that.model);\n }\n var dataFunction = proxy(that.data, that);\n that._dataAccessFunction = dataFunction;\n if (that.model) {\n var groupsFunction = proxy(that.groups, that), serializeFunction = proxy(that.serialize, that), originalFieldNames = {}, getters = {}, serializeGetters = {}, fieldNames = {}, shouldSerialize = false, fieldName;\n model = that.model;\n if (model.fields) {\n each(model.fields, function (field, value) {\n var fromName;\n fieldName = field;\n if (isPlainObject(value) && value.field) {\n fieldName = value.field;\n } else if (typeof value === STRING) {\n fieldName = value;\n }\n if (isPlainObject(value) && value.from) {\n fromName = value.from;\n }\n shouldSerialize = shouldSerialize || fromName && fromName !== field || fieldName !== field;\n getters[field] = getter(fromName || fieldName);\n serializeGetters[field] = getter(field);\n originalFieldNames[fromName || fieldName] = field;\n fieldNames[field] = fromName || fieldName;\n });\n if (!schema.serialize && shouldSerialize) {\n that.serialize = wrapDataAccess(serializeFunction, model, serializeRecords, serializeGetters, originalFieldNames, fieldNames);\n }\n }\n that._dataAccessFunction = dataFunction;\n that.data = wrapDataAccess(dataFunction, model, convertRecords, getters, originalFieldNames, fieldNames);\n that.groups = wrapDataAccess(groupsFunction, model, convertGroup, getters, originalFieldNames, fieldNames);\n }\n },\n errors: function (data) {\n return data ? data.errors : null;\n },\n parse: identity,\n data: identity,\n total: function (data) {\n return data.length;\n },\n groups: identity,\n aggregates: function () {\n return {};\n },\n serialize: function (data) {\n return data;\n }\n });\n function mergeGroups(target, dest, skip, take) {\n var group, idx = 0, items;\n while (dest.length && take) {\n group = dest[idx];\n items = group.items;\n var length = items.length;\n if (target && target.field === group.field && target.value === group.value) {\n if (target.hasSubgroups && target.items.length) {\n mergeGroups(target.items[target.items.length - 1], group.items, skip, take);\n } else {\n items = items.slice(skip, skip + take);\n target.items = target.items.concat(items);\n }\n dest.splice(idx--, 1);\n } else if (group.hasSubgroups && items.length) {\n mergeGroups(group, items, skip, take);\n if (!group.items.length) {\n dest.splice(idx--, 1);\n }\n } else {\n items = items.slice(skip, skip + take);\n group.items = items;\n if (!group.items.length) {\n dest.splice(idx--, 1);\n }\n }\n if (items.length === 0) {\n skip -= length;\n } else {\n skip = 0;\n take -= items.length;\n }\n if (++idx >= dest.length) {\n break;\n }\n }\n if (idx < dest.length) {\n dest.splice(idx, dest.length - idx);\n }\n }\n function flattenGroups(data) {\n var idx, result = [], length, items, itemIndex;\n for (idx = 0, length = data.length; idx < length; idx++) {\n var group = data.at(idx);\n if (group.hasSubgroups) {\n result = result.concat(flattenGroups(group.items));\n } else {\n items = group.items;\n for (itemIndex = 0; itemIndex < items.length; itemIndex++) {\n result.push(items.at(itemIndex));\n }\n }\n }\n return result;\n }\n function wrapGroupItems(data, model) {\n var idx, length, group;\n if (model) {\n for (idx = 0, length = data.length; idx < length; idx++) {\n group = data.at(idx);\n if (group.hasSubgroups) {\n wrapGroupItems(group.items, model);\n } else {\n group.items = new LazyObservableArray(group.items, model);\n }\n }\n }\n }\n function eachGroupItems(data, func) {\n for (var idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].hasSubgroups) {\n if (eachGroupItems(data[idx].items, func)) {\n return true;\n }\n } else if (func(data[idx].items, data[idx])) {\n return true;\n }\n }\n }\n function replaceInRanges(ranges, data, item, observable) {\n for (var idx = 0; idx < ranges.length; idx++) {\n if (ranges[idx].data === data) {\n break;\n }\n if (replaceInRange(ranges[idx].data, item, observable)) {\n break;\n }\n }\n }\n function replaceInRange(items, item, observable) {\n for (var idx = 0, length = items.length; idx < length; idx++) {\n if (items[idx] && items[idx].hasSubgroups) {\n return replaceInRange(items[idx].items, item, observable);\n } else if (items[idx] === item || items[idx] === observable) {\n items[idx] = observable;\n return true;\n }\n }\n }\n function replaceWithObservable(view, data, ranges, type, serverGrouping) {\n for (var viewIndex = 0, length = view.length; viewIndex < length; viewIndex++) {\n var item = view[viewIndex];\n if (!item || item instanceof type) {\n continue;\n }\n if (item.hasSubgroups !== undefined && !serverGrouping) {\n replaceWithObservable(item.items, data, ranges, type, serverGrouping);\n } else {\n for (var idx = 0; idx < data.length; idx++) {\n if (data[idx] === item) {\n view[viewIndex] = data.at(idx);\n replaceInRanges(ranges, data, item, view[viewIndex]);\n break;\n }\n }\n }\n }\n }\n function removeModel(data, model) {\n var length = data.length;\n var dataItem;\n var idx;\n for (idx = 0; idx < length; idx++) {\n dataItem = data[idx];\n if (dataItem.uid && dataItem.uid == model.uid) {\n data.splice(idx, 1);\n return dataItem;\n }\n }\n }\n function indexOfPristineModel(data, model) {\n if (model) {\n return indexOf(data, function (item) {\n return item.uid && item.uid == model.uid || item[model.idField] === model.id && model.id !== model._defaultId;\n });\n }\n return -1;\n }\n function indexOfModel(data, model) {\n if (model) {\n return indexOf(data, function (item) {\n return item.uid == model.uid;\n });\n }\n return -1;\n }\n function indexOf(data, comparer) {\n var idx, length;\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (comparer(data[idx])) {\n return idx;\n }\n }\n return -1;\n }\n function fieldNameFromModel(fields, name) {\n if (fields && !isEmptyObject(fields)) {\n var descriptor = fields[name];\n var fieldName;\n if (isPlainObject(descriptor)) {\n fieldName = descriptor.from || descriptor.field || name;\n } else {\n fieldName = fields[name] || name;\n }\n if (isFunction(fieldName)) {\n return name;\n }\n return fieldName;\n }\n return name;\n }\n function convertFilterDescriptorsField(descriptor, model) {\n var idx, length, target = {};\n for (var field in descriptor) {\n if (field !== 'filters') {\n target[field] = descriptor[field];\n }\n }\n if (descriptor.filters) {\n target.filters = [];\n for (idx = 0, length = descriptor.filters.length; idx < length; idx++) {\n target.filters[idx] = convertFilterDescriptorsField(descriptor.filters[idx], model);\n }\n } else {\n target.field = fieldNameFromModel(model.fields, target.field);\n }\n return target;\n }\n function convertDescriptorsField(descriptors, model) {\n var idx, length, result = [], target, descriptor;\n for (idx = 0, length = descriptors.length; idx < length; idx++) {\n target = {};\n descriptor = descriptors[idx];\n for (var field in descriptor) {\n target[field] = descriptor[field];\n }\n target.field = fieldNameFromModel(model.fields, target.field);\n if (target.aggregates && isArray(target.aggregates)) {\n target.aggregates = convertDescriptorsField(target.aggregates, model);\n }\n result.push(target);\n }\n return result;\n }\n var DataSource = Observable.extend({\n init: function (options) {\n var that = this, model, data;\n if (options) {\n data = options.data;\n }\n options = that.options = extend({}, that.options, options);\n that._map = {};\n that._prefetch = {};\n that._data = [];\n that._pristineData = [];\n that._ranges = [];\n that._view = [];\n that._pristineTotal = 0;\n that._destroyed = [];\n that._pageSize = options.pageSize;\n that._page = options.page || (options.pageSize ? 1 : undefined);\n that._sort = normalizeSort(options.sort);\n that._filter = normalizeFilter(options.filter);\n that._group = normalizeGroup(options.group);\n that._aggregate = options.aggregate;\n that._total = options.total;\n that._shouldDetachObservableParents = true;\n Observable.fn.init.call(that);\n that.transport = Transport.create(options, data, that);\n if (isFunction(that.transport.push)) {\n that.transport.push({\n pushCreate: proxy(that._pushCreate, that),\n pushUpdate: proxy(that._pushUpdate, that),\n pushDestroy: proxy(that._pushDestroy, that)\n });\n }\n if (options.offlineStorage != null) {\n if (typeof options.offlineStorage == 'string') {\n var key = options.offlineStorage;\n that._storage = {\n getItem: function () {\n return JSON.parse(localStorage.getItem(key));\n },\n setItem: function (item) {\n localStorage.setItem(key, stringify(that.reader.serialize(item)));\n }\n };\n } else {\n that._storage = options.offlineStorage;\n }\n }\n that.reader = new kendo.data.readers[options.schema.type || 'json'](options.schema);\n model = that.reader.model || {};\n that._detachObservableParents();\n that._data = that._observe(that._data);\n that._online = true;\n that.bind([\n 'push',\n ERROR,\n CHANGE,\n REQUESTSTART,\n SYNC,\n REQUESTEND,\n PROGRESS\n ], options);\n },\n options: {\n data: null,\n schema: { modelBase: Model },\n offlineStorage: null,\n serverSorting: false,\n serverPaging: false,\n serverFiltering: false,\n serverGrouping: false,\n serverAggregates: false,\n batch: false,\n inPlaceSort: false\n },\n clone: function () {\n return this;\n },\n online: function (value) {\n if (value !== undefined) {\n if (this._online != value) {\n this._online = value;\n if (value) {\n return this.sync();\n }\n }\n return $.Deferred().resolve().promise();\n } else {\n return this._online;\n }\n },\n offlineData: function (state) {\n if (this.options.offlineStorage == null) {\n return null;\n }\n if (state !== undefined) {\n return this._storage.setItem(state);\n }\n return this._storage.getItem() || [];\n },\n _isServerGrouped: function () {\n var group = this.group() || [];\n return this.options.serverGrouping && group.length;\n },\n _pushCreate: function (result) {\n this._push(result, 'pushCreate');\n },\n _pushUpdate: function (result) {\n this._push(result, 'pushUpdate');\n },\n _pushDestroy: function (result) {\n this._push(result, 'pushDestroy');\n },\n _push: function (result, operation) {\n var data = this._readData(result);\n if (!data) {\n data = result;\n }\n this[operation](data);\n },\n _flatData: function (data, skip) {\n if (data) {\n if (this._isServerGrouped()) {\n return flattenGroups(data);\n }\n if (!skip) {\n for (var idx = 0; idx < data.length; idx++) {\n data.at(idx);\n }\n }\n }\n return data;\n },\n parent: noop,\n get: function (id) {\n var idx, length, data = this._flatData(this._data, this.options.useRanges);\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].id == id) {\n return data[idx];\n }\n }\n },\n getByUid: function (id) {\n return this._getByUid(id, this._data);\n },\n _getByUid: function (id, dataItems) {\n var idx, length, data = this._flatData(dataItems, this.options.useRanges);\n if (!data) {\n return;\n }\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].uid == id) {\n return data[idx];\n }\n }\n },\n indexOf: function (model) {\n return indexOfModel(this._data, model);\n },\n at: function (index) {\n return this._data.at(index);\n },\n data: function (value) {\n var that = this;\n if (value !== undefined) {\n that._detachObservableParents();\n that._data = this._observe(value);\n that._pristineData = value.slice(0);\n that._storeData();\n that._ranges = [];\n that.trigger('reset');\n that._addRange(that._data);\n that._total = that._data.length;\n that._pristineTotal = that._total;\n that._process(that._data);\n } else {\n if (that._data) {\n for (var idx = 0; idx < that._data.length; idx++) {\n that._data.at(idx);\n }\n }\n return that._data;\n }\n },\n view: function (value) {\n if (value === undefined) {\n return this._view;\n } else {\n this._view = this._observeView(value);\n }\n },\n _observeView: function (data) {\n var that = this;\n replaceWithObservable(data, that._data, that._ranges, that.reader.model || ObservableObject, that._isServerGrouped());\n var view = new LazyObservableArray(data, that.reader.model);\n view.parent = function () {\n return that.parent();\n };\n return view;\n },\n flatView: function () {\n var groups = this.group() || [];\n if (groups.length) {\n return flattenGroups(this._view);\n } else {\n return this._view;\n }\n },\n add: function (model) {\n return this.insert(this._data.length, model);\n },\n _createNewModel: function (model) {\n if (this.reader.model) {\n return new this.reader.model(model);\n }\n if (model instanceof ObservableObject) {\n return model;\n }\n return new ObservableObject(model);\n },\n insert: function (index, model) {\n if (!model) {\n model = index;\n index = 0;\n }\n if (!(model instanceof Model)) {\n model = this._createNewModel(model);\n }\n if (this._isServerGrouped()) {\n this._data.splice(index, 0, this._wrapInEmptyGroup(model));\n } else {\n this._data.splice(index, 0, model);\n }\n this._insertModelInRange(index, model);\n return model;\n },\n pushInsert: function (index, items) {\n var that = this;\n var rangeSpan = that._getCurrentRangeSpan();\n if (!items) {\n items = index;\n index = 0;\n }\n if (!isArray(items)) {\n items = [items];\n }\n var pushed = [];\n var autoSync = this.options.autoSync;\n this.options.autoSync = false;\n try {\n for (var idx = 0; idx < items.length; idx++) {\n var item = items[idx];\n var result = this.insert(index, item);\n pushed.push(result);\n var pristine = result.toJSON();\n if (this._isServerGrouped()) {\n pristine = this._wrapInEmptyGroup(pristine);\n }\n this._pristineData.push(pristine);\n if (rangeSpan && rangeSpan.length) {\n $(rangeSpan).last()[0].pristineData.push(pristine);\n }\n index++;\n }\n } finally {\n this.options.autoSync = autoSync;\n }\n if (pushed.length) {\n this.trigger('push', {\n type: 'create',\n items: pushed\n });\n }\n },\n pushCreate: function (items) {\n this.pushInsert(this._data.length, items);\n },\n pushUpdate: function (items) {\n if (!isArray(items)) {\n items = [items];\n }\n var pushed = [];\n for (var idx = 0; idx < items.length; idx++) {\n var item = items[idx];\n var model = this._createNewModel(item);\n var target = this.get(model.id);\n if (target) {\n pushed.push(target);\n target.accept(item);\n target.trigger(CHANGE);\n this._updatePristineForModel(target, item);\n } else {\n this.pushCreate(item);\n }\n }\n if (pushed.length) {\n this.trigger('push', {\n type: 'update',\n items: pushed\n });\n }\n },\n pushDestroy: function (items) {\n var pushed = this._removeItems(items);\n if (pushed.length) {\n this.trigger('push', {\n type: 'destroy',\n items: pushed\n });\n }\n },\n _removeItems: function (items) {\n if (!isArray(items)) {\n items = [items];\n }\n var destroyed = [];\n var autoSync = this.options.autoSync;\n this.options.autoSync = false;\n try {\n for (var idx = 0; idx < items.length; idx++) {\n var item = items[idx];\n var model = this._createNewModel(item);\n var found = false;\n this._eachItem(this._data, function (items) {\n for (var idx = 0; idx < items.length; idx++) {\n var item = items.at(idx);\n if (item.id === model.id) {\n destroyed.push(item);\n items.splice(idx, 1);\n found = true;\n break;\n }\n }\n });\n if (found) {\n this._removePristineForModel(model);\n this._destroyed.pop();\n }\n }\n } finally {\n this.options.autoSync = autoSync;\n }\n return destroyed;\n },\n remove: function (model) {\n var result, that = this, hasGroups = that._isServerGrouped();\n this._eachItem(that._data, function (items) {\n result = removeModel(items, model);\n if (result && hasGroups) {\n if (!result.isNew || !result.isNew()) {\n that._destroyed.push(result);\n }\n return true;\n }\n });\n this._removeModelFromRanges(model);\n return model;\n },\n destroyed: function () {\n return this._destroyed;\n },\n created: function () {\n var idx, length, result = [], data = this._flatData(this._data, this.options.useRanges);\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].isNew && data[idx].isNew()) {\n result.push(data[idx]);\n }\n }\n return result;\n },\n updated: function () {\n var idx, length, result = [], data = this._flatData(this._data, this.options.useRanges);\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].isNew && !data[idx].isNew() && data[idx].dirty) {\n result.push(data[idx]);\n }\n }\n return result;\n },\n sync: function () {\n var that = this, created = [], updated = [], destroyed = that._destroyed;\n var promise = $.Deferred().resolve().promise();\n if (that.online()) {\n if (!that.reader.model) {\n return promise;\n }\n created = that.created();\n updated = that.updated();\n var promises = [];\n if (that.options.batch && that.transport.submit) {\n promises = that._sendSubmit(created, updated, destroyed);\n } else {\n promises.push.apply(promises, that._send('create', created));\n promises.push.apply(promises, that._send('update', updated));\n promises.push.apply(promises, that._send('destroy', destroyed));\n }\n promise = $.when.apply(null, promises).then(function () {\n var idx, length;\n for (idx = 0, length = arguments.length; idx < length; idx++) {\n if (arguments[idx]) {\n that._accept(arguments[idx]);\n }\n }\n that._storeData(true);\n that._change({ action: 'sync' });\n that.trigger(SYNC);\n });\n } else {\n that._storeData(true);\n that._change({ action: 'sync' });\n }\n return promise;\n },\n cancelChanges: function (model) {\n var that = this;\n if (model instanceof kendo.data.Model) {\n that._cancelModel(model);\n } else {\n that._destroyed = [];\n that._detachObservableParents();\n that._data = that._observe(that._pristineData);\n if (that.options.serverPaging) {\n that._total = that._pristineTotal;\n }\n that._ranges = [];\n that._addRange(that._data, 0);\n that._change();\n that._markOfflineUpdatesAsDirty();\n }\n },\n _markOfflineUpdatesAsDirty: function () {\n var that = this;\n if (that.options.offlineStorage != null) {\n that._eachItem(that._data, function (items) {\n for (var idx = 0; idx < items.length; idx++) {\n var item = items.at(idx);\n if (item.__state__ == 'update' || item.__state__ == 'create') {\n item.dirty = true;\n }\n }\n });\n }\n },\n hasChanges: function () {\n var idx, length, data = this._flatData(this._data, this.options.useRanges);\n if (this._destroyed.length) {\n return true;\n }\n for (idx = 0, length = data.length; idx < length; idx++) {\n if (data[idx].isNew && data[idx].isNew() || data[idx].dirty) {\n return true;\n }\n }\n return false;\n },\n _accept: function (result) {\n var that = this, models = result.models, response = result.response, idx = 0, serverGroup = that._isServerGrouped(), pristine = that._pristineData, type = result.type, length;\n that.trigger(REQUESTEND, {\n response: response,\n type: type\n });\n if (response && !isEmptyObject(response)) {\n response = that.reader.parse(response);\n if (that._handleCustomErrors(response)) {\n return;\n }\n response = that.reader.data(response);\n if (!isArray(response)) {\n response = [response];\n }\n } else {\n response = $.map(models, function (model) {\n return model.toJSON();\n });\n }\n if (type === 'destroy') {\n that._destroyed = [];\n }\n for (idx = 0, length = models.length; idx < length; idx++) {\n if (type !== 'destroy') {\n models[idx].accept(response[idx]);\n if (type === 'create') {\n pristine.push(serverGroup ? that._wrapInEmptyGroup(models[idx]) : response[idx]);\n } else if (type === 'update') {\n that._updatePristineForModel(models[idx], response[idx]);\n }\n } else {\n that._removePristineForModel(models[idx]);\n }\n }\n },\n _updatePristineForModel: function (model, values) {\n this._executeOnPristineForModel(model, function (index, items) {\n kendo.deepExtend(items[index], values);\n });\n },\n _executeOnPristineForModel: function (model, callback) {\n this._eachPristineItem(function (items) {\n var index = indexOfPristineModel(items, model);\n if (index > -1) {\n callback(index, items);\n return true;\n }\n });\n },\n _removePristineForModel: function (model) {\n this._executeOnPristineForModel(model, function (index, items) {\n items.splice(index, 1);\n });\n },\n _readData: function (data) {\n var read = !this._isServerGrouped() ? this.reader.data : this.reader.groups;\n return read.call(this.reader, data);\n },\n _eachPristineItem: function (callback) {\n var that = this;\n var options = that.options;\n var rangeSpan = that._getCurrentRangeSpan();\n that._eachItem(that._pristineData, callback);\n if (options.serverPaging && options.useRanges) {\n each(rangeSpan, function (i, range) {\n that._eachItem(range.pristineData, callback);\n });\n }\n },\n _eachItem: function (data, callback) {\n if (data && data.length) {\n if (this._isServerGrouped()) {\n eachGroupItems(data, callback);\n } else {\n callback(data);\n }\n }\n },\n _pristineForModel: function (model) {\n var pristine, idx, callback = function (items) {\n idx = indexOfPristineModel(items, model);\n if (idx > -1) {\n pristine = items[idx];\n return true;\n }\n };\n this._eachPristineItem(callback);\n return pristine;\n },\n _cancelModel: function (model) {\n var that = this;\n var pristine = this._pristineForModel(model);\n this._eachItem(this._data, function (items) {\n var idx = indexOfModel(items, model);\n if (idx >= 0) {\n if (pristine && (!model.isNew() || pristine.__state__)) {\n items[idx].accept(pristine);\n if (pristine.__state__ == 'update') {\n items[idx].dirty = true;\n }\n } else {\n items.splice(idx, 1);\n that._removeModelFromRanges(model);\n }\n }\n });\n },\n _submit: function (promises, data) {\n var that = this;\n that.trigger(REQUESTSTART, { type: 'submit' });\n that.trigger(PROGRESS);\n that.transport.submit(extend({\n success: function (response, type) {\n var promise = $.grep(promises, function (x) {\n return x.type == type;\n })[0];\n if (promise) {\n promise.resolve({\n response: response,\n models: promise.models,\n type: type\n });\n }\n },\n error: function (response, status, error) {\n for (var idx = 0; idx < promises.length; idx++) {\n promises[idx].reject(response);\n }\n that.error(response, status, error);\n }\n }, data));\n },\n _sendSubmit: function (created, updated, destroyed) {\n var that = this, promises = [];\n if (that.options.batch) {\n if (created.length) {\n promises.push($.Deferred(function (deferred) {\n deferred.type = 'create';\n deferred.models = created;\n }));\n }\n if (updated.length) {\n promises.push($.Deferred(function (deferred) {\n deferred.type = 'update';\n deferred.models = updated;\n }));\n }\n if (destroyed.length) {\n promises.push($.Deferred(function (deferred) {\n deferred.type = 'destroy';\n deferred.models = destroyed;\n }));\n }\n that._submit(promises, {\n data: {\n created: that.reader.serialize(toJSON(created)),\n updated: that.reader.serialize(toJSON(updated)),\n destroyed: that.reader.serialize(toJSON(destroyed))\n }\n });\n }\n return promises;\n },\n _promise: function (data, models, type) {\n var that = this;\n return $.Deferred(function (deferred) {\n that.trigger(REQUESTSTART, { type: type });\n that.trigger(PROGRESS);\n that.transport[type].call(that.transport, extend({\n success: function (response) {\n deferred.resolve({\n response: response,\n models: models,\n type: type\n });\n },\n error: function (response, status, error) {\n deferred.reject(response);\n that.error(response, status, error);\n }\n }, data));\n }).promise();\n },\n _send: function (method, data) {\n var that = this, idx, length, promises = [], converted = that.reader.serialize(toJSON(data));\n if (that.options.batch) {\n if (data.length) {\n promises.push(that._promise({ data: { models: converted } }, data, method));\n }\n } else {\n for (idx = 0, length = data.length; idx < length; idx++) {\n promises.push(that._promise({ data: converted[idx] }, [data[idx]], method));\n }\n }\n return promises;\n },\n read: function (data) {\n var that = this, params = that._params(data);\n var deferred = $.Deferred();\n that._queueRequest(params, function () {\n var isPrevented = that.trigger(REQUESTSTART, { type: 'read' });\n if (!isPrevented) {\n that.trigger(PROGRESS);\n that._ranges = [];\n that.trigger('reset');\n if (that.online()) {\n that.transport.read({\n data: params,\n success: function (data) {\n that._ranges = [];\n that.success(data, params);\n deferred.resolve();\n },\n error: function () {\n var args = slice.call(arguments);\n that.error.apply(that, args);\n deferred.reject.apply(deferred, args);\n }\n });\n } else if (that.options.offlineStorage != null) {\n that.success(that.offlineData(), params);\n deferred.resolve();\n }\n } else {\n that._dequeueRequest();\n deferred.resolve(isPrevented);\n }\n });\n return deferred.promise();\n },\n _readAggregates: function (data) {\n return this.reader.aggregates(data);\n },\n success: function (data) {\n var that = this, options = that.options, requestParams;\n that.trigger(REQUESTEND, {\n response: data,\n type: 'read'\n });\n if (that.online()) {\n data = that.reader.parse(data);\n if (that._handleCustomErrors(data)) {\n that._dequeueRequest();\n return;\n }\n that._total = that.reader.total(data);\n if (that._pageSize > that._total) {\n that._pageSize = that._total;\n if (that.options.pageSize && that.options.pageSize > that._pageSize) {\n that._pageSize = that.options.pageSize;\n }\n }\n if (that._aggregate && options.serverAggregates) {\n that._aggregateResult = that._readAggregates(data);\n }\n requestParams = arguments.length > 1 ? arguments[1] : undefined;\n data = that._readData(data, requestParams);\n that._destroyed = [];\n } else {\n data = that._readData(data);\n var items = [];\n var itemIds = {};\n var model = that.reader.model;\n var idField = model ? model.idField : 'id';\n var idx;\n for (idx = 0; idx < this._destroyed.length; idx++) {\n var id = this._destroyed[idx][idField];\n itemIds[id] = id;\n }\n for (idx = 0; idx < data.length; idx++) {\n var item = data[idx];\n var state = item.__state__;\n if (state == 'destroy') {\n if (!itemIds[item[idField]]) {\n this._destroyed.push(this._createNewModel(item));\n }\n } else {\n items.push(item);\n }\n }\n data = items;\n that._total = data.length;\n }\n that._pristineTotal = that._total;\n that._pristineData = data.slice(0);\n that._detachObservableParents();\n if (that.options.endless) {\n that._data.unbind(CHANGE, that._changeHandler);\n data = that._observe(data);\n for (var i = 0; i < data.length; i++) {\n that._data.push(data[i]);\n }\n that._data.bind(CHANGE, that._changeHandler);\n } else {\n that._data = that._observe(data);\n }\n that._markOfflineUpdatesAsDirty();\n that._storeData();\n that._addRange(that._data);\n that._process(that._data);\n that._dequeueRequest();\n },\n _detachObservableParents: function () {\n if (this._data && this._shouldDetachObservableParents) {\n for (var idx = 0; idx < this._data.length; idx++) {\n if (this._data[idx].parent) {\n this._data[idx].parent = noop;\n }\n }\n }\n },\n _storeData: function (updatePristine) {\n var serverGrouping = this._isServerGrouped();\n var model = this.reader.model;\n function items(data) {\n var state = [];\n for (var idx = 0; idx < data.length; idx++) {\n var dataItem = data.at(idx);\n var item = dataItem.toJSON();\n if (serverGrouping && dataItem.items) {\n item.items = items(dataItem.items);\n } else {\n item.uid = dataItem.uid;\n if (model) {\n if (dataItem.isNew()) {\n item.__state__ = 'create';\n } else if (dataItem.dirty) {\n item.__state__ = 'update';\n }\n }\n }\n state.push(item);\n }\n return state;\n }\n if (this.options.offlineStorage != null) {\n var state = items(this._data);\n var destroyed = [];\n for (var idx = 0; idx < this._destroyed.length; idx++) {\n var item = this._destroyed[idx].toJSON();\n item.__state__ = 'destroy';\n destroyed.push(item);\n }\n this.offlineData(state.concat(destroyed));\n if (updatePristine) {\n this._pristineData = this._readData(state);\n }\n }\n },\n _addRange: function (data, skip) {\n var that = this, start = typeof skip !== 'undefined' ? skip : that._skip || 0, end = start + that._flatData(data, true).length;\n that._ranges.push({\n start: start,\n end: end,\n data: data,\n pristineData: data.toJSON(),\n timestamp: that._timeStamp()\n });\n that._sortRanges();\n },\n _sortRanges: function () {\n this._ranges.sort(function (x, y) {\n return x.start - y.start;\n });\n },\n error: function (xhr, status, errorThrown) {\n this._dequeueRequest();\n this.trigger(REQUESTEND, {});\n this.trigger(ERROR, {\n xhr: xhr,\n status: status,\n errorThrown: errorThrown\n });\n },\n _params: function (data) {\n var that = this, options = extend({\n take: that.take(),\n skip: that.skip(),\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 }, data);\n if (!that.options.serverPaging) {\n delete options.take;\n delete options.skip;\n delete options.page;\n delete options.pageSize;\n }\n if (!that.options.serverGrouping) {\n delete options.group;\n } else if (that.reader.model && options.group) {\n options.group = convertDescriptorsField(options.group, that.reader.model);\n }\n if (!that.options.serverFiltering) {\n delete options.filter;\n } else if (that.reader.model && options.filter) {\n options.filter = convertFilterDescriptorsField(options.filter, that.reader.model);\n }\n if (!that.options.serverSorting) {\n delete options.sort;\n } else if (that.reader.model && options.sort) {\n options.sort = convertDescriptorsField(options.sort, that.reader.model);\n }\n if (!that.options.serverAggregates) {\n delete options.aggregate;\n } else if (that.reader.model && options.aggregate) {\n options.aggregate = convertDescriptorsField(options.aggregate, that.reader.model);\n }\n return options;\n },\n _queueRequest: function (options, callback) {\n var that = this;\n if (!that._requestInProgress) {\n that._requestInProgress = true;\n that._pending = undefined;\n callback();\n } else {\n that._pending = {\n callback: proxy(callback, that),\n options: options\n };\n }\n },\n _dequeueRequest: function () {\n var that = this;\n that._requestInProgress = false;\n if (that._pending) {\n that._queueRequest(that._pending.options, that._pending.callback);\n }\n },\n _handleCustomErrors: function (response) {\n if (this.reader.errors) {\n var errors = this.reader.errors(response);\n if (errors) {\n this.trigger(ERROR, {\n xhr: null,\n status: 'customerror',\n errorThrown: 'custom error',\n errors: errors\n });\n return true;\n }\n }\n return false;\n },\n _shouldWrap: function (data) {\n var model = this.reader.model;\n if (model && data.length) {\n return !(data[0] instanceof model);\n }\n return false;\n },\n _observe: function (data) {\n var that = this, model = that.reader.model;\n that._shouldDetachObservableParents = true;\n if (data instanceof ObservableArray) {\n that._shouldDetachObservableParents = false;\n if (that._shouldWrap(data)) {\n data.type = that.reader.model;\n data.wrapAll(data, data);\n }\n } else {\n var arrayType = that.pageSize() && !that.options.serverPaging ? LazyObservableArray : ObservableArray;\n data = new arrayType(data, that.reader.model);\n data.parent = function () {\n return that.parent();\n };\n }\n if (that._isServerGrouped()) {\n wrapGroupItems(data, model);\n }\n if (that._changeHandler && that._data && that._data instanceof ObservableArray) {\n that._data.unbind(CHANGE, that._changeHandler);\n } else {\n that._changeHandler = proxy(that._change, that);\n }\n return data.bind(CHANGE, that._changeHandler);\n },\n _updateTotalForAction: function (action, items) {\n var that = this;\n var total = parseInt(that._total, 10);\n if (!isNumber(that._total)) {\n total = parseInt(that._pristineTotal, 10);\n }\n if (action === 'add') {\n total += items.length;\n } else if (action === 'remove') {\n total -= items.length;\n } else if (action !== 'itemchange' && action !== 'sync' && !that.options.serverPaging) {\n total = that._pristineTotal;\n } else if (action === 'sync') {\n total = that._pristineTotal = parseInt(that._total, 10);\n }\n that._total = total;\n },\n _change: function (e) {\n var that = this, idx, length, action = e ? e.action : '';\n if (action === 'remove') {\n for (idx = 0, length = e.items.length; idx < length; idx++) {\n if (!e.items[idx].isNew || !e.items[idx].isNew()) {\n that._destroyed.push(e.items[idx]);\n }\n }\n }\n if (that.options.autoSync && (action === 'add' || action === 'remove' || action === 'itemchange')) {\n var handler = function (args) {\n if (args.action === 'sync') {\n that.unbind('change', handler);\n that._updateTotalForAction(action, e.items);\n }\n };\n that.first('change', handler);\n that.sync();\n } else {\n that._updateTotalForAction(action, e ? e.items : []);\n that._process(that._data, e);\n }\n },\n _calculateAggregates: function (data, options) {\n options = options || {};\n var query = new Query(data), aggregates = options.aggregate, filter = options.filter;\n if (filter) {\n query = query.filter(filter);\n }\n return query.aggregate(aggregates);\n },\n _process: function (data, e) {\n var that = this, options = {}, result;\n if (that.options.serverPaging !== true) {\n options.skip = that._skip;\n options.take = that._take || that._pageSize;\n if (options.skip === undefined && that._page !== undefined && that._pageSize !== undefined) {\n options.skip = (that._page - 1) * that._pageSize;\n }\n }\n if (that.options.serverSorting !== true) {\n options.sort = that._sort;\n }\n if (that.options.serverFiltering !== true) {\n options.filter = that._filter;\n }\n if (that.options.serverGrouping !== true) {\n options.group = that._group;\n }\n if (that.options.serverAggregates !== true) {\n options.aggregate = that._aggregate;\n that._aggregateResult = that._calculateAggregates(data, options);\n }\n result = that._queryProcess(data, options);\n that.view(result.data);\n if (result.total !== undefined && !that.options.serverFiltering) {\n that._total = result.total;\n }\n e = e || {};\n e.items = e.items || that._view;\n that.trigger(CHANGE, e);\n },\n _queryProcess: function (data, options) {\n if (this.options.inPlaceSort) {\n return Query.process(data, options, this.options.inPlaceSort);\n } else {\n return Query.process(data, options);\n }\n },\n _mergeState: function (options) {\n var that = this;\n if (options !== undefined) {\n that._pageSize = options.pageSize;\n that._page = options.page;\n that._sort = options.sort;\n that._filter = options.filter;\n that._group = options.group;\n that._aggregate = options.aggregate;\n that._skip = that._currentRangeStart = options.skip;\n that._take = options.take;\n if (that._skip === undefined) {\n that._skip = that._currentRangeStart = that.skip();\n options.skip = that.skip();\n }\n if (that._take === undefined && that._pageSize !== undefined) {\n that._take = that._pageSize;\n options.take = that._take;\n }\n if (options.sort) {\n that._sort = options.sort = normalizeSort(options.sort);\n }\n if (options.filter) {\n that._filter = options.filter = normalizeFilter(options.filter);\n }\n if (options.group) {\n that._group = options.group = normalizeGroup(options.group);\n }\n if (options.aggregate) {\n that._aggregate = options.aggregate = normalizeAggregate(options.aggregate);\n }\n }\n return options;\n },\n query: function (options) {\n var result;\n var remote = this.options.serverSorting || this.options.serverPaging || this.options.serverFiltering || this.options.serverGrouping || this.options.serverAggregates;\n if (remote || (this._data === undefined || this._data.length === 0) && !this._destroyed.length) {\n if (this.options.endless) {\n var moreItemsCount = options.pageSize - this.pageSize();\n if (moreItemsCount > 0) {\n moreItemsCount = this.pageSize();\n options.page = options.pageSize / moreItemsCount;\n options.pageSize = moreItemsCount;\n } else {\n options.page = 1;\n this.options.endless = false;\n }\n }\n return this.read(this._mergeState(options));\n }\n var isPrevented = this.trigger(REQUESTSTART, { type: 'read' });\n if (!isPrevented) {\n this.trigger(PROGRESS);\n result = this._queryProcess(this._data, this._mergeState(options));\n if (!this.options.serverFiltering) {\n if (result.total !== undefined) {\n this._total = result.total;\n } else {\n this._total = this._data.length;\n }\n }\n this._aggregateResult = this._calculateAggregates(this._data, options);\n this.view(result.data);\n this.trigger(REQUESTEND, { type: 'read' });\n this.trigger(CHANGE, { items: result.data });\n }\n return $.Deferred().resolve(isPrevented).promise();\n },\n fetch: function (callback) {\n var that = this;\n var fn = function (isPrevented) {\n if (isPrevented !== true && isFunction(callback)) {\n callback.call(that);\n }\n };\n return this._query().then(fn);\n },\n _query: function (options) {\n var that = this;\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 }, options));\n },\n next: function (options) {\n var that = this, page = that.page(), total = that.total();\n options = options || {};\n if (!page || total && page + 1 > that.totalPages()) {\n return;\n }\n that._skip = that._currentRangeStart = page * that.take();\n page += 1;\n options.page = page;\n that._query(options);\n return page;\n },\n prev: function (options) {\n var that = this, page = that.page();\n options = options || {};\n if (!page || page === 1) {\n return;\n }\n that._skip = that._currentRangeStart = that._skip - that.take();\n page -= 1;\n options.page = page;\n that._query(options);\n return page;\n },\n page: function (val) {\n var that = this, skip;\n if (val !== undefined) {\n val = math.max(math.min(math.max(val, 1), that.totalPages()), 1);\n that._query({ page: val });\n return;\n }\n skip = that.skip();\n return skip !== undefined ? math.round((skip || 0) / (that.take() || 1)) + 1 : undefined;\n },\n pageSize: function (val) {\n var that = this;\n if (val !== undefined) {\n that._query({\n pageSize: val,\n page: 1\n });\n return;\n }\n return that.take();\n },\n sort: function (val) {\n var that = this;\n if (val !== undefined) {\n that._query({ sort: val });\n return;\n }\n return that._sort;\n },\n filter: function (val) {\n var that = this;\n if (val === undefined) {\n return that._filter;\n }\n that.trigger('reset');\n that._query({\n filter: val,\n page: 1\n });\n },\n group: function (val) {\n var that = this;\n if (val !== undefined) {\n that._query({ group: val });\n return;\n }\n return that._group;\n },\n total: function () {\n return parseInt(this._total || 0, 10);\n },\n aggregate: function (val) {\n var that = this;\n if (val !== undefined) {\n that._query({ aggregate: val });\n return;\n }\n return that._aggregate;\n },\n aggregates: function () {\n var result = this._aggregateResult;\n if (isEmptyObject(result)) {\n result = this._emptyAggregates(this.aggregate());\n }\n return result;\n },\n _emptyAggregates: function (aggregates) {\n var result = {};\n if (!isEmptyObject(aggregates)) {\n var aggregate = {};\n if (!isArray(aggregates)) {\n aggregates = [aggregates];\n }\n for (var idx = 0; idx < aggregates.length; idx++) {\n aggregate[aggregates[idx].aggregate] = 0;\n result[aggregates[idx].field] = aggregate;\n }\n }\n return result;\n },\n _wrapInEmptyGroup: function (model) {\n var groups = this.group(), parent, group, idx, length;\n for (idx = groups.length - 1, length = 0; idx >= length; idx--) {\n group = groups[idx];\n parent = {\n value: model.get(group.field),\n field: group.field,\n items: parent ? [parent] : [model],\n hasSubgroups: !!parent,\n aggregates: this._emptyAggregates(group.aggregates)\n };\n }\n return parent;\n },\n totalPages: function () {\n var that = this, pageSize = that.pageSize() || that.total();\n return math.ceil((that.total() || 0) / pageSize);\n },\n inRange: function (skip, take) {\n var that = this, end = math.min(skip + take, that.total());\n if (!that.options.serverPaging && that._data.length > 0) {\n return true;\n }\n return that._findRange(skip, end).length > 0;\n },\n lastRange: function () {\n var ranges = this._ranges;\n return ranges[ranges.length - 1] || {\n start: 0,\n end: 0,\n data: []\n };\n },\n firstItemUid: function () {\n var ranges = this._ranges;\n return ranges.length && ranges[0].data.length && ranges[0].data[0].uid;\n },\n enableRequestsInProgress: function () {\n this._skipRequestsInProgress = false;\n },\n _timeStamp: function () {\n return new Date().getTime();\n },\n range: function (skip, take, callback) {\n this._currentRequestTimeStamp = this._timeStamp();\n this._skipRequestsInProgress = true;\n skip = math.min(skip || 0, this.total());\n callback = isFunction(callback) ? callback : noop;\n var that = this, pageSkip = math.max(math.floor(skip / take), 0) * take, size = math.min(pageSkip + take, that.total()), data;\n data = that._findRange(skip, math.min(skip + take, that.total()));\n if (data.length || that.total() === 0) {\n that._processRangeData(data, skip, take, pageSkip, size);\n callback();\n return;\n }\n if (take !== undefined) {\n if (!that._rangeExists(pageSkip, size)) {\n that.prefetch(pageSkip, take, function () {\n if (skip > pageSkip && size < that.total() && !that._rangeExists(size, math.min(size + take, that.total()))) {\n that.prefetch(size, take, function () {\n that.range(skip, take, callback);\n });\n } else {\n that.range(skip, take, callback);\n }\n });\n } else if (pageSkip < skip) {\n that.prefetch(size, take, function () {\n that.range(skip, take, callback);\n });\n }\n }\n },\n _findRange: function (start, end) {\n var that = this, ranges = that._ranges, range, data = [], skipIdx, takeIdx, startIndex, endIndex, rangeData, rangeEnd, processed, options = that.options, remote = options.serverSorting || options.serverPaging || options.serverFiltering || options.serverGrouping || options.serverAggregates, flatData, count, length;\n for (skipIdx = 0, length = ranges.length; skipIdx < length; skipIdx++) {\n range = ranges[skipIdx];\n if (start >= range.start && start <= range.end) {\n count = 0;\n for (takeIdx = skipIdx; takeIdx < length; takeIdx++) {\n range = ranges[takeIdx];\n flatData = that._flatData(range.data, true);\n if (flatData.length && start + count >= range.start) {\n rangeData = range.data;\n rangeEnd = range.end;\n if (!remote) {\n if (options.inPlaceSort) {\n processed = that._queryProcess(range.data, { filter: that.filter() });\n } else {\n var sort = normalizeGroup(that.group() || []).concat(normalizeSort(that.sort() || []));\n processed = that._queryProcess(range.data, {\n sort: sort,\n filter: that.filter()\n });\n }\n flatData = rangeData = processed.data;\n if (processed.total !== undefined) {\n rangeEnd = processed.total;\n }\n }\n startIndex = 0;\n if (start + count > range.start) {\n startIndex = start + count - range.start;\n }\n endIndex = flatData.length;\n if (rangeEnd > end) {\n endIndex = endIndex - (rangeEnd - end);\n }\n count += endIndex - startIndex;\n data = that._mergeGroups(data, rangeData, startIndex, endIndex);\n if (end <= range.end && count == end - start) {\n return data;\n }\n }\n }\n break;\n }\n }\n return [];\n },\n _mergeGroups: function (data, range, skip, take) {\n if (this._isServerGrouped()) {\n var temp = range.toJSON(), prevGroup;\n if (data.length) {\n prevGroup = data[data.length - 1];\n }\n mergeGroups(prevGroup, temp, skip, take);\n return data.concat(temp);\n }\n return data.concat(range.slice(skip, take));\n },\n _processRangeData: function (data, skip, take, pageSkip, size) {\n var that = this;\n that._pending = undefined;\n that._skip = skip > that.skip() ? math.min(size, (that.totalPages() - 1) * that.take()) : pageSkip;\n that._currentRangeStart = skip;\n that._take = take;\n var paging = that.options.serverPaging;\n var sorting = that.options.serverSorting;\n var filtering = that.options.serverFiltering;\n var aggregates = that.options.serverAggregates;\n try {\n that.options.serverPaging = true;\n if (!that._isServerGrouped() && !(that.group() && that.group().length)) {\n that.options.serverSorting = true;\n }\n that.options.serverFiltering = true;\n that.options.serverPaging = true;\n that.options.serverAggregates = true;\n if (paging) {\n that._detachObservableParents();\n that._data = data = that._observe(data);\n }\n that._process(data);\n } finally {\n that.options.serverPaging = paging;\n that.options.serverSorting = sorting;\n that.options.serverFiltering = filtering;\n that.options.serverAggregates = aggregates;\n }\n },\n skip: function () {\n var that = this;\n if (that._skip === undefined) {\n return that._page !== undefined ? (that._page - 1) * (that.take() || 1) : undefined;\n }\n return that._skip;\n },\n currentRangeStart: function () {\n return this._currentRangeStart || 0;\n },\n take: function () {\n return this._take || this._pageSize;\n },\n _prefetchSuccessHandler: function (skip, size, callback, force) {\n var that = this;\n var timestamp = that._timeStamp();\n return function (data) {\n var found = false, range = {\n start: skip,\n end: size,\n data: [],\n timestamp: that._timeStamp()\n }, idx, length, temp;\n that._dequeueRequest();\n that.trigger(REQUESTEND, {\n response: data,\n type: 'read'\n });\n data = that.reader.parse(data);\n temp = that._readData(data);\n if (temp.length) {\n for (idx = 0, length = that._ranges.length; idx < length; idx++) {\n if (that._ranges[idx].start === skip) {\n found = true;\n range = that._ranges[idx];\n range.pristineData = temp;\n range.data = that._observe(temp);\n range.end = range.start + that._flatData(range.data, true).length;\n that._sortRanges();\n break;\n }\n }\n if (!found) {\n that._addRange(that._observe(temp), skip);\n }\n }\n that._total = that.reader.total(data);\n if (force || (timestamp >= that._currentRequestTimeStamp || !that._skipRequestsInProgress)) {\n if (callback && temp.length) {\n callback();\n } else {\n that.trigger(CHANGE, {});\n }\n }\n };\n },\n prefetch: function (skip, take, callback) {\n var that = this, size = math.min(skip + take, that.total()), options = {\n take: take,\n skip: skip,\n page: skip / take + 1,\n pageSize: take,\n sort: that._sort,\n filter: that._filter,\n group: that._group,\n aggregate: that._aggregate\n };\n if (!that._rangeExists(skip, size)) {\n clearTimeout(that._timeout);\n that._timeout = setTimeout(function () {\n that._queueRequest(options, function () {\n if (!that.trigger(REQUESTSTART, { type: 'read' })) {\n that.transport.read({\n data: that._params(options),\n success: that._prefetchSuccessHandler(skip, size, callback),\n error: function () {\n var args = slice.call(arguments);\n that.error.apply(that, args);\n }\n });\n } else {\n that._dequeueRequest();\n }\n });\n }, 100);\n } else if (callback) {\n callback();\n }\n },\n _multiplePrefetch: function (skip, take, callback) {\n var that = this, size = math.min(skip + take, that.total()), options = {\n take: take,\n skip: skip,\n page: skip / take + 1,\n pageSize: take,\n sort: that._sort,\n filter: that._filter,\n group: that._group,\n aggregate: that._aggregate\n };\n if (!that._rangeExists(skip, size)) {\n if (!that.trigger(REQUESTSTART, { type: 'read' })) {\n that.transport.read({\n data: that._params(options),\n success: that._prefetchSuccessHandler(skip, size, callback, true)\n });\n }\n } else if (callback) {\n callback();\n }\n },\n _rangeExists: function (start, end) {\n var that = this, ranges = that._ranges, idx, length;\n for (idx = 0, length = ranges.length; idx < length; idx++) {\n if (ranges[idx].start <= start && ranges[idx].end >= end) {\n return true;\n }\n }\n return false;\n },\n _getCurrentRangeSpan: function () {\n var that = this;\n var ranges = that._ranges;\n var start = that.currentRangeStart();\n var end = start + (that.take() || 0);\n var rangeSpan = [];\n var range;\n var idx;\n var length = ranges.length;\n for (idx = 0; idx < length; idx++) {\n range = ranges[idx];\n if (range.start <= start && range.end >= start || range.start >= start && range.start <= end) {\n rangeSpan.push(range);\n }\n }\n return rangeSpan;\n },\n _removeModelFromRanges: function (model) {\n var that = this;\n var result, range;\n for (var idx = 0, length = this._ranges.length; idx < length; idx++) {\n range = this._ranges[idx];\n this._eachItem(range.data, function (items) {\n result = removeModel(items, model);\n });\n if (result) {\n break;\n }\n }\n that._updateRangesLength();\n },\n _insertModelInRange: function (index, model) {\n var that = this;\n var ranges = that._ranges || [];\n var rangesLength = ranges.length;\n var range;\n var i;\n for (i = 0; i < rangesLength; i++) {\n range = ranges[i];\n if (range.start <= index && range.end >= index) {\n if (!that._getByUid(model.uid, range.data)) {\n if (that._isServerGrouped()) {\n range.data.splice(index, 0, that._wrapInEmptyGroup(model));\n } else {\n range.data.splice(index, 0, model);\n }\n }\n break;\n }\n }\n that._updateRangesLength();\n },\n _updateRangesLength: function () {\n var that = this;\n var ranges = that._ranges || [];\n var rangesLength = ranges.length;\n var mismatchFound = false;\n var mismatchLength = 0;\n var lengthDifference = 0;\n var range;\n var i;\n for (i = 0; i < rangesLength; i++) {\n range = ranges[i];\n lengthDifference = that._flatData(range.data, true).length - math.abs(range.end - range.start);\n if (!mismatchFound && lengthDifference !== 0) {\n mismatchFound = true;\n mismatchLength = lengthDifference;\n range.end += mismatchLength;\n continue;\n }\n if (mismatchFound) {\n range.start += mismatchLength;\n range.end += mismatchLength;\n }\n }\n }\n });\n var Transport = {};\n Transport.create = function (options, data, dataSource) {\n var transport, transportOptions = options.transport ? $.extend({}, options.transport) : null;\n if (transportOptions) {\n transportOptions.read = typeof transportOptions.read === STRING ? { url: transportOptions.read } : transportOptions.read;\n if (options.type === 'jsdo') {\n transportOptions.dataSource = dataSource;\n }\n if (options.type) {\n kendo.data.transports = kendo.data.transports || {};\n kendo.data.schemas = kendo.data.schemas || {};\n if (!kendo.data.transports[options.type]) {\n kendo.logToConsole('Unknown DataSource transport type \\'' + options.type + '\\'.\\nVerify that registration scripts for this type are included after Kendo UI on the page.', 'warn');\n } else if (!isPlainObject(kendo.data.transports[options.type])) {\n transport = new kendo.data.transports[options.type](extend(transportOptions, { data: data }));\n } else {\n transportOptions = extend(true, {}, kendo.data.transports[options.type], transportOptions);\n }\n options.schema = extend(true, {}, kendo.data.schemas[options.type], options.schema);\n }\n if (!transport) {\n transport = isFunction(transportOptions.read) ? transportOptions : new RemoteTransport(transportOptions);\n }\n } else {\n transport = new LocalTransport({ data: options.data || [] });\n }\n return transport;\n };\n DataSource.create = function (options) {\n if (isArray(options) || options instanceof ObservableArray) {\n options = { data: options };\n }\n var dataSource = options || {}, data = dataSource.data, fields = dataSource.fields, table = dataSource.table, select = dataSource.select, idx, length, model = {}, field;\n if (!data && fields && !dataSource.transport) {\n if (table) {\n data = inferTable(table, fields);\n } else if (select) {\n data = inferSelect(select, fields);\n if (dataSource.group === undefined && data[0] && data[0].optgroup !== undefined) {\n dataSource.group = 'optgroup';\n }\n }\n }\n if (kendo.data.Model && fields && (!dataSource.schema || !dataSource.schema.model)) {\n for (idx = 0, length = fields.length; idx < length; idx++) {\n field = fields[idx];\n if (field.type) {\n model[field.field] = field;\n }\n }\n if (!isEmptyObject(model)) {\n dataSource.schema = extend(true, dataSource.schema, { model: { fields: model } });\n }\n }\n dataSource.data = data;\n select = null;\n dataSource.select = null;\n table = null;\n dataSource.table = null;\n return dataSource instanceof DataSource ? dataSource : new DataSource(dataSource);\n };\n function inferSelect(select, fields) {\n select = $(select)[0];\n var options = select.options;\n var firstField = fields[0];\n var secondField = fields[1];\n var data = [];\n var idx, length;\n var optgroup;\n var option;\n var record;\n var value;\n for (idx = 0, length = options.length; idx < length; idx++) {\n record = {};\n option = options[idx];\n optgroup = option.parentNode;\n if (optgroup === select) {\n optgroup = null;\n }\n if (option.disabled || optgroup && optgroup.disabled) {\n continue;\n }\n if (optgroup) {\n record.optgroup = optgroup.label;\n }\n record[firstField.field] = option.text;\n value = option.attributes.value;\n if (value && value.specified) {\n value = option.value;\n } else {\n value = option.text;\n }\n record[secondField.field] = value;\n data.push(record);\n }\n return data;\n }\n function inferTable(table, fields) {\n var tbody = $(table)[0].tBodies[0], rows = tbody ? tbody.rows : [], idx, length, fieldIndex, fieldCount = fields.length, data = [], cells, record, cell, empty;\n for (idx = 0, length = rows.length; idx < length; idx++) {\n record = {};\n empty = true;\n cells = rows[idx].cells;\n for (fieldIndex = 0; fieldIndex < fieldCount; fieldIndex++) {\n cell = cells[fieldIndex];\n if (cell.nodeName.toLowerCase() !== 'th') {\n empty = false;\n record[fields[fieldIndex].field] = cell.innerHTML;\n }\n }\n if (!empty) {\n data.push(record);\n }\n }\n return data;\n }\n var Node = Model.define({\n idField: 'id',\n init: function (value) {\n var that = this, hasChildren = that.hasChildren || value && value.hasChildren, childrenField = 'items', childrenOptions = {};\n kendo.data.Model.fn.init.call(that, value);\n if (typeof that.children === STRING) {\n childrenField = that.children;\n }\n childrenOptions = {\n schema: {\n data: childrenField,\n model: {\n hasChildren: hasChildren,\n id: that.idField,\n fields: that.fields\n }\n }\n };\n if (typeof that.children !== STRING) {\n extend(childrenOptions, that.children);\n }\n childrenOptions.data = value;\n if (!hasChildren) {\n hasChildren = childrenOptions.schema.data;\n }\n if (typeof hasChildren === STRING) {\n hasChildren = kendo.getter(hasChildren);\n }\n if (isFunction(hasChildren)) {\n var hasChildrenObject = hasChildren.call(that, that);\n if (hasChildrenObject && hasChildrenObject.length === 0) {\n that.hasChildren = false;\n } else {\n that.hasChildren = !!hasChildrenObject;\n }\n }\n that._childrenOptions = childrenOptions;\n if (that.hasChildren) {\n that._initChildren();\n }\n that._loaded = !!(value && value._loaded);\n },\n _initChildren: function () {\n var that = this;\n var children, transport, parameterMap;\n if (!(that.children instanceof HierarchicalDataSource)) {\n children = that.children = new HierarchicalDataSource(that._childrenOptions);\n transport = children.transport;\n parameterMap = transport.parameterMap;\n transport.parameterMap = function (data, type) {\n data[that.idField || 'id'] = that.id;\n if (parameterMap) {\n data = parameterMap(data, type);\n }\n return data;\n };\n children.parent = function () {\n return that;\n };\n children.bind(CHANGE, function (e) {\n e.node = e.node || that;\n that.trigger(CHANGE, e);\n });\n children.bind(ERROR, function (e) {\n var collection = that.parent();\n if (collection) {\n e.node = e.node || that;\n collection.trigger(ERROR, e);\n }\n });\n that._updateChildrenField();\n }\n },\n append: function (model) {\n this._initChildren();\n this.loaded(true);\n this.children.add(model);\n },\n hasChildren: false,\n level: function () {\n var parentNode = this.parentNode(), level = 0;\n while (parentNode && parentNode.parentNode) {\n level++;\n parentNode = parentNode.parentNode ? parentNode.parentNode() : null;\n }\n return level;\n },\n _updateChildrenField: function () {\n var fieldName = this._childrenOptions.schema.data;\n this[fieldName || 'items'] = this.children.data();\n },\n _childrenLoaded: function () {\n this._loaded = true;\n this._updateChildrenField();\n },\n load: function () {\n var options = {};\n var method = '_query';\n var children, promise;\n if (this.hasChildren) {\n this._initChildren();\n children = this.children;\n options[this.idField || 'id'] = this.id;\n if (!this._loaded) {\n children._data = undefined;\n method = 'read';\n }\n children.one(CHANGE, proxy(this._childrenLoaded, this));\n if (this._matchFilter) {\n options.filter = {\n field: '_matchFilter',\n operator: 'eq',\n value: true\n };\n }\n promise = children[method](options);\n } else {\n this.loaded(true);\n }\n return promise || $.Deferred().resolve().promise();\n },\n parentNode: function () {\n var array = this.parent();\n return array.parent();\n },\n loaded: function (value) {\n if (value !== undefined) {\n this._loaded = value;\n } else {\n return this._loaded;\n }\n },\n shouldSerialize: function (field) {\n return Model.fn.shouldSerialize.call(this, field) && field !== 'children' && field !== '_loaded' && field !== 'hasChildren' && field !== '_childrenOptions';\n }\n });\n function dataMethod(name) {\n return function () {\n var data = this._data, result = DataSource.fn[name].apply(this, slice.call(arguments));\n if (this._data != data) {\n this._attachBubbleHandlers();\n }\n return result;\n };\n }\n var HierarchicalDataSource = DataSource.extend({\n init: function (options) {\n var node = Node.define({ children: options });\n if (options.filter && !options.serverFiltering) {\n this._hierarchicalFilter = options.filter;\n options.filter = null;\n }\n DataSource.fn.init.call(this, extend(true, {}, {\n schema: {\n modelBase: node,\n model: node\n }\n }, options));\n this._attachBubbleHandlers();\n },\n _attachBubbleHandlers: function () {\n var that = this;\n that._data.bind(ERROR, function (e) {\n that.trigger(ERROR, e);\n });\n },\n read: function (data) {\n var result = DataSource.fn.read.call(this, data);\n if (this._hierarchicalFilter) {\n if (this._data && this._data.length > 0) {\n this.filter(this._hierarchicalFilter);\n } else {\n this.options.filter = this._hierarchicalFilter;\n this._filter = normalizeFilter(this.options.filter);\n this._hierarchicalFilter = null;\n }\n }\n return result;\n },\n remove: function (node) {\n var parentNode = node.parentNode(), dataSource = this, result;\n if (parentNode && parentNode._initChildren) {\n dataSource = parentNode.children;\n }\n result = DataSource.fn.remove.call(dataSource, node);\n if (parentNode && !dataSource.data().length) {\n parentNode.hasChildren = false;\n }\n return result;\n },\n success: dataMethod('success'),\n data: dataMethod('data'),\n insert: function (index, model) {\n var parentNode = this.parent();\n if (parentNode && parentNode._initChildren) {\n parentNode.hasChildren = true;\n parentNode._initChildren();\n }\n return DataSource.fn.insert.call(this, index, model);\n },\n filter: function (val) {\n if (val === undefined) {\n return this._filter;\n }\n if (!this.options.serverFiltering && this._markHierarchicalQuery(val)) {\n val = {\n logic: 'or',\n filters: [\n val,\n {\n field: '_matchFilter',\n operator: 'equals',\n value: true\n }\n ]\n };\n }\n this.trigger('reset');\n this._query({\n filter: val,\n page: 1\n });\n },\n _markHierarchicalQuery: function (expressions) {\n var compiled;\n var predicate;\n var fields;\n var operators;\n var filter;\n expressions = normalizeFilter(expressions);\n if (!expressions || expressions.filters.length === 0) {\n this._updateHierarchicalFilter(function () {\n return true;\n });\n return false;\n }\n compiled = Query.filterExpr(expressions);\n fields = compiled.fields;\n operators = compiled.operators;\n predicate = filter = new Function('d, __f, __o', 'return ' + compiled.expression);\n if (fields.length || operators.length) {\n filter = function (d) {\n return predicate(d, fields, operators);\n };\n }\n this._updateHierarchicalFilter(filter);\n return true;\n },\n _updateHierarchicalFilter: function (filter) {\n var current;\n var data = this._data;\n var result = false;\n for (var idx = 0; idx < data.length; idx++) {\n current = data[idx];\n if (current.hasChildren) {\n current._matchFilter = current.children._updateHierarchicalFilter(filter);\n if (!current._matchFilter) {\n current._matchFilter = filter(current);\n }\n } else {\n current._matchFilter = filter(current);\n }\n if (current._matchFilter) {\n result = true;\n }\n }\n return result;\n },\n _find: function (method, value) {\n var idx, length, node, children;\n var data = this._data;\n if (!data) {\n return;\n }\n node = DataSource.fn[method].call(this, value);\n if (node) {\n return node;\n }\n data = this._flatData(this._data);\n for (idx = 0, length = data.length; idx < length; idx++) {\n children = data[idx].children;\n if (!(children instanceof HierarchicalDataSource)) {\n continue;\n }\n node = children[method](value);\n if (node) {\n return node;\n }\n }\n },\n get: function (id) {\n return this._find('get', id);\n },\n getByUid: function (uid) {\n return this._find('getByUid', uid);\n }\n });\n function inferList(list, fields) {\n var items = $(list).children(), idx, length, data = [], record, textField = fields[0].field, urlField = fields[1] && fields[1].field, spriteCssClassField = fields[2] && fields[2].field, imageUrlField = fields[3] && fields[3].field, item, id, textChild, className, children;\n function elements(collection, tagName) {\n return collection.filter(tagName).add(collection.find(tagName));\n }\n for (idx = 0, length = items.length; idx < length; idx++) {\n record = { _loaded: true };\n item = items.eq(idx);\n textChild = item[0].firstChild;\n children = item.children();\n list = children.filter('ul');\n children = children.filter(':not(ul)');\n id = item.attr('data-id');\n if (id) {\n record.id = id;\n }\n if (textChild) {\n record[textField] = textChild.nodeType == 3 ? textChild.nodeValue : children.text();\n }\n if (urlField) {\n record[urlField] = elements(children, 'a').attr('href');\n }\n if (imageUrlField) {\n record[imageUrlField] = elements(children, 'img').attr('src');\n }\n if (spriteCssClassField) {\n className = elements(children, '.k-sprite').prop('className');\n record[spriteCssClassField] = className && $.trim(className.replace('k-sprite', ''));\n }\n if (list.length) {\n record.items = inferList(list.eq(0), fields);\n }\n if (item.attr('data-hasChildren') == 'true') {\n record.hasChildren = true;\n }\n data.push(record);\n }\n return data;\n }\n HierarchicalDataSource.create = function (options) {\n options = options && options.push ? { data: options } : options;\n var dataSource = options || {}, data = dataSource.data, fields = dataSource.fields, list = dataSource.list;\n if (data && data._dataSource) {\n return data._dataSource;\n }\n if (!data && fields && !dataSource.transport) {\n if (list) {\n data = inferList(list, fields);\n }\n }\n dataSource.data = data;\n return dataSource instanceof HierarchicalDataSource ? dataSource : new HierarchicalDataSource(dataSource);\n };\n var Buffer = kendo.Observable.extend({\n init: function (dataSource, viewSize, disablePrefetch) {\n kendo.Observable.fn.init.call(this);\n this._prefetching = false;\n this.dataSource = dataSource;\n this.prefetch = !disablePrefetch;\n var buffer = this;\n dataSource.bind('change', function () {\n buffer._change();\n });\n dataSource.bind('reset', function () {\n buffer._reset();\n });\n this._syncWithDataSource();\n this.setViewSize(viewSize);\n },\n setViewSize: function (viewSize) {\n this.viewSize = viewSize;\n this._recalculate();\n },\n at: function (index) {\n var pageSize = this.pageSize, itemPresent = true;\n if (index >= this.total()) {\n this.trigger('endreached', { index: index });\n return null;\n }\n if (!this.useRanges) {\n return this.dataSource.view()[index];\n }\n if (this.useRanges) {\n if (index < this.dataOffset || index >= this.skip + pageSize) {\n itemPresent = this.range(Math.floor(index / pageSize) * pageSize);\n }\n if (index === this.prefetchThreshold) {\n this._prefetch();\n }\n if (index === this.midPageThreshold) {\n this.range(this.nextMidRange, true);\n } else if (index === this.nextPageThreshold) {\n this.range(this.nextFullRange);\n } else if (index === this.pullBackThreshold) {\n if (this.offset === this.skip) {\n this.range(this.previousMidRange);\n } else {\n this.range(this.previousFullRange);\n }\n }\n if (itemPresent) {\n return this.dataSource.at(index - this.dataOffset);\n } else {\n this.trigger('endreached', { index: index });\n return null;\n }\n }\n },\n indexOf: function (item) {\n return this.dataSource.data().indexOf(item) + this.dataOffset;\n },\n total: function () {\n return parseInt(this.dataSource.total(), 10);\n },\n next: function () {\n var buffer = this, pageSize = buffer.pageSize, offset = buffer.skip - buffer.viewSize + pageSize, pageSkip = math.max(math.floor(offset / pageSize), 0) * pageSize;\n this.offset = offset;\n this.dataSource.prefetch(pageSkip, pageSize, function () {\n buffer._goToRange(offset, true);\n });\n },\n range: function (offset, nextRange) {\n if (this.offset === offset) {\n return true;\n }\n var buffer = this, pageSize = this.pageSize, pageSkip = math.max(math.floor(offset / pageSize), 0) * pageSize, dataSource = this.dataSource;\n if (nextRange) {\n pageSkip += pageSize;\n }\n if (dataSource.inRange(offset, pageSize)) {\n this.offset = offset;\n this._recalculate();\n this._goToRange(offset);\n return true;\n } else if (this.prefetch) {\n dataSource.prefetch(pageSkip, pageSize, function () {\n buffer.offset = offset;\n buffer._recalculate();\n buffer._goToRange(offset, true);\n });\n return false;\n }\n return true;\n },\n syncDataSource: function () {\n var offset = this.offset;\n this.offset = null;\n this.range(offset);\n },\n destroy: function () {\n this.unbind();\n },\n _prefetch: function () {\n var buffer = this, pageSize = this.pageSize, prefetchOffset = this.skip + pageSize, dataSource = this.dataSource;\n if (!dataSource.inRange(prefetchOffset, pageSize) && !this._prefetching && this.prefetch) {\n this._prefetching = true;\n this.trigger('prefetching', {\n skip: prefetchOffset,\n take: pageSize\n });\n dataSource.prefetch(prefetchOffset, pageSize, function () {\n buffer._prefetching = false;\n buffer.trigger('prefetched', {\n skip: prefetchOffset,\n take: pageSize\n });\n });\n }\n },\n _goToRange: function (offset, expanding) {\n if (this.offset !== offset) {\n return;\n }\n this.dataOffset = offset;\n this._expanding = expanding;\n this.dataSource.range(offset, this.pageSize);\n this.dataSource.enableRequestsInProgress();\n },\n _reset: function () {\n this._syncPending = true;\n },\n _change: function () {\n var dataSource = this.dataSource;\n this.length = this.useRanges ? dataSource.lastRange().end : dataSource.view().length;\n if (this._syncPending) {\n this._syncWithDataSource();\n this._recalculate();\n this._syncPending = false;\n this.trigger('reset', { offset: this.offset });\n }\n this.trigger('resize');\n if (this._expanding) {\n this.trigger('expand');\n }\n delete this._expanding;\n },\n _syncWithDataSource: function () {\n var dataSource = this.dataSource;\n this._firstItemUid = dataSource.firstItemUid();\n this.dataOffset = this.offset = dataSource.skip() || 0;\n this.pageSize = dataSource.pageSize();\n this.useRanges = dataSource.options.serverPaging;\n },\n _recalculate: function () {\n var pageSize = this.pageSize, offset = this.offset, viewSize = this.viewSize, skip = Math.ceil(offset / pageSize) * pageSize;\n this.skip = skip;\n this.midPageThreshold = skip + pageSize - 1;\n this.nextPageThreshold = skip + viewSize - 1;\n this.prefetchThreshold = skip + Math.floor(pageSize / 3 * 2);\n this.pullBackThreshold = this.offset - 1;\n this.nextMidRange = skip + pageSize - viewSize;\n this.nextFullRange = skip;\n this.previousMidRange = offset - viewSize;\n this.previousFullRange = skip - pageSize;\n }\n });\n var BatchBuffer = kendo.Observable.extend({\n init: function (dataSource, batchSize) {\n var batchBuffer = this;\n kendo.Observable.fn.init.call(batchBuffer);\n this.dataSource = dataSource;\n this.batchSize = batchSize;\n this._total = 0;\n this.buffer = new Buffer(dataSource, batchSize * 3);\n this.buffer.bind({\n 'endreached': function (e) {\n batchBuffer.trigger('endreached', { index: e.index });\n },\n 'prefetching': function (e) {\n batchBuffer.trigger('prefetching', {\n skip: e.skip,\n take: e.take\n });\n },\n 'prefetched': function (e) {\n batchBuffer.trigger('prefetched', {\n skip: e.skip,\n take: e.take\n });\n },\n 'reset': function () {\n batchBuffer._total = 0;\n batchBuffer.trigger('reset');\n },\n 'resize': function () {\n batchBuffer._total = Math.ceil(this.length / batchBuffer.batchSize);\n batchBuffer.trigger('resize', {\n total: batchBuffer.total(),\n offset: this.offset\n });\n }\n });\n },\n syncDataSource: function () {\n this.buffer.syncDataSource();\n },\n at: function (index) {\n var buffer = this.buffer, skip = index * this.batchSize, take = this.batchSize, view = [], item;\n if (buffer.offset > skip) {\n buffer.at(buffer.offset - 1);\n }\n for (var i = 0; i < take; i++) {\n item = buffer.at(skip + i);\n if (item === null) {\n break;\n }\n view.push(item);\n }\n return view;\n },\n total: function () {\n return this._total;\n },\n destroy: function () {\n this.buffer.destroy();\n this.unbind();\n }\n });\n extend(true, kendo.data, {\n readers: { json: DataReader },\n Query: Query,\n DataSource: DataSource,\n HierarchicalDataSource: HierarchicalDataSource,\n Node: Node,\n ObservableObject: ObservableObject,\n ObservableArray: ObservableArray,\n LazyObservableArray: LazyObservableArray,\n LocalTransport: LocalTransport,\n RemoteTransport: RemoteTransport,\n Cache: Cache,\n DataReader: DataReader,\n Model: Model,\n Buffer: Buffer,\n BatchBuffer: BatchBuffer\n });\n }(window.kendo.jQuery));\n return window.kendo;\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));"]}