(function(d){var b=d.telerik;var c=3;var a=0;b.grouping={};b.grouping.initialize=function(e){d.extend(e,b.grouping.implementation);e.$groupDropClue=d('
');e.$groupHeader=d("> .t-grouping-header",e.element);b.draganddrop(e.element.id,d.extend({useDragClue:true,draggables:[d(".t-link",e.$groupHeader[0]),d(".t-header:not(.t-group-cell,.t-hierarchy-cell)",e.$header[0])]},b.draganddrop.applyContext(b.draganddrop.grouping,e)));if(e.isAjax()){e.$groupHeader.delegate(".t-button","click",function(f){f.preventDefault();e.unGroup(d(this).parent().text())}).delegate(".t-link","click",function(g){g.preventDefault();var f=e.groupFromTitle(d(this).parent().text());f.order=f.order=="asc"?"desc":"asc";e.group(f.title)})}e.$groupHeader.delegate(".t-group-indicator","mouseenter",function(){e.$currentGroupItem=d(this)}).delegate(".t-group-indicator","mouseleave",function(){e.$currentGroupItem=null});e.$tbody.delegate(".t-grouping-row .t-collapse, .t-grouping-row .t-expand","click",b.stop(function(g){g.preventDefault();var f=d(this).closest("tr");if(d(this).hasClass("t-collapse")){e.collapseGroup(f)}else{e.expandGroup(f)}}))};b.grouping.implementation={columnFromTitle:function(e){return d.grep(this.columns,function(f){return f.title==e})[0]},groupFromTitle:function(e){return d.grep(this.groups,function(f){return f.title==e})[0]},expandGroup:function(f){var g=d(f);var e=g.find(".t-group-cell").length;g.find("~ tr").each(d.proxy(function(j,k){var h=d(k);var l=h.find(".t-group-cell").length;if(l<=e){return false}if(l==e+1&&!h.hasClass("t-detail-row")){h.show();if(h.hasClass("t-grouping-row")&&h.find(".t-icon").hasClass("t-collapse")){this.expandGroup(h)}if(h.hasClass("t-master-row")&&h.find(".t-icon").hasClass("t-minus")){h.next().show()}}},this));g.find(".t-icon").addClass("t-collapse").removeClass("t-expand")},collapseGroup:function(f){var g=d(f);var e=g.find(".t-group-cell").length;g.find("~ tr").each(function(){var h=d(this);var i=h.find(".t-group-cell").length;if(i<=e){return false}h.hide()});g.find(".t-icon").addClass("t-expand").removeClass("t-collapse")},group:function(f,i){if(this.groups.length==0&&this.isAjax()){this.$groupHeader.empty()}var g=d.grep(this.groups,function(k){return k.title==f})[0];if(!g){var h=this.columnFromTitle(f);g={order:"asc",member:h.member,title:f};this.groups.push(g)}if(i>=0){this.groups.splice(d.inArray(g,this.groups),1);this.groups.splice(i,0,g)}this.groupBy=d.map(this.groups,function(k){return k.member+"-"+k.order}).join("~");if(this.isAjax()){var j=this.$groupHeader.find('div:contains("'+f+'")');if(j.length==0){var e=new d.telerik.stringBuilder().cat('").string();j=d(e).appendTo(this.$groupHeader)}if(this.$groupDropClue.is(":visible")){j.insertBefore(this.$groupDropClue)}j.find(".t-link .t-icon").toggleClass("t-arrow-up-small",g.order=="asc").toggleClass("t-arrow-down-small",g.order=="desc");this.ajaxRequest()}else{this.serverRequest()}},unGroup:function(f){var e=this.groupFromTitle(f);this.groups.splice(d.inArray(e,this.groups),1);if(this.groups.length==0){this.$groupHeader.html(this.localization.groupHint)}this.groupBy=d.map(this.groups,function(h){return h.member+"-"+h.order}).join("~");if(this.isAjax()){this.$groupHeader.find('div:contains("'+e.title+'")').remove();this.ajaxRequest()}else{this.serverRequest()}},normalizeColumns:function(g){var h=this.groups.length;var f=g-this.$tbody.parent().find("col").length;if(f==0){return}var i=this.$tbody.parent().add(this.$headerWrap.find("table"));if(d.browser.msie){if(f>0){d(new b.stringBuilder().rep('',f).string()).prependTo(i.find("colgroup"));d(new b.stringBuilder().rep('',f).string()).insertBefore(i.find("th.t-header:first"))}else{i.find("th:lt("+Math.abs(f)+")").remove().end().find("col:lt("+Math.abs(f)+")").remove()}if(document.documentMode==8){if(this.scrollable){i.css("table-layout","auto")}var j=this;var e=30;i.find("col").css("width",function(){return d(this).is(".t-group-col,.t-hierarchy-col")?e:(d(j.element).width()-h*e-16)/j.columns.length})}}else{i.find("col.t-group-col").remove();d(new b.stringBuilder().rep('',h).string()).prependTo(i.find("colgroup"));i.find("th.t-group-cell").remove();d(new b.stringBuilder().rep('',h).string()).insertBefore(i.find("th.t-header:first"))}this.$footer.attr("colspan",g)},bindGroup:function(g,m,k,j){var h=this.groups[j];var o=g.Key;var f=d.grep(this.columns,function(i){return h.member==i.member})[0];if(f&&(f.format||f.type=="Date")){o=b.formatString(f.format||"{0:G}",o)}k.cat('').rep(' | ',j).cat('').cat(h.title).cat(": ").cat(o).cat(" |
");if(g.HasSubgroups){for(var e=0,n=g.Items.length;e .t-grid-toolbar",this.element).outerHeight()+c;if(!i.length){this.$groupDropClue.css({top:l,left:a}).appendTo(this.$groupHeader);return"t-add"}var g=i[0];var n=i[i.length-1];var h=parseInt(g.$group.css("marginLeft"));var j=parseInt(g.$group.css("marginRight"));var k=d.grep(i,function(e){return m.pageX>=e.left-h-j&&m.pageX<=e.right})[0];if(!k&&g&&m.pageX0){var i=this.$groupHeader.find("div").index(this.$groupDropClue);var l=j-i;if(!g||(this.$groupDropClue.is(":visible")&&l!=0&&l!=-1)){this.group(h,i)}}else{if(f.parent().is(".t-group-indicator")){this.unGroup(h)}else{this.$groupDropClue.remove();return false}}this.$groupDropClue.remove();return true}}})})(jQuery);