Wtf.grid.RowExpander=function(A){Wtf.apply(this,A);Wtf.grid.RowExpander.superclass.constructor.call(this);if(this.tpl){if(typeof this.tpl=="string"){this.tpl=new Wtf.Template(this.tpl)}this.tpl.compile()}this.state={};this.bodyContent={};this.addEvents({beforeexpand:true,expand:true,beforecollapse:true,collapse:true})};Wtf.extend(Wtf.grid.RowExpander,Wtf.util.Observable,{header:"",width:20,sortable:false,fixed:true,dataIndex:"",id:"expander",lazyRender:true,enableCaching:true,getRowClass:function(B,E,D,C){D.cols=D.cols-1;var A=this.bodyContent[B.id];if(!A&&!this.lazyRender){A=this.getBodyContent(B,E)}if(A){D.body=A}return this.state[B.id]?"x-grid3-row-expanded":"x-grid3-row-collapsed"},init:function(B){this.grid=B;var A=B.getView();A.getRowClass=this.getRowClass.createDelegate(this);A.enableRowBody=true;B.on("render",function(){A.mainBody.on("mousedown",this.onMouseDown,this)},this)},getBodyContent:function(C,A){if(!this.enableCaching){return this.tpl.apply(C.data)}var B=this.bodyContent[C.id];if(!B){B=this.tpl.apply(C.data);this.bodyContent[C.id]=B}return B},onMouseDown:function(B,A){if(A.className=="x-grid3-row-expander"){B.stopEvent();var C=B.getTarget(".x-grid3-row");this.toggleRow(C)}},renderer:function(A,C,B){C.cellAttr='rowspan="2"';return'<div class="x-grid3-row-expander">&#160;</div>'},beforeExpand:function(B,A,C){if(this.fireEvent("beforexpand",this,B,A,C)!==false){if(this.tpl&&this.lazyRender){A.innerHTML=this.getBodyContent(B,C)}return true}else{return false}},toggleRow:function(A){if(typeof A=="number"){A=this.grid.view.getRow(A)}this[Wtf.fly(A).hasClass("x-grid3-row-collapsed")?"expandRow":"collapseRow"](A)},expandRow:function(C){if(typeof C=="number"){C=this.grid.view.getRow(C)}var B=this.grid.store.getAt(C.rowIndex);var A=Wtf.DomQuery.selectNode("tr:nth(2) div.x-grid3-row-body",C);if(this.beforeExpand(B,A,C.rowIndex)){this.state[B.id]=true;Wtf.fly(C).replaceClass("x-grid3-row-collapsed","x-grid3-row-expanded");this.fireEvent("expand",this,B,A,C.rowIndex)}},collapseRow:function(C){if(typeof C=="number"){C=this.grid.view.getRow(C)}var B=this.grid.store.getAt(C.rowIndex);var A=Wtf.fly(C).child("tr:nth(1) div.x-grid3-row-body",true);if(this.fireEvent("beforcollapse",this,B,A,C.rowIndex)!==false){this.state[B.id]=false;Wtf.fly(C).replaceClass("x-grid3-row-expanded","x-grid3-row-collapsed");this.fireEvent("collapse",this,B,A,C.rowIndex)}}})