/*
* Kendo UI Beta v2013.2.716 (http://kendoui.com)
* Copyright 2013 Telerik AD. All rights reserved.
*
* Kendo UI Beta license terms available at
* http://www.kendoui.com/purchase/license-agreement/kendo-ui-beta.aspx
*/
("function"==typeof define&&define.amd?define:function(e,t){return t()})(["./kendo.data.min","./kendo.editable.min","./kendo.window.min","./kendo.filtermenu.min","./kendo.columnmenu.min","./kendo.groupable.min","./kendo.pager.min","./kendo.selectable.min","./kendo.sortable.min","./kendo.reorderable.min","./kendo.resizable.min"],function(){!function(e,t){function r(e){return Array(e+1).join('
| ')}function a(e){var t,r=" ";if(e){if(typeof e===gt)return e;for(t in e)r+=t+'="'+e[t]+'"'}return r}function l(t){var r=0;return e("> .k-grouping-header, > .k-grid-toolbar",t).each(function(){r+=this.offsetHeight}),r}function o(t,r){e("th, th .k-grid-filter, th .k-link",t).add(document.body).css("cursor",r)}function n(e){var t,r,a={},l={};if(!z(e))for(I(e)||(e=[e]),t=0,r=e.length;r>t;t++)a[e[t].aggregate]=0,l[e[t].field]=a;return l}function i(e,t,r){var a=e.eq(t),l=e.eq(r);a[t>r?"insertBefore":"insertAfter"](l)}function s(e,t,r){var a,l,o,n;for(r=I(r)?r:[r],a=0,l=r.length;l>a;a++)o=r[a],H(o)&&o.click&&(n=o.name||o.text,t.on(ut+K,"a.k-grid-"+(n||"").replace(/\s/g,""),{commandName:n},W(o.click,e)))}function d(e){return D(e,function(e){return!e.hidden})}function c(e){e=e||{};var t=e.style;return t?(t=t.replace(/((.*)?display)(.*)?:([^;]*)/i,"$1:none"),t===e.style&&(t=t.replace(/(.*)?/i,"display:none;$1"))):t="display:none",R({},e,{style:t})}function u(e){e=e||{};var t=e.style;return t&&(e.style=t.replace(/(display\s*:\s*none\s*;?)*/gi,"")),e}function p(t,r,a,l){var o,n=t.find(">colgroup"),i=A(r,function(e){return o=e.width,o&&0!==parseInt(o,10)?v.format('',typeof o===gt?o:o+"px"):""});(a||n.find(".k-hierarchy-col").length)&&i.splice(0,0,''),n.length&&n.remove(),n=e(Array(l+1).join('')+i.join("")),n.is("colgroup")||(n=e("").append(n)),t.prepend(n),Ct.msie&&8==Ct.version&&(t.css("display","inline-table"),window.setTimeout(function(){t.css("display","")},1))}function f(e){var t,r,a,l={};for(r=0,a=e.length;a>r;r++)t=e[r],l[t.value]=t.text;return l}function h(e,t,r){var a=r&&r.length&&H(r[0])&&"value"in r[0],l=a?f(r)[e]:e;return l=null!=l?l:"",t?v.format(t,l):l}function g(e,t,r){for(var a,l=0,o=e[l];o;){if(a=r?!0:"none"!==o.style.display,a&&!_t.test(o.className)&&--t<0){o.style.display=r?"":"none";break}o=e[++l]}}function m(e,t){var r,a,l;if(typeof e===gt&&e===t)return e;if(H(e)&&e.name===t)return e;if(I(e))for(r=0,a=e.length;a>r;r++)if(l=e[r],typeof l===gt&&l===t||l.name===t)return l;return null}function b(t,r){var a,l,o,n=Ct.msie;if(r===!0){if(t=e(t),o=n&&t.parent().is(".k-grid-content,.k-grid-header-wrap"),o&&(a=t.parent().scrollTop(),l=t.parent().scrollLeft()),n)try{t[0].setActive()}catch(i){t[0].focus()}else t[0].focus();o&&(t.parent().scrollTop(a),t.parent().scrollLeft(l))}else e(t).one("focusin",function(e){e.preventDefault()}).focus()}function k(t){var r=e(t.currentTarget),a=r.is("th"),l=r.closest("table")[0];v.support.touch||(l===this.table[0]||l===this.thead.parent()[0])&&(this.current(r),(a||!e(t.target).is(":button,a,:input,a>.k-icon,textarea,span.k-icon,.k-input,.k-multiselect-wrap"))&&setTimeout(function(){b(l,!0)}),a&&t.preventDefault())}var v=window.kendo,_=v.ui,w=v.data.DataSource,y=_.Groupable,C=v.support.tbodyInnerHtml,x=v._activeElement,T=_.Widget,S=v.keys,H=e.isPlainObject,R=e.extend,A=e.map,D=e.grep,I=e.isArray,E=e.inArray,W=e.proxy,M=e.isFunction,z=e.isEmptyObject,N=Math,L="progress",B="error",F=":not(.k-group-cell):not(.k-hierarchy-cell):visible",q="tbody>tr:not(.k-grouping-row):not(.k-detail-row):not(.k-group-footer) > td:not(.k-group-cell):not(.k-hierarchy-cell)",P="tr:not(.k-footer-template):visible",O=":not(.k-group-cell):not(.k-hierarchy-cell):visible",G=P+":first>"+O+":first",j="th.k-header:not(.k-group-cell,.k-hierarchy-cell)",U=j+":visible["+v.attr("field")+"]",$=j+"["+v.attr("field")+"]",K=".kendoGrid",J="edit",V="save",X="remove",Q="detailInit",Y="filterMenuInit",Z="columnMenuInit",et="change",tt="columnHide",rt="columnShow",at="saveChanges",lt="dataBound",ot="detailExpand",nt="detailCollapse",it="k-state-focused",st="k-state-selected",dt="columnResize",ct="columnReorder",ut="click",pt="height",ft="tabIndex",ht="function",gt="string",mt="Are you sure you want to delete this record?",bt=/(\}|\#)/gi,kt=/#/gi,vt="[\\x20\\t\\r\\n\\f]",_t=RegExp("(^|"+vt+")"+"(k-group-cell|k-hierarchy-cell)"+"("+vt+"|$)"),wt='#=text#',yt=!1,Ct=v.support.browser,xt=Ct.msie&&7==Ct.version,Tt=T.extend({init:function(e,t){var r=this;T.fn.init.call(r,e,t),r._refreshHandler=W(r.refresh,r),r.setDataSource(t.dataSource),r.wrap()},setDataSource:function(e){var t=this;t.dataSource&&t.dataSource.unbind(et,t._refreshHandler),t.dataSource=e,t.dataSource.bind(et,t._refreshHandler)},options:{name:"VirtualScrollable",itemHeight:e.noop},destroy:function(){var e=this;T.fn.destroy.call(e),e.dataSource.unbind(et,e._refreshHandler),e.wrapper.add(e.verticalScrollbar).off(K),e.drag&&e.drag.destroy()},wrap:function(){var t,r=this,a=v.support.scrollbar()+1,l=r.element;l.css({width:"auto",overflow:"hidden"}).css(yt?"padding-left":"padding-right",a),r.content=l.children().first(),t=r.wrapper=r.content.wrap('').parent().bind("DOMMouseScroll"+K+" mousewheel"+K,W(r._wheelScroll,r)),v.support.kineticScrollNeeded&&(r.drag=new v.UserEvents(r.wrapper,{global:!0,move:function(e){r.verticalScrollbar.scrollTop(r.verticalScrollbar.scrollTop()-e.y.delta),t.scrollLeft(t.scrollLeft()-e.x.delta),e.preventDefault()}})),r.verticalScrollbar=e('').css({width:a}).appendTo(l).bind("scroll"+K,W(r._scroll,r))},_wheelScroll:function(e){var r,a=this,l=a.verticalScrollbar.scrollTop(),o=e.originalEvent,n=o.wheelDeltaY;o.wheelDelta?(n===t||n)&&(r=o.wheelDelta):o.detail&&o.axis===o.VERTICAL_AXIS&&(r=10*-o.detail),r&&(e.preventDefault(),a.verticalScrollbar.scrollTop(l+-r))},_scroll:function(e){var t=this,r=e.currentTarget.scrollTop,a=t.dataSource,l=t.itemHeight,o=a.skip()||0,n=t._rangeStart||o,i=t.element.innerHeight(),s=!!(t._scrollbarTop&&t._scrollbarTop>r),d=N.max(N.floor(r/l),0),c=N.max(d+N.floor(i/l),0);t._scrollTop=r-n*l,t._scrollbarTop=r,t._fetch(d,c,s)||(t.wrapper[0].scrollTop=t._scrollTop)},_fetch:function(e,t,r){var a=this,l=a.dataSource,o=a.itemHeight,n=l.take(),i=a._rangeStart||l.skip()||0,s=N.floor(e/n)*n,d=!1,c=.33;return i>e?(d=!0,i=N.max(0,t-n),a._scrollTop=(e-i)*o,a._page(i,n)):t>=i+n&&!r?(d=!0,i=e,a._scrollTop=o,a._page(i,n)):a._fetching||(s+n-n*c>e&&e>n&&l.prefetch(s-n,n),t>s+n*c&&l.prefetch(s+n,n)),d},_page:function(e,t){var r=this,a=r.dataSource;clearTimeout(r._timeout),r._fetching=!0,r._rangeStart=e,a.inRange(e,t)?a.range(e,t):(v.ui.progress(r.wrapper.parent(),!0),r._timeout=setTimeout(function(){a.range(e,t)},100))},refresh:function(){var e,t,r,a,l=this,o="",n=25e4,i=l.dataSource,s=l._rangeStart,d=v.support.kineticScrollNeeded?0:v.support.scrollbar(),c=l.wrapper[0];for(v.ui.progress(l.wrapper.parent(),!1),clearTimeout(l._timeout),r=l.itemHeight=l.options.itemHeight()||0,a=c.scrollWidth>c.offsetWidth?d:0,e=i.total()*r+a,t=0;t';e%n&&(o+=''),l.verticalScrollbar.html(o),c.scrollTop=l._scrollTop,l.drag&&l.drag.cancel(),s&&!l._fetching&&(l._rangeStart=i.skip()),l._fetching=!1}}),St={create:{text:"Add new record",imageClass:"k-add",className:"k-grid-add",iconClass:"k-icon"},cancel:{text:"Cancel changes",imageClass:"k-cancel",className:"k-grid-cancel-changes",iconClass:"k-icon"},save:{text:"Save changes",imageClass:"k-update",className:"k-grid-save-changes",iconClass:"k-icon"},destroy:{text:"Delete",imageClass:"k-delete",className:"k-grid-delete",iconClass:"k-icon"},edit:{text:"Edit",imageClass:"k-edit",className:"k-grid-edit",iconClass:"k-icon"},update:{text:"Update",imageClass:"k-update",className:"k-grid-update",iconClass:"k-icon"},canceledit:{text:"Cancel",imageClass:"k-cancel",className:"k-grid-cancel",iconClass:"k-icon"}},Ht=T.extend({init:function(e,t){var r=this;t=I(t)?{dataSource:t}:t,T.fn.init.call(r,e,t),yt=v.support.isRtl(e),r._element(),r._aria(),r._columns(r.options.columns),r._dataSource(),r._tbody(),r._pageable(),r._thead(),r._groupable(),r._toolbar(),r._setContentHeight(),r._templates(),r._navigatable(),r._selectable(),r._details(),r._editable(),r._attachCustomCommandsEvent(),r.options.autoBind?r.dataSource.fetch():r._footer(),v.notify(r)},events:[et,"dataBinding","cancel",lt,ot,nt,Q,Y,Z,J,V,X,at,dt,ct,rt,tt],setDataSource:function(e){var t=this;t.options.dataSource=e,t._dataSource(),t._pageable(),t.options.groupable&&t._groupable(),t._thead(),t.virtualScrollable&&t.virtualScrollable.setDataSource(t.options.dataSource),t.options.autoBind&&e.fetch()},options:{name:"Grid",columns:[],toolbar:null,autoBind:!0,filterable:!1,scrollable:!0,sortable:!1,selectable:!1,navigatable:!1,pageable:!1,editable:!1,groupable:!1,rowTemplate:"",altRowTemplate:"",dataSource:{},height:null,resizable:!1,reorderable:!1,columnMenu:!1,detailTemplate:null,columnResizeHandleWidth:3},destroy:function(){var e,t=this;T.fn.destroy.call(t),t.pager&&t.pager.destroy(),t.groupable&&t.groupable.destroy(),t.options.reorderable&&t.wrapper.data("kendoReorderable").destroy(),t.resizable&&t.resizable.destroy(),t.virtualScrollable&&t.virtualScrollable.destroy(),t._destroyColumnAttachments(),t._destroyEditable(),t.dataSource.unbind(et,t._refreshHandler).unbind(L,t._progressHandler).unbind(B,t._errorHandler),e=t.element.add(t.wrapper).add(t.table).add(t.thead).add(t.wrapper.find(">.k-grid-toolbar")),t.content&&(e=e.add(t.content).add(t.content.find(">.k-virtual-scrollable-wrap"))),e.off(K),v.destroy(t.wrapper)},setOptions:function(e){var t=this;T.fn.setOptions.call(this,e),t._templates()},items:function(){return this.tbody.children(":not(.k-grouping-row,.k-detail-row,.k-group-footer)")},_destroyColumnAttachments:function(){var t=this;t.resizeHandle=null,t.thead.find("th").each(function(){var t=e(this),r=t.data("kendoFilterMenu"),a=t.data("kendoSortable"),l=t.data("kendoColumnMenu");r&&r.destroy(),a&&a.destroy(),l&&l.destroy()})},_attachCustomCommandsEvent:function(){var e,t,r,a=this,l=a.columns||[];for(t=0,r=l.length;r>t;t++)e=l[t].command,e&&s(a,a.wrapper,e)},_aria:function(){var e=this.element.attr("id")||"aria";e&&(this._cellId=e+"_active_cell")},_element:function(){var t=this,r=t.element;r.is("table")||(r=t.options.scrollable?t.element.find("> .k-grid-content > table"):t.element.children("table"),r.length||(r=e("").appendTo(t.element))),xt&&r.attr("cellspacing",0),t.table=r.attr("role",t._hasDetails()?"treegrid":"grid"),t._wrapper()},_positionColumnResizeHandle:function(t){var r,a=this,n=a.options.scrollable,i=a.resizeHandle,s=a.options.columnResizeHandleWidth;a.thead.on("mousemove"+K,"th:not(.k-group-cell,.k-hierarchy-cell)",function(d){var c,u,p,f,h=e(this),g=d.clientX,m=e(window).scrollLeft(),b=h.offset().left+(yt?0:this.offsetWidth);g+m>b-s&&b+s>g+m?(i||(i=a.resizeHandle=e(''),t.append(i)),yt?(c=h.closest(".k-grid-header-wrap"),u=Ct.msie?c.scrollLeft():0,p=Ct.webkit?c[0].scrollWidth-c[0].offsetWidth-c.scrollLeft():0,f=Ct.mozilla?c[0].scrollWidth-c[0].offsetWidth-(c[0].scrollWidth-c[0].offsetWidth-c.scrollLeft()):0,r=h.position().left-p+f-u):(r=this.offsetWidth,h.prevAll(":visible").each(function(){r+=this.offsetWidth})),i.css({top:n?0:l(a.wrapper),left:r-s,height:h.outerHeight(),width:3*s}).data("th",h).show()):i?i.hide():o(a.wrapper,"")})},_resizable:function(){var t,r,a,l,n,i,s=this,d=s.options;d.resizable&&(t=d.scrollable?s.wrapper.find(".k-grid-header-wrap:first"):s.wrapper,s._positionColumnResizeHandle(t),s.resizable=new _.Resizable(t,{handle:".k-resize-handle",hint:function(t){return e('').css({height:t.data("th").outerHeight()+s.tbody.attr("clientHeight")})},start:function(t){i=e(t.currentTarget).data("th");var c=e.inArray(i[0],i.parent().children(":visible")),u=s.tbody.parent(),p=s.footer||e();o(s.wrapper,"col-resize"),n=d.scrollable?s.thead.parent().find("col:eq("+c+")").add(u.children("colgroup").find("col:eq("+c+")")).add(p.find("colgroup").find("col:eq("+c+")")):u.children("colgroup").find("col:eq("+c+")"),r=t.x.location,a=i.outerWidth(),l=s.tbody.outerWidth()},resize:function(t){var o=yt?-1:1,i=a+t.x.location*o-r*o,c=s.footer||e();i>10&&(n.css("width",i),d.scrollable&&l&&(s._footerWidth=l+t.x.location*o-r*o,s.tbody.parent().add(s.thead.parent()).add(c.find("table")).css("width",s._footerWidth)))},resizeend:function(){var e,t=i.outerWidth();o(s.wrapper,""),a!=t&&(e=s.columns[i.parent().find("th:not(.k-group-cell,.k-hierarchy-cell)").index(i)],e.width=t,s.trigger(dt,{column:e,oldWidth:a,newWidth:t})),s.resizeHandle.hide(),i=null}}))},_draggable:function(){var t=this;t.options.reorderable&&(t._draggableInstance&&t._draggableInstance.destroy(),t._draggableInstance=t.wrapper.kendoDraggable({group:v.guid(),filter:t.content?".k-grid-header:first "+j:"table:first>.k-grid-header "+j,hint:function(t){return e('').css({width:t.width(),paddingLeft:t.css("paddingLeft"),paddingRight:t.css("paddingRight"),lineHeight:t.height()+"px",paddingTop:t.css("paddingTop"),paddingBottom:t.css("paddingBottom")}).html(t.attr(v.attr("title"))||t.attr(v.attr("field"))||t.text()).prepend('')}}).data("kendoDraggable"))},_reorderable:function(){var e=this;e.options.reorderable&&e.wrapper.kendoReorderable({draggable:e._draggableInstance,change:function(t){var r=E(e.columns[t.newIndex],e.columns),a=e.columns[t.oldIndex];e.trigger(ct,{newIndex:r,oldIndex:E(a,e.columns),column:a}),e.reorderColumn(r,a)}})},reorderColumn:function(e,t){var r,a,l,o=this,n=E(t,o.columns),s=E(t,d(o.columns)),c=E(o.columns[e],d(o.columns)),u=o.footer||o.wrapper.find(".k-grid-footer");if(n!==e)for(o.columns.splice(n,1),o.columns.splice(e,0,t),o._templates(),i(o.thead.prev().find("col:not(.k-group-col,.k-hierarchy-col)"),s,c),o.options.scrollable&&i(o.tbody.prev().find("col:not(.k-group-col,.k-hierarchy-col)"),s,c),i(o.thead.find(".k-header:not(.k-group-cell,.k-hierarchy-cell)"),n,e),u&&u.length&&(i(u.find(".k-grid-footer-wrap>table>colgroup>col:not(.k-group-col,.k-hierarchy-col)"),s,c),i(u.find(".k-footer-template>td:not(.k-group-cell,.k-hierarchy-cell)"),n,e)),r=o.tbody.children(":not(.k-grouping-row,.k-detail-row)"),a=0,l=r.length;l>a;a+=1)i(r.eq(a).find(">td:not(.k-group-cell,.k-hierarchy-cell)"),n,e)},cellIndex:function(t){return e(t).parent().children("td:not(.k-group-cell,.k-hierarchy-cell)").index(t)},_modelForContainer:function(t){t=e(t),t.is("tr")||"popup"===this._editMode()||(t=t.closest("tr"));var r=t.attr(v.attr("uid"));return this.dataSource.getByUid(r)},_editable:function(){var t,r=this,a=r.selectable&&r.selectable.options.multiple,l=r.options.editable,o=function(){var t=x(),a=r._editContainer;!a||e.contains(a[0],t)||a[0]===t||e(t).closest(".k-animation-container").length||r.editable.end()&&r.closeCell()};l&&(t=r._editMode(),"incell"===t?l.update!==!1&&r.wrapper.on(ut+K,"tr:not(.k-grouping-row) > td",function(t){var l=e(this);l.hasClass("k-hierarchy-cell")||l.hasClass("k-detail-cell")||l.hasClass("k-group-cell")||l.hasClass("k-edit-cell")||l.has("a.k-grid-delete").length||l.has("button.k-grid-delete").length||l.closest("tbody")[0]!==r.tbody[0]||e(t.target).is(":input")||(r.editable?r.editable.end()&&(a&&e(x()).blur(),r.closeCell(),r.editCell(l)):r.editCell(l))}).on("focusin"+K,function(){clearTimeout(r.timer),r.timer=null}).on("focusout"+K,function(){r.timer=setTimeout(o,1)}):l.update!==!1&&r.wrapper.on(ut+K,"tbody>tr:not(.k-detail-row,.k-grouping-row):visible a.k-grid-edit",function(t){t.preventDefault(),r.editRow(e(this).closest("tr"))}),l.destroy!==!1?r.wrapper.on(ut+K,"tbody>tr:not(.k-detail-row,.k-grouping-row):visible .k-grid-delete",function(t){t.preventDefault(),t.stopPropagation(),r.removeRow(e(this).closest("tr"))}):r.wrapper.on(ut+K,"tbody>tr:not(.k-detail-row,.k-grouping-row):visible button.k-grid-delete",function(e){r._confirmation()||e.preventDefault()}))},editCell:function(t){t=e(t);var r=this,a=r.columns[r.cellIndex(t)],l=r._modelForContainer(t);!l||l.editable&&!l.editable(a.field)||a.command||!a.field||(r._attachModelChange(l),r._editContainer=t,r.editable=t.addClass("k-edit-cell").kendoEditable({fields:{field:a.field,format:a.format,editor:a.editor,values:a.values},model:l,change:function(e){r.trigger(V,{values:e.values,container:t,model:l})&&e.preventDefault()}}).data("kendoEditable"),t.parent().addClass("k-grid-edit-row"),r.trigger(J,{container:t,model:l}))},_destroyEditable:function(){var e=this,t=function(){e.editable&&(e._detachModelChange(),e.editable.destroy(),e.editable=null,e._editContainer=null)};e.editable&&("popup"===e._editMode()?e._editContainer.data("kendoWindow").bind("deactivate",t).close():t())},_attachModelChange:function(e){var t=this;t._modelChangeHandler=function(e){t._modelChange({field:e.field,model:this})},e.bind("change",t._modelChangeHandler)},_detachModelChange:function(){var e=this,t=e._editContainer,r=e._modelForContainer(t);r&&r.unbind(et,e._modelChangeHandler)},closeCell:function(t){var r,a,l,o=this,n=o._editContainer;n&&(r=n.closest("tr").attr(v.attr("uid")),l=o.dataSource.getByUid(r),t&&o.trigger("cancel",{container:n,model:l})||(n.removeClass("k-edit-cell"),a=o.columns[o.cellIndex(n)],n.parent().removeClass("k-grid-edit-row"),o._destroyEditable(),o._displayCell(n,a,l),n.hasClass("k-dirty-cell")&&e('').prependTo(n)))},_displayCell:function(e,t,r){var a=this,l={storage:{},count:0},o=R({},v.Template,a.options.templateSettings),n=v.template(a._cellTmpl(t,l),o);l.count>0&&(n=W(n,l.storage)),e.empty().html(n(r))},removeRow:function(t){var r,a,l=this;l._confirmation()&&(t=e(t).hide(),r=l._modelForContainer(t),r&&!l.trigger(X,{row:t,model:r})&&(a=l._editMode(),"incell"!==a&&l.cancelRow(),l.dataSource.remove(r),("inline"===a||"popup"===a)&&l.dataSource.sync()))},_editMode:function(){var e="incell",t=this.options.editable;return t!==!0&&(e="string"==typeof t?t:t.mode||e),e},editRow:function(r){r=e(r);var a,l=this,o=l._modelForContainer(r),n=l._editMode(),i=l.options.navigatable;l.cancelRow(),o&&(l._attachModelChange(o),"popup"===n?l._createPopupEditor(o):"inline"===n?l._createInlineEditor(r,o):"incell"===n&&e(r).children(F).each(function(){var r=e(this),a=l.columns[r.index()];return o=l._modelForContainer(r),o&&(!o.editable||o.editable(a.field))&&a.field?(l.editCell(r),!1):t}),a=l._editContainer,a.on(ut+K,"a.k-grid-cancel",function(t){if(t.preventDefault(),t.stopPropagation(),!l.trigger("cancel",{container:a,model:o})){var r=l.items().index(e(l.current()).parent());l.cancelRow(),i&&(l.current(l.items().eq(r).children().filter(O).first()),b(l.table,!0))}}),a.on(ut+K,"a.k-grid-update",function(e){e.preventDefault(),e.stopPropagation(),l.saveRow()}))},_createPopupEditor:function(r){var a,l,o,n,i,s,d,c,u,p,f,h=this,g="",f=h._editContainer=e(g).appendTo(h.wrapper).eq(0).kendoWindow(R({modal:!0,resizable:!1,draggable:!0,title:"Edit",visible:!1,close:function(a){if(a.userTriggered){if(h.trigger("cancel",{container:f,model:r}))return a.preventDefault(),t;var l=h.items().index(e(h.current()).parent());h.cancelRow(),h.options.navigatable&&(h.current(h.items().eq(l).children().filter(O).first()),b(h.table,!0))}}},y)),h.editable=h._editContainer.kendoEditable({fields:k,model:r,clearContainer:!1}).data("kendoEditable"),f.data("kendoWindow").center().open(),h.trigger(J,{container:f,model:r})},_createInlineEditor:function(t,r){var a,l,o,n=this,i=[];t.children(":not(.k-group-cell,.k-hierarchy-cell)").each(function(){if(l=e(this),a=n.columns[n.cellIndex(l)],a.command||!a.field||r.editable&&!r.editable(a.field)){if(a.command&&(o=m(a.command,"edit"))){l.empty();var t,s,d;H(o)&&(o.text&&H(o.text)&&(t=o.text.update,s=o.text.cancel),o.attr&&(d=o.attr)),e(n._createButton({name:"update",text:t,attr:d})+n._createButton({name:"canceledit",text:s,attr:d})).appendTo(l)}}else i.push({field:a.field,format:a.format,editor:a.editor,values:a.values}),l.attr(v.attr("container-for"),a.field),l.empty()}),n._editContainer=t,n.editable=t.addClass("k-grid-edit-row").kendoEditable({fields:i,model:r,clearContainer:!1}).data("kendoEditable"),n.trigger(J,{container:t,model:r})},cancelRow:function(){var e,t=this,r=t._editContainer;r&&(e=t._modelForContainer(r),t.dataSource.cancelChanges(e),"popup"!==t._editMode()?t._displayRow(r):t._displayRow(t.items().filter("["+v.attr("uid")+"="+e.uid+"]")),t._destroyEditable())},saveRow:function(){var e=this,t=e._editContainer,r=e._modelForContainer(t),a=e.editable;t&&a&&a.end()&&!e.trigger(V,{container:t,model:r})&&e.dataSource.sync()},_displayRow:function(t){var r=this,a=r._modelForContainer(t);a&&t.replaceWith(e((t.hasClass("k-alt")?r.altRowTemplate:r.rowTemplate)(a)))},_showMessage:function(e){return window.confirm(e)},_confirmation:function(){var e=this,t=e.options.editable,r=t===!0||typeof t===gt?mt:t.confirmation;return r!==!1&&null!=r?e._showMessage(r):!0},cancelChanges:function(){this.dataSource.cancelChanges()},saveChanges:function(){var e=this;(e.editable&&e.editable.end()||!e.editable)&&!e.trigger(at)&&e.dataSource.sync()},addRow:function(){var e,t,r,a,l,o=this,n=o.dataSource,i=o._editMode(),s=o.options.editable.createAt||"",d=n.pageSize(),c=n.view()||[];(o.editable&&o.editable.end()||!o.editable)&&("incell"!=i&&o.cancelRow(),e=n.indexOf(c[0]),"bottom"==s.toLowerCase()&&(e+=c.length,d&&!n.options.serverPaging&&d<=c.length&&(e-=1)),0>e&&(e=n.page()>n.totalPages()?(n.page()-1)*d:0),t=n.insert(e,{}),r=t.uid,a=o.table.find("tr["+v.attr("uid")+"="+r+"]"),l=a.children("td:not(.k-group-cell,.k-hierarchy-cell)").eq(o._firstEditableColumnIndex(a)),"inline"!==i&&"popup"!==i||!a.length?l.length&&o.editCell(l):o.editRow(a))},_firstEditableColumnIndex:function(e){var t,r,a,l=this,o=l.columns,n=l._modelForContainer(e);for(r=0,a=o.length;a>r;r++)if(t=o[r],n&&(!n.editable||n.editable(t.field))&&!t.command&&t.field)return r;return-1},_toolbar:function(){var t,r=this,a=r.wrapper,l=r.options.toolbar,o=r.options.editable;l&&(t=r.wrapper.find(".k-grid-toolbar"),t.length||(M(l)||(l=typeof l===gt?l:r._toolbarTmpl(l).replace(kt,"\\#"),l=W(v.template(l),r)),t=e('').html(l({})).prependTo(a)),o&&o.create!==!1&&t.on(ut+K,".k-grid-add",function(e){e.preventDefault(),r.addRow()}).on(ut+K,".k-grid-cancel-changes",function(e){e.preventDefault(),r.cancelChanges()}).on(ut+K,".k-grid-save-changes",function(e){e.preventDefault(),r.saveChanges()}))},_toolbarTmpl:function(e){var t,r,a=this,l="";if(I(e))for(t=0,r=e.length;r>t;t++)l+=a._createButton(e[t]);return l},_createButton:function(e){var t=e.template||wt,r=typeof e===gt?e:e.name||e.text,l=St[r]?St[r].className:"k-grid-"+(r||"").replace(/\s/g,""),o={className:l,text:r,imageClass:"",attr:"",iconClass:""};if(!(r||H(e)&&e.template))throw Error("Custom commands should have name specified");return H(e)?(e.className&&(e.className+=" "+o.className),"edit"===r&&H(e.text)&&(e=R(!0,{},e),e.text=e.text.edit),e.attr&&H(e.attr)&&(e.attr=a(e.attr)),o=R(!0,o,St[r],e)):o=R(!0,o,St[r]),v.template(t)(o)},_groupable:function(){var t=this;t._groupableClickHandler?t.table.off(ut+K,t._groupableClickHandler):t._groupableClickHandler=function(r){var a=e(this),l=a.closest("tr");a.hasClass("k-i-collapse")?t.collapseGroup(l):t.expandGroup(l),r.preventDefault(),r.stopPropagation()},t.table.on(ut+K,".k-grouping-row .k-i-collapse, .k-grouping-row .k-i-expand",t._groupableClickHandler),t._attachGroupable()},_attachGroupable:function(){var t=this,r=t.wrapper,a=t.options.groupable;a&&(r.has("div.k-grouping-header")[0]||e("
").addClass("k-grouping-header").prependTo(r),t.groupable&&t.groupable.destroy(),t.groupable=new y(r,R({},a,{draggable:t._draggableInstance,groupContainer:">div.k-grouping-header",dataSource:t.dataSource,draggableElements:t.content?".k-grid-header:first "+U:"table:first>.k-grid-header "+U,filter:t.content?".k-grid-header:first "+$:"table:first>.k-grid-header "+$,allowDrag:t.options.reorderable})))},_selectable:function(){var e,r,a=this,l=a.options.selectable;l&&(e=typeof l===gt&&l.toLowerCase().indexOf("multiple")>-1,r=typeof l===gt&&l.toLowerCase().indexOf("cell")>-1,a.selectable=new v.ui.Selectable(a.table,{filter:">"+(r?q:"tbody>tr:not(.k-grouping-row,.k-detail-row,.k-group-footer)"),aria:!0,multiple:e,change:function(){a.trigger(et)}}),a.options.navigatable&&a.table.on("keydown"+K,function(l){var o=a.current();if(l.keyCode===S.SPACEBAR&&l.target==a.table[0]&&!o.is(".k-edit-cell,.k-header")&&o.parent().is(":not(.k-grouping-row,.k-detail-row,.k-group-footer)")){if(l.preventDefault(),l.stopPropagation(),o=r?o:o.parent(),e)if(l.ctrlKey){if(o.hasClass(st))return o.removeClass(st),a.trigger(et),t}else a.selectable.clear();else a.selectable.clear();a.selectable.value(o)}}))},clearSelection:function(){var e=this;e.selectable.clear(),e.trigger(et)},select:function(r){var a=this,l=a.selectable;return r=e(r),r.length?(l.options.multiple||(l.clear(),r=r.first()),l.value(r),t):l.value()},current:function(r){var a=this,l=a.options.scrollable,o=a._current,n=a.table.add(a.thead.parent());return r!==t&&r.length&&(o&&o[0]===r[0]||(o&&(o.removeClass(it).removeAttr("id"),n.removeAttr("aria-activedescendant")),r.attr("id",a._cellId),a._current=r.addClass(it),n.attr("aria-activedescendant",a._cellId),r.length&&l&&(e.contains(a.content[0],r[0])&&a._scrollTo(r.parent()[0],a.content[0]),l.virtual?a._scrollTo(r[0],a.content.find(">.k-virtual-scrollable-wrap")[0]):a._scrollTo(r[0],a.content[0])))),a._current},_removeCurrent:function(){this._current&&(this._current.removeClass(it),this._current=null)},_scrollTo:function(e,t){var r=e.tagName.toLowerCase(),a="td"===r||"th"===r,l=e[a?"offsetLeft":"offsetTop"],o=e[a?"offsetWidth":"offsetHeight"],n=t[a?"scrollLeft":"scrollTop"],i=t[a?"clientWidth":"clientHeight"],s=l+o,d=0;d=n>l?l:s>n+i?i>=o?s-i:l:n,t[a?"scrollLeft":"scrollTop"]=d},_navigatable:function(){var t=this,r=W(t.current,t),a=t.table,l=t.thead.parent(),o=a,n=v.support.isRtl(t.element);t.options.navigatable&&(t.options.scrollable&&(o=a.add(l),l.attr(ft,-1)),l.on("keydown"+K,function(e){e.altKey&&e.keyCode==S.DOWN&&(r().find(".k-grid-filter, .k-header-column-menu").click(),e.stopImmediatePropagation())}).find("a.k-link").attr("tabIndex",-1),a.attr(ft,N.max(a.attr(ft)||0,0)).on("mousedown"+K+" keydown"+K,".k-detail-cell",function(e){e.target!==e.currentTarget&&e.stopImmediatePropagation()}),o.on(v.support.touch?"touchstart"+K:"mousedown"+K,P+">"+O,W(k,t)).on("focus"+K,function(){if(!v.support.touch){var t=r();t&&t.is(":visible")?t.addClass(it):r(e(this).find(G)),this==a[0]?(l.attr(ft,-1),a.attr(ft,0)):(a.attr(ft,-1),l.attr(ft,0))}}).on("focusout"+K,function(){var e=r();e&&e.removeClass(it)}).on("keydown"+K,function(l){var o,i,s,d,c,u,p,f,h=l.keyCode,g=!1,m=!l.isDefaultPrevented()&&!e(l.target).is(":button,a,:input,a>.k-icon"),k=t.options.pageable,v=t.dataSource,_="incell"==t._editMode(),w=l.shiftKey,y=r();y&&y.is("th")&&(m=!0),m&&h==S.UP?(y?(s=y.parent().prevAll(P).first(),s[0]||(c=t.thead.parent(),b(c,!0),s=c.find(P).first()),d=y.index(),y=s.children().eq(d),y[0]&&y.is(O)||(y=s.children(O).first())):y=a.find(G),g=!0,r(y)):m&&h==S.DOWN?(y?(s=y.parent().nextAll(P).first(),!s[0]&&y.is("th")&&(b(t.tbody.parent()),s=t.tbody.find(P).first()),d=y.index(),y=s.children().eq(d),y[0]&&y.is(O)||(y=s.children(O).first())):y=a.find(G),g=!0,r(y)):m&&h==(n?S.RIGHT:S.LEFT)?(r(y?y.prevAll(F+":first"):a.find(G)),g=!0):m&&h==(n?S.LEFT:S.RIGHT)?(y?y.next()[0]&&(y=y.nextAll(F+":first")):y=a.find(G),g=!0,r(y)):m&&k&&S.PAGEDOWN==h?(v.page(v.page()+1),g=!0):m&&k&&S.PAGEUP==h?(v.page(v.page()-1),g=!0):h==S.ENTER||S.F2==h?(y=y?y:a.find(G),y.is("th")?(y.find(".k-link").click(),g=!0):y.parent().is(".k-master-row,.k-grouping-row")?(y.parent().find(".k-icon:first").click(),g=!0):(u=y.find(":focusable:first"),!y.hasClass("k-edit-cell")&&u[0]&&y.hasClass("k-state-focused")?(u.focus(),g=!0):t.options.editable&&!e(l.target).is(":button,.k-button")&&(p=e(l.target).closest("[role=gridcell]"),p[0]||(p=y),t._handleEditing(p),g=!0))):S.ESC==h?(o=x(),y&&e.contains(y[0],o)&&!y.hasClass("k-edit-cell")&&!y.parent().hasClass("k-grid-edit-row")?(b(t.table[0],!0),g=!0):!t._editContainer||y&&!t._editContainer.has(y[0])&&y[0]!==t._editContainer[0]||(_?t.closeCell(!0):(i=t.items().index(e(y).parent()),o&&o.blur(),t.cancelRow(),i>=0&&t.current(t.items().eq(i).children().filter(O).first())),Ct.msie&&Ct.version<9&&document.body.focus(),b(a,!0),g=!0)):S.TAB==h&&(y=e(y),t.options.editable&&_&&(f=e(x()).closest(".k-edit-cell"),f[0]&&f[0]!==y[0]&&(y=f)),f=w?y.prevAll(F+":first"):y.nextAll(":visible:first"),f.length||(f=y.parent()[w?"prevAll":"nextAll"]("tr:not(.k-grouping-row):not(.k-detail-row):visible:first").children(F+(w?":last":":first"))),!y.is("th")&&f.length&&t.options.editable&&_&&(t._handleEditing(y,f),g=!0)),g&&(l.preventDefault(),l.stopPropagation())}))},_handleEditing:function(r,a){var l,o,n=this,i=e(x()),s=n._editMode(),d=Ct.msie,c=d&&Ct.version<9,u=n._editContainer;if(o="incell"==s?r.hasClass("k-edit-cell"):r.parent().hasClass("k-grid-edit-row"),n.editable){if(e.contains(u[0],i[0])&&(Ct.opera||c?i.change().triggerHandler("blur"):(i.blur(),d&&i.blur())),!n.editable)return b(n.table),t;if(!n.editable.end())return"incell"==s?n.current(u):n.current(u.children().filter(F).first()),l=u.find(":focusable:first")[0],l&&l.focus(),t;"incell"==s?n.closeCell():(n.saveRow(),o=!0)}a&&n.current(a),c&&document.body.focus(),b(n.table,!0),(!o&&!a||a)&&("incell"==s?n.editCell(n.current()):n.editRow(n.current().parent()))},_wrapper:function(){var e=this,t=e.table,r=e.options.height,a=e.element;a.is("div")||(a=a.wrap("").parent()),e.wrapper=a.addClass("k-grid k-widget k-secondary"),r&&(e.wrapper.css(pt,r),t.css(pt,"auto"))},_tbody:function(){var t,r=this,a=r.table;t=a.find(">tbody"),t.length||(t=e("").appendTo(a)),r.tbody=t},_scrollable:function(){var t,r,a,l,o,n=this,i=n.options,s=i.scrollable,d=s!==!0&&s.virtual&&!n.virtualScrollable,c=!v.support.kineticScrollNeeded||d?v.support.scrollbar():0;s&&(t=n.wrapper.children(".k-grid-header"),t[0]||(t=e('').insertBefore(n.table)),t.css(yt?"padding-left":"padding-right",s.virtual?c+1:c),r=e(''),xt&&r.attr("cellspacing",0),r.append(n.thead),t.empty().append(e('').append(r)),n.content=n.table.parent(),n.content.is(".k-virtual-scrollable-wrap")&&(n.content=n.content.parent()),n.content.is(".k-grid-content, .k-virtual-scrollable-wrap")||(n.content=n.table.wrap('').parent()),d&&(n.virtualScrollable=new Tt(n.content,{dataSource:n.dataSource,itemHeight:W(n._averageRowHeight,n)})),n.scrollables=t.children(".k-grid-header-wrap"),a=n.wrapper.find(".k-grid-footer"),l=yt&&Ct.webkit?c:0,a.length&&(n.scrollables=n.scrollables.add(a.children(".k-grid-footer-wrap"))),s.virtual?n.content.find(">.k-virtual-scrollable-wrap").bind("scroll"+K,function(){n.scrollables.scrollLeft(this.scrollLeft+l)
}):(n.content.bind("scroll"+K,function(){n.scrollables.scrollLeft(this.scrollLeft+l)}),o=v.touchScroller(n.content),o&&o.movable&&o.movable.bind("change",function(e){n.scrollables.scrollLeft(-e.sender.x)})))},_setContentHeight:function(){var e,t=this,r=t.options,a=t.wrapper.innerHeight(),l=t.wrapper.children(".k-grid-header"),o=v.support.scrollbar();r.scrollable&&(a-=l.outerHeight(),t.pager&&(a-=t.pager.element.outerHeight()),r.groupable&&(a-=t.wrapper.children(".k-grouping-header").outerHeight()),r.toolbar&&(a-=t.wrapper.children(".k-grid-toolbar").outerHeight()),t.footerTemplate&&(a-=t.wrapper.children(".k-grid-footer").outerHeight()),e=function(e){var t,r;return e[0].style.height?!0:(t=e.height(),e.height("auto"),r=e.height(),t!=r?(e.height(""),!0):(e.height(""),!1))},e(t.wrapper)&&(a>2*o?t.content.height(a):t.content.height(2*o+1)))},_averageRowHeight:function(){var e,t=this,r=t._rowHeight;return t._rowHeight||(t._rowHeight=r=t.table.outerHeight()/t.items().length,t._sum=r,t._measures=1),e=t.table.outerHeight()/t.items().length,r!==e&&(t._measures++,t._sum+=e,t._rowHeight=t._sum/t._measures),r},_dataSource:function(){var e,r=this,a=r.options,l=a.dataSource;l=I(l)?{data:l}:l,H(l)&&(R(l,{table:r.table,fields:r.columns}),e=a.pageable,H(e)&&e.pageSize!==t&&(l.pageSize=e.pageSize)),r.dataSource&&r._refreshHandler?r.dataSource.unbind(et,r._refreshHandler).unbind(L,r._progressHandler).unbind(B,r._errorHandler):(r._refreshHandler=W(r.refresh,r),r._progressHandler=W(r._requestStart,r),r._errorHandler=W(r._error,r)),r.dataSource=w.create(l).bind(et,r._refreshHandler).bind(L,r._progressHandler).bind(B,r._errorHandler)},_error:function(){this._progress(!1)},_requestStart:function(){this._progress(!0)},_modelChange:function(t){var r,a,l,o,n=this,i=t.model,s=n.tbody.find("tr["+v.attr("uid")+"="+i.uid+"]"),d=s.hasClass("k-alt"),c=n.items().index(s);if(s.children(".k-edit-cell").length&&!n.options.rowTemplate)s.children(":not(.k-group-cell,.k-hierarchy-cell)").each(function(){r=e(this),a=n.columns[n.cellIndex(r)],a.field===t.field&&(r.hasClass("k-edit-cell")?r.addClass("k-dirty-cell"):(n._displayCell(r,a,i),e('').prependTo(r)))});else if(!s.hasClass("k-grid-edit-row")){for(l=(d?n.altRowTemplate:n.rowTemplate)(i),s.replaceWith(l),l=n.items().eq(c),c=0,o=n.columns.length;o>c;c++)a=n.columns[c],a.field===t.field&&(r=l.children(":not(.k-group-cell,.k-hierarchy-cell)").eq(c),e('').prependTo(r));n.trigger("itemChange",{item:l,data:i,ns:_})}},_pageable:function(){var t,r=this,a=r.options.pageable;a&&(t=r.wrapper.children("div.k-grid-pager"),t.length||(t=e('').appendTo(r.wrapper)),r.pager&&r.pager.destroy(),r.pager="object"==typeof a&&a instanceof v.ui.Pager?a:new v.ui.Pager(t,R({},a,{dataSource:r.dataSource})))},_footer:function(){var t,r,a=this,l=a.dataSource.aggregates(),o="",i=a.footerTemplate,s=a.options,d=a.footer||a.wrapper.find(".k-grid-footer");i?(l=z(l)?n(a.dataSource.aggregate()):l,o=e(a._wrapFooter(i(l))),d.length?(r=o,d.replaceWith(r),d=a.footer=r):d=a.footer=s.scrollable?s.pageable?o.insertBefore(a.wrapper.children("div.k-grid-pager")):o.appendTo(a.wrapper):o.insertBefore(a.tbody)):d&&!a.footer&&(a.footer=d),d.length&&(s.scrollable&&(t=d.attr("tabindex",-1).children(".k-grid-footer-wrap"),a.scrollables=a.scrollables.not(".k-grid-footer-wrap").add(t)),a._footerWidth&&d.find("table").css("width",a._footerWidth),t&&t.scrollLeft(a.content.scrollLeft()))},_wrapFooter:function(t){var r=this,a="",l=v.support.mobileOS?0:v.support.scrollbar();return r.options.scrollable?(a=e('"),r._appendCols(a.find("table")),a.css(yt?"padding-left":"padding-right",l),a):'"},_columnMenu:function(){var t,r,a,l,o,n,i=this,s=i.columns,d=i.options,c=d.columnMenu,u=function(){b(i.thead.parent(),!0)},p=function(e){i.trigger(Z,{field:e.field,container:e.container})};c&&("boolean"==typeof c&&(c={}),i.thead.find("th:not(.k-hierarchy-cell,.k-group-cell)").each(function(f){r=s[f],n=e(this),r.command||!r.field&&!n.attr("data-"+v.ns+"field")||(t=n.data("kendoColumnMenu"),t&&t.destroy(),l=r.sortable!==!1&&c.sortable!==!1?d.sortable:!1,o=d.filterable&&r.filterable!==!1&&c.filterable!==!1?R({},r.filterable,d.filterable):!1,a={dataSource:i.dataSource,values:r.values,columns:c.columns,sortable:l,filterable:o,messages:c.messages,owner:i,closeCallback:u,init:p},n.kendoColumnMenu(a))}))},_filterable:function(){var t,r,a=this,l=a.columns,o=function(){b(a.thead.parent(),!0)},n=a.options.filterable;n&&!a.options.columnMenu&&a.thead.find("th:not(.k-hierarchy-cell,.k-group-cell)").each(function(i){t=e(this),l[i].filterable===!1||l[i].command||!l[i].field&&!t.attr("data-"+v.ns+"field")||(r=t.data("kendoFilterMenu"),r&&r.destroy(),t.kendoFilterMenu(R(!0,{},n,l[i].filterable,{dataSource:a.dataSource,values:l[i].values,closeCallback:o,init:function(e){a.trigger(Y,{field:e.field,container:e.container})}})))})},_sortable:function(){var t,r,a,l=this,o=l.columns,n=l.options.sortable;n&&l.thead.find("th:not(.k-hierarchy-cell,.k-group-cell)").each(function(i){t=o[i],t.sortable!==!1&&!t.command&&t.field&&(r=e(this),a=r.data("kendoSortable"),a&&a.destroy(),r.attr("data-"+v.ns+"field",t.field).kendoSortable(R({},n,t.sortable,{dataSource:l.dataSource,aria:!0})))})},_columns:function(t){var r,a=this,l=a.table,o=l.find("col"),n=a.options.dataSource;t=t.length?t:A(l.find("th"),function(t,r){t=e(t);var a=t.attr(v.attr("sortable")),l=t.attr(v.attr("filterable")),n=t.attr(v.attr("type")),i=t.attr(v.attr("groupable")),s=t.attr(v.attr("field")),d=t.attr(v.attr("menu"));return s||(s=t.text().replace(/\s|[^A-z0-9]/g,"")),{field:s,type:n,sortable:"false"!==a,filterable:"false"!==l,groupable:"false"!==i,menu:d,template:t.attr(v.attr("template")),width:o.eq(r).css("width")}}),r=!(a.table.find("tbody tr").length>0&&(!n||!n.transport)),a.columns=A(t,function(e){return e=typeof e===gt?{field:e}:e,e.hidden&&(e.attributes=c(e.attributes),e.footerAttributes=c(e.footerAttributes),e.headerAttributes=c(e.headerAttributes)),R({encoded:r},e)})},_groups:function(){var e=this.dataSource.group();return e?e.length:0},_tmpl:function(e,t){var l,o,n,i,s=this,d=R({},v.Template,s.options.templateSettings),c=s.columns.length,u={storage:{},count:0},p=s._hasDetails(),f=[],h=s._groups();if(!e){for(e="",h>0&&(e+=r(h)),p&&(e+=' | '),l=0;c>l;l++)n=s.columns[l],o=n.template,i=typeof o,e+="",e+=s._cellTmpl(n,u),e+=" | ";e+="
"}return e=v.template(e,d),u.count>0?W(e,u.storage):e},_headerCellText:function(e){var t=this,r=R({},v.Template,t.options.templateSettings),a=e.headerTemplate,l=typeof a,o=e.title||e.field||"";return l===ht?o=v.template(a,r)({}):l===gt&&(o=a),o},_cellTmpl:function(e,t){var r,a,l=this,o=R({},v.Template,l.options.templateSettings),n=e.template,i=o.paramName,s=e.field,d="",c=e.format,u=typeof n,p=e.values;if(e.command){if(I(e.command)){for(r=0,a=e.command.length;a>r;r++)d+=l._createButton(e.command[r]);return d.replace(kt,"\\#")}return l._createButton(e.command).replace(kt,"\\#")}return u===ht?(t.storage["tmpl"+t.count]=n,d+="#=this.tmpl"+t.count+"("+i+")#",t.count++):u===gt?d+=n:p&&p.length&&H(p[0])&&"value"in p[0]&&s?(d+="#var v ="+v.stringify(f(p))+"#",d+="#var f = v[",o.useWithBlock||(d+=i+"."),d+=s+"]#",d+="${f != null ? f : ''}"):(d+=e.encoded?"#:":"#=",c&&(d+='kendo.format("'+c.replace(bt,"\\$1")+'",'),s?(s=v.expr(s,i),d+=s+"==null?'':"+s):d+="''",c&&(d+=")"),d+="#"),d},_templates:function(){var t=this,r=t.options,a=t.dataSource,l=a.group(),o=t.footer||t.wrapper.find(".k-grid-footer"),n=a.aggregate();t.rowTemplate=t._tmpl(r.rowTemplate),t.altRowTemplate=t._tmpl(r.altRowTemplate||r.rowTemplate,!0),t._hasDetails()&&(t.detailTemplate=t._detailTmpl(r.detailTemplate||"")),(t._group&&!z(n)||!z(n)&&!o.length||D(t.columns,function(e){return e.footerTemplate}).length)&&(t.footerTemplate=t._footerTmpl(n,"footerTemplate","k-footer-template")),l&&D(t.columns,function(e){return e.groupFooterTemplate}).length&&(n=e.map(l,function(e){return e.aggregates}),t.groupFooterTemplate=t._footerTmpl(n,"groupFooterTemplate","k-group-footer"))},_footerTmpl:function(e,t,l){var o,i,s,d,c,u=this,p=R({},v.Template,u.options.templateSettings),f=p.paramName,h="",g=u.columns,m={},b=0,k={},_=u._groups(),w=n(e);for(h+='',_>0&&(h+=r(_)),u._hasDetails()&&(h+=' | '),o=0,i=u.columns.length;i>o;o++)c=g[o],s=c[t],d=typeof s,h+="",s?(d!==ht&&(k=w[c.field]?R({},p,{paramName:f+"."+c.field}):{},s=v.template(s,k)),m["tmpl"+b]=s,h+="#=this.tmpl"+b+"("+f+")#",b++):h+=" ",h+=" | ";return h+="
",h=v.template(h,p),b>0?W(h,m):h},_detailTmpl:function(e){var t=this,a="",l=R({},v.Template,t.options.templateSettings),o=l.paramName,n={},i=0,s=t._groups(),c=d(t.columns).length,u=typeof e;return a+='',s>0&&(a+=r(s)),a+=' | ",u===ht?(n["tmpl"+i]=e,a+="#=this.tmpl"+i+"("+o+")#",i++):a+=e,a+=" |
",a=v.template(a,l),i>0?W(a,n):a},_hasDetails:function(){var e=this;return null!==e.options.detailTemplate||(e._events[Q]||[]).length},_details:function(){var t=this;t.table.on(ut+K,".k-hierarchy-cell .k-plus, .k-hierarchy-cell .k-minus",function(r){var a,l,o=e(this),n=o.hasClass("k-plus"),i=o.closest("tr.k-master-row"),s=t.detailTemplate,d=t._hasDetails();return o.toggleClass("k-plus",!n).toggleClass("k-minus",n),d&&!i.next().hasClass("k-detail-row")&&(l=t.dataItem(i),e(s(l)).addClass(i.hasClass("k-alt")?"k-alt":"").insertAfter(i),t.trigger(Q,{masterRow:i,detailRow:i.next(),data:l,detailCell:i.next().find(".k-detail-cell")})),a=i.next(),t.trigger(n?ot:nt,{masterRow:i,detailRow:a}),a.toggle(n),t._current&&t._current.attr("aria-expanded",n),r.preventDefault(),!1})},dataItem:function(t){if(t=e(t)[0],!t)return null;var r,a,l=this.tbody.children(),o=/k-grouping-row|k-detail-row|k-group-footer/,n=t.sectionRowIndex;for(a=n,r=0;n>r;r++)o.test(l[r].className)&&a--;return this._data[a]},expandRow:function(t){e(t).find("> td .k-plus, > td .k-i-expand").click()},collapseRow:function(t){e(t).find("> td .k-minus, > td .k-i-collapse").click()},_thead:function(){var r,l,o,n,i,s=this,d=s.columns,c=s._hasDetails()&&d.length,u="",p=s.table.find(">thead");if(p.length||(p=e("").insertBefore(s.tbody)),o=s.element.find("tr:has(th):first"),o.length||(o=p.children().first(),o.length||(o=e("
"))),o.children().length)c&&!o.find(".k-hierarchy-cell")[0]&&o.prepend(' | ');else{for(c&&(u+=' | '),r=0,l=d.length;l>r;r++)i=d[r],n=s._headerCellText(i),i.command?u+=""+n+" | ":(u+=""+n+" | ");o.html(u)}o.find("th").addClass("k-header"),s.options.scrollable||p.addClass("k-grid-header"),o.find("script").remove().end().appendTo(p),s.thead&&s._destroyColumnAttachments(),s.thead=p,s._sortable(),s._filterable(),s._scrollable(),s._updateCols(),s._resizable(),s._draggable(),s._reorderable(),s.groupable&&s._attachGroupable(),s._columnMenu()},_updateCols:function(){var e=this;e._appendCols(e.thead.parent().add(e.table))},_appendCols:function(e){var t=this;p(e,d(t.columns),t._hasDetails(),t._groups())},_autoColumns:function(e){if(e&&e.toJSON){var t,r=this;e=e.toJSON();for(t in e)r.columns.push({field:t});r._thead(),r._templates()}},_rowsHtml:function(e){var t,r,a=this,l="",o=a.rowTemplate,n=a.altRowTemplate;for(t=0,r=e.length;r>t;t++)l+=t%2?n(e[t]):o(e[t]),a._data.push(e[t]);return l},_groupRowHtml:function(e,t,a){var l,o,n=this,i="",s=e.field,d=D(n.columns,function(e){return e.field==s})[0]||{},c=d.groupHeaderTemplate,u=(d.title||s)+": "+h(e.value,d.format,d.values),p=R({},{field:e.field,value:e.value},e.aggregates[e.field]),f=n._groupAggregatesDefaultObject||{},g=e.items;if(c&&(u=typeof c===ht?c(p):v.template(c)(p)),i+=''+r(a)+''+' '+''+u+" |
",e.hasSubgroups)for(l=0,o=g.length;o>l;l++)i+=n._groupRowHtml(g[l],t-1,a+1);else i+=n._rowsHtml(g);return n.groupFooterTemplate&&(i+=n.groupFooterTemplate(R(f,e.aggregates))),i},collapseGroup:function(r){r=e(r).find(".k-icon").addClass("k-i-expand").removeClass("k-i-collapse").end();var a,l,o=r.find(".k-group-cell").length,n=1;r.find("td:first").attr("aria-expanded",!1),r.nextAll("tr").each(function(){return l=e(this),a=l.find(".k-group-cell").length,l.hasClass("k-grouping-row")?n++:l.hasClass("k-group-footer")&&n--,o>=a||l.hasClass("k-group-footer")&&0>n?!1:(l.hide(),t)})},expandGroup:function(r){r=e(r).find(".k-icon").addClass("k-i-collapse").removeClass("k-i-expand").end();var a,l,o=this,n=r.find(".k-group-cell").length,i=1;r.find("td:first").attr("aria-expanded",!0),r.nextAll("tr").each(function(){return a=e(this),l=a.find(".k-group-cell").length,n>=l?!1:(l!=n+1||a.hasClass("k-detail-row")||(a.show(),a.hasClass("k-grouping-row")&&a.find(".k-icon").hasClass("k-i-collapse")&&o.expandGroup(a),a.hasClass("k-master-row")&&a.find(".k-icon").hasClass("k-minus")&&a.next().show()),a.hasClass("k-grouping-row")&&i++,a.hasClass("k-group-footer")&&(1==i?a.show():i--),t)})},_updateHeader:function(t){var r=this,a=r.thead.find("th.k-group-cell"),l=a.length;t>l?e(Array(t-l+1).join('')).prependTo(r.thead.find("tr")):l>t&&(l-=t,e(D(a,function(e,t){return l>t})).remove())},_firstDataItem:function(e,t){return e&&t&&(e=e.hasSubgroups?this._firstDataItem(e.items[0],t):e.items[0]),e},hideColumn:function(t){var r,a,l,o,n,i,s,u,p,f=this,h=0,m=f.footer||f.wrapper.find(".k-grid-footer"),b=f.columns;if(t="number"==typeof t?b[t]:D(b,function(e){return e.field===t})[0],t&&!t.hidden){for(p=E(t,d(b)),t.hidden=!0,t.attributes=c(t.attributes),t.footerAttributes=c(t.footerAttributes),t.headerAttributes=c(t.headerAttributes),f._templates(),f._updateCols(),g(f.thead.find(">tr")[0].cells,p,!1),m[0]&&(f._appendCols(m.find("table:first")),g(m.find(".k-footer-template")[0].cells,p,!1)),r=f.tbody.children(),n=0,u=r.length;u>n;n+=1)a=r.eq(n),a.is(".k-grouping-row,.k-detail-row")?(l=a.children(":not(.k-group-cell):first,.k-detail-cell").last(),l.attr("colspan",parseInt(l.attr("colspan"),10)-1)):(a.hasClass("k-grid-edit-row")&&(l=a.children(".k-edit-container")[0])&&(l=e(l),l.attr("colspan",parseInt(l.attr("colspan"),10)-1),l.find("col").eq(p).remove(),a=l.find("tr:first")),g(a[0].cells,p,!1));for(i=f.thead.prev().find("col"),n=0,u=i.length;u>n;n+=1){if(s=i[n].style.width,!s||-1!=s.indexOf("%")){h=0;break}h+=parseInt(s,10)}o=e(">.k-grid-header table:first,>.k-grid-footer table:first",f.wrapper).add(f.table),f._footerWidth=null,h&&(o.width(h),f._footerWidth=h),Ct.msie&&8==Ct.version&&(o.css("display","inline-table"),setTimeout(function(){o.css("display","table")},1)),f.trigger(tt,{column:t})}},showColumn:function(t){var r,a,l,o,n,i,s,c,f,h,m=this,b=m.columns,k=m.footer||m.wrapper.find(".k-grid-footer");if(t="number"==typeof t?b[t]:D(b,function(e){return e.field===t})[0],t&&t.hidden){for(h=E(t,b),t.hidden=!1,t.attributes=u(t.attributes),t.footerAttributes=u(t.footerAttributes),t.headerAttributes=u(t.headerAttributes),m._templates(),m._updateCols(),g(m.thead.find(">tr")[0].cells,h,!0),k[0]&&(m._appendCols(k.find("table:first")),g(k.find(".k-footer-template")[0].cells,h,!0)),r=m.tbody.children(),a=0,l=r.length;l>a;a+=1)o=r.eq(a),o.is(".k-grouping-row,.k-detail-row")?(n=o.children(":not(.k-group-cell):first,.k-detail-cell").last(),n.attr("colspan",parseInt(n.attr("colspan"),10)+1)):(o.hasClass("k-grid-edit-row")&&(n=o.children(".k-edit-container")[0])&&(n=e(n),n.attr("colspan",parseInt(n.attr("colspan"),10)+1),p(n.find(">form>table"),d(b),!1,0),o=n.find("tr:first")),g(o[0].cells,h,!0));if(i=e(">.k-grid-header table:first,>.k-grid-footer table:first",m.wrapper).add(m.table),t.width){for(s=0,f=m.thead.prev().find("col"),a=0,l=f.length;l>a;a+=1){if(c=f[a].style.width,c.indexOf("%")>-1){s=0;break}s+=parseInt(c,10)}m._footerWidth=null,s&&(i.width(s),m._footerWidth=s)}else i.width("");m.trigger(rt,{column:t})}},_progress:function(e){var t=this,r=t.element.is("table")?t.element.parent():t.content&&t.content.length?t.content:t.element;v.ui.progress(r,e)},refresh:function(t){var r,a,l,o,i,s,c=this,u="",p=c.dataSource.view(),f=c.options.navigatable,h=e(c.current()),g=!1,m=(c.dataSource.group()||[]).length,k=m+d(c.columns).length;if(!(t&&"itemchange"===t.action&&c.editable||(t=t||{},c.trigger("dataBinding",{action:t.action||"rebind",index:t.index,items:t.items})))){if(s=x(),f&&(c.table[0]===s||e.contains(c.table[0],s)||c._editContainer&&c._editContainer.data("kendoWindow"))&&(g=h.is("th"),i=0,g&&(i=c.thead.find("th:not(.k-group-cell)").index(h))),c._destroyEditable(),c._progress(!1),c._data=[],c.columns.length||(c._autoColumns(c._firstDataItem(p[0],m)),k=m+c.columns.length),c._group=m>0||c._group,c._group&&(c._templates(),c._updateCols(),c._updateHeader(m),c._group=m>0),m>0)for(c.detailTemplate&&k++,c.groupFooterTemplate&&(c._groupAggregatesDefaultObject=n(c.dataSource.aggregate())),a=0,r=p.length;r>a;a++)u+=c._groupRowHtml(p[a],k,0);else u+=c._rowsHtml(p);C?c.tbody[0].innerHTML=u:(o=document.createElement("div"),o.innerHTML="",l=o.firstChild.firstChild,c.table[0].replaceChild(l,c.tbody[0]),c.tbody=e(l)),c._footer(),c._setContentHeight(),i>=0&&(c._removeCurrent(),g?c.current(c.thead.find("th:not(.k-group-cell)").eq(i)):c.current(c.items().eq(i).children().filter(F).first()),c._current&&b(c._current.closest("table")[0],!0)),c.trigger(lt)}}});_.plugin(Ht),_.plugin(Tt)}(window.kendo.jQuery)});