1 line
6.9 KiB
JavaScript
1 line
6.9 KiB
JavaScript
|
(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('<div class="t-grouping-dropclue"/>');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('<div class="t-group-indicator">').cat('<a href="#" class="t-link"><span class="t-icon" />').cat(f).cat("</a>").cat('<a class="t-button t-state-default"><span class="t-icon t-group-delete" /></a>').cat("</div>").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('<col class="t-group-col" />',f).string()).prependTo(i.find("colgroup"));d(new b.stringBuilder().rep('<th class="t-group-cell t-header"> </th>',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){i
|