﻿Sys.UI.Controls.GridMouseHoverEventArgs=function(isHover,clientX,clientY){Sys.UI.Controls.GridMouseHoverEventArgs.initializeBase(this);this._isHover=isHover;this._clientX=clientX;this._clientY=clientY;}
Sys.UI.Controls.GridMouseHoverEventArgs.prototype={get_isHover:function(){return this._isHover;},get_clientX:function(){return this._clientX;},get_clientY:function(){return this._clientY;}}
Sys.UI.Controls.GridMouseHoverEventArgs.registerClass('Sys.UI.Controls.GridMouseHoverEventArgs',Sys.EventArgs);Sys.UI.Controls.GridGetRowNoEventArgs=function(rowNo,rowData){Sys.UI.Controls.GridGetRowNoEventArgs.initializeBase(this);this._rowNo=rowNo;this._rowData=rowData;}
Sys.UI.Controls.GridGetRowNoEventArgs.prototype={get_rowNo:function(){return this._rowNo;},set_rowNo:function(value){this._rowNo=value;},get_rowData:function(){return this._rowData;}}
Sys.UI.Controls.GridGetRowNoEventArgs.registerClass('Sys.UI.Controls.GridGetRowNoEventArgs',Sys.EventArgs);Sys.UI.Controls.GridColumnChangeEventArgs=function(rowIndex,value,oldValue){Sys.UI.Controls.GridColumnChangeEventArgs.initializeBase(this);this._rowIndex=rowIndex;this._value=value;this._oldValue=oldValue;this._valueChanged=false;this._focusColumn=null;}
Sys.UI.Controls.GridColumnChangeEventArgs.prototype={get_rowIndex:function(){return this._rowIndex;},get_focusColumn:function(){return this._focusColumn;},set_focusColumn:function(value){this._focusColumn=value;},get_oldValue:function(){return this._oldValue;},get_value:function(){return this._value;},set_value:function(value){this._value=value;this._valueChanged=true;},get_valueChanged:function(){return this._valueChanged;}}
Sys.UI.Controls.GridColumnChangeEventArgs.registerClass('Sys.UI.Controls.GridColumnChangeEventArgs',Sys.CancelEventArgs);Sys.UI.Controls.GridCellBeginEditEventArgs=function(rowIndex,columnIndex,column){Sys.UI.Controls.GridCellBeginEditEventArgs.initializeBase(this);this._rowIndex=rowIndex;this._columnIndex=columnIndex;this._column=column;}
Sys.UI.Controls.GridCellBeginEditEventArgs.prototype={get_rowIndex:function(){return this._rowIndex;},get_columnIndex:function(){return this._columnIndex;},get_column:function(){return this._column;}}
Sys.UI.Controls.GridCellBeginEditEventArgs.registerClass('Sys.UI.Controls.GridCellBeginEditEventArgs',Sys.CancelEventArgs);Sys.UI.Controls.GridCellRenderingEventArgs=function(rowIndex,columnIndex,column){Sys.UI.Controls.GridCellRenderingEventArgs.initializeBase(this);this._rowIndex=rowIndex;this._columnIndex=columnIndex;this._column=column;this._fontColor=null;this._bgColor=null;}
Sys.UI.Controls.GridCellRenderingEventArgs.prototype={get_rowIndex:function(){return this._rowIndex;},get_columnIndex:function(){return this._columnIndex;},get_column:function(){return this._column;},get_fontColor:function(){return this._fontColor;},set_fontColor:function(value){this._fontColor=value;},get_bgColor:function(){return this._bgColor;},set_bgColor:function(value){this._bgColor=value;}}
Sys.UI.Controls.GridCellRenderingEventArgs.registerClass('Sys.UI.Controls.GridCellRenderingEventArgs',Sys.EventArgs);Sys.UI.Controls.GridNewRecordEventArgs=function(data){Sys.UI.Controls.GridNewRecordEventArgs.initializeBase(this);this._data=data;}
Sys.UI.Controls.GridNewRecordEventArgs.prototype={get_data:function(){return this._data;}}
Sys.UI.Controls.GridNewRecordEventArgs.registerClass('Sys.UI.Controls.GridNewRecordEventArgs',Sys.EventArgs);Sys.UI.Controls.GridGetDisplayTextEventArgs=function(rowIndex,value,text){Sys.UI.Controls.GridGetDisplayTextEventArgs.initializeBase(this);this._rowIndex=rowIndex;this._value=value;this._text=text;}
Sys.UI.Controls.GridGetDisplayTextEventArgs.prototype={get_rowIndex:function(){return this._rowIndex;},get_value:function(){return this._value;},get_text:function(){return this._text;},set_text:function(value){this._text=value;}}
Sys.UI.Controls.GridGetDisplayTextEventArgs.registerClass('Sys.UI.Controls.GridGetDisplayTextEventArgs',Sys.EventArgs);Sys.UI.Controls.GridRowClickEventArgs=function(rowIndex,column){Sys.UI.Controls.GridRowClickEventArgs.initializeBase(this);this._rowIndex=rowIndex;this._column=column;}
Sys.UI.Controls.GridRowClickEventArgs.prototype={get_rowIndex:function(){return this._rowIndex;},get_column:function(){return this._column;}}
Sys.UI.Controls.GridRowClickEventArgs.registerClass('Sys.UI.Controls.GridRowClickEventArgs',Sys.EventArgs);Sys.UI.Controls.GridRowDeletingEventArgs=function(rowIndex){Sys.UI.Controls.GridRowDeletingEventArgs.initializeBase(this);this._rowIndex=rowIndex;}
Sys.UI.Controls.GridRowDeletingEventArgs.prototype={get_rowIndex:function(){return this._rowIndex;}}
Sys.UI.Controls.GridRowDeletingEventArgs.registerClass('Sys.UI.Controls.GridRowDeletingEventArgs',Sys.CancelEventArgs);Sys.UI.Controls.GridGetLoadedItemsEventArgs=function(loadedItems,appendItemIndex,decimalField){Sys.UI.Controls.GridGetLoadedItemsEventArgs.initializeBase(this);this._loadedItems=loadedItems;this._appendItemIndex=appendItemIndex;this._decimalField=decimalField;}
Sys.UI.Controls.GridGetLoadedItemsEventArgs.prototype={modifyOrAppendItems:function(items,keyField){if(!items)return;if(!keyField){throw Error.argumentNull("keyField");} var loadedItems=this._loadedItems;var loadedItemsCount=loadedItems.length;var findLoadedItem=function(item){for(var j=0;j<loadedItemsCount;j++){var loadedItem=loadedItems[j];if(loadedItem){var data=loadedItem.data;if(data&&data[keyField]==item[keyField]){return loadedItem;}}} return null;};var copyTo=function(from,to){if(from&&to){for(var name in from){to[name]=from[name];}}};var appendItemIndex=this._appendItemIndex;for(var i=0,count=items.length;i<count;i++){var item=items[i];var loadedItem=findLoadedItem(item);if(loadedItem){if(!loadedItem.__isLoadedItem){copyTo(item,loadedItem.data);loadedItem.__isLoadedItem=true;}} else{var record={};record.data=item;record.__isLoadedItem=true;loadedItems[appendItemIndex]=record;appendItemIndex++;}} var decimalField=this._decimalField;if(decimalField){for(var i=0,count=loadedItems.length;i<count;i++){var loadedItem=loadedItems[i];if(loadedItem){var data=loadedItem.data;if(data&&!loadedItem.__isLoadedItem){data[decimalField]=null;loadedItem.__isLoadedItem=true;}}}}}}
Sys.UI.Controls.GridGetLoadedItemsEventArgs.registerClass('Sys.UI.Controls.GridGetLoadedItemsEventArgs',Sys.EventArgs);Sys.UI.Controls.GridColumnSortEventArgs=function(column){Sys.UI.Controls.GridColumnSortEventArgs.initializeBase(this);this._column=column;}
Sys.UI.Controls.GridColumnSortEventArgs.prototype={get_column:function(){return this._column;}}
Sys.UI.Controls.GridColumnSortEventArgs.registerClass('Sys.UI.Controls.GridColumnSortEventArgs',Sys.CancelEventArgs);Sys.UI.Controls.Grid=function(element){Sys.UI.Controls.Grid.initializeBase(this,[element]);this._visible=true;this._label=null;this._tag=null;this._readOnly=true;this._modifyOnly=false;this._skinColors=null;this._skinPoperties=null;this._defaultRowCount=10;this._maxRowCount=-1;this._pageSize=10;this._columnsParams=[];this._bands=null;this._guid=null;this._dataField=null;this._dataSource=null;this._columnExpands=null;this._cellMergeItems=null;this._showHeader=true;this._maxHeaderLevel=1;this._showFooter=false;this._showRowNo=true;this._showLines=true;this._hideSelection=false;this._allowCopy=$settings.gridDefaultAllowCopy;this._allowSort=false;this._allowResize=$settings.gridDefaultAllowResize;this._showScrollBar=true;this._showHScrollBar=false;this._useEvenRowColor=true;this._useMultiRowCaption=false;this._useCustomRendering=false;this._allColumnWidth=0;this._pagerId=null;this._rowNoColumnWidth=null;this._mouseHoverTime=200;this._mouseHoverTimer=null;this._textColor=null;this._popupMenu=null;this._needRowIndex=false;this._wordWrap=true;this._headerBar=null;this._header=null;this._headerRow=null;this._headerSpacer=null;this._colGroup=null;this._body=null;this._footerBar=null;this._footer=null;this._footerRow=null;this._footerSpacer=null;this._rowsTable=null;this._rows=null;this._selectedRow=null;this._mouseHoverRow=null;this._columns=null;this._focusedColumn=null;this._dataController=null;this._configData=null;this._configDataChanged=false;this._dataRowFirst=0;this._configID=0;this._followPager=null;this._summaryItems=null;this._hasSummaryColumn=false;this._needPreloadItems=false;this._preloadItems=null;}
Sys.UI.Controls.Grid.prototype={initialize:function(){Sys.UI.Controls.Grid.callBaseMethod(this,'initialize');},dispose:function(){this._hideEditor();delete this._columnsParams;if(this._rowsTable){if(this._commandColumns){this._clearRowsTable();delete this._commandColumns;} $clearHandlers(this._rowsTable);this._rowsTable=null;} this._colGroup=null;if(this._body){$clearHandlers(this._body);this._body=null;} if(this._footer){$clearHandlers(this._footer);this._footer=null;} if(this._documentKeyDownHandler){$common.removeKeyDownHandler(document,this._documentKeyDownHandler);this._documentKeyDownHandler=null;} this._focusedColumn=null;this._rowDeleteColumn=null;this._activeColumn=null;if(this._loadedItems){delete this._loadedItems;this._loadedItems=null;this._multiSelectColumn=null;} if(this._columns){for(var i=0,count=this._columns.length;i<count;i++){this._columns[i].dispose();} delete this._columns;} if(this._dataController){this._dataController.dispose();this._dataController=null;} this._clearMouseHoverTimer();this._followPager=null;this._summaryItems=null;if(this._rowsEnabled){delete this._rowsEnabled;} if(this._preloadItems){delete this._preloadItems;} if(this._configDataChanged){var form=this.findForm();if(form){var syncCall=!form.get_isAsync();try{this._internalSaveConfig(syncCall);} catch(e){};} this._configDataChanged=false;} delete this._configData;Sys.UI.Controls.Grid.callBaseMethod(this,'dispose');},doFormInit:function Sys$UI$Controls$Grid$doFormInit(){if(!this.get_visible())return;this._skinColors=$skin.getElement("grid","colors");var skinPoperties=this._skinPoperties=$skin.getElement("grid","properties");this._rowNoColumnWidth=skinPoperties.rowNoColumnWidth;var element=this.get_element();var gridWidth=element.offsetWidth;var gridHeight=element.offsetHeight;var borderSize=this._getBorderSize();var headerHeight=0;var gridDivs=$common.getChildrenByTagName(element,"div");var divIndex=0;var showScrollBar=this.get_showScrollBar();if(this.get_showHeader()){var headerBar=this._headerBar=gridDivs[divIndex];divIndex++;var header=this._header=$common.getFirstChildByTagName(headerBar,"table");if(this._maxHeaderLevel>1){this._colGroup=$common.getFirstChildByTagName(header,"colgroup");} var tr=this._headerRow=$common.getTableFirstRow(header);if(showScrollBar){var td=this._headerSpacer=$common.getLastChildByTagName(tr,"td");this._doAdjustHeaderSpacer();} headerHeight=headerBar.offsetHeight;} var body=this._body=gridDivs[divIndex];$common.addFocusHandler(body,this._bodyFocus,this);divIndex++;var footerHeight=0;if(this.get_showFooter()){var footerBar=this._footerBar=gridDivs[divIndex];var footer=this._footer=$common.getFirstChildByTagName(footerBar,"table");$common.addMouseOverHandler(footer,this._footerMouseOver,this);var tr=this._footerRow=$common.getTableFirstRow(footer);this._footerSpacer=$common.getLastChildByTagName(tr,"td");this._doAdjustFooterSpacer();footerHeight=footer.offsetHeight;} this._createColumns();body.tabIndex=0;this._doAdjustBodyWidth();var borderAndHeaderFooterHeight=borderSize+headerHeight+footerHeight;body.style.height=(gridHeight-borderAndHeaderFooterHeight)+"px";if(Sys.Browser.isStandard&&!showScrollBar){$common.setAutoHeight(element);$common.setAutoHeight(body);} if(Sys.Browser.isIE7||Sys.Browser.isStandard){element.style.height="";} var borderSize=this._getLineWidth();var table=this._rowsTable=$common.createTable(borderSize);table.className="GridBodyRows";table.style.tableLayout="fixed";var allColumnWidth=this._allColumnWidth;table.width=showScrollBar?(allColumnWidth>0?allColumnWidth:this._getAllColumnWidth()):"100%";var tableBody=this._rows=$common.createTBody();var expandCount=this._getFirstColumnExpandCount();if(expandCount>0){this._initColumnExpands();} table.appendChild(tableBody);body.appendChild(table);this._initDataRows();if(expandCount==0){this._initColumnExpands();} $common.addMouseOutHandler(body,this._bodyMouseOut,this);$common.addScrollHandler(body,this._bodyScroll,this);this._documentKeyDownHandler=$common.addKeyDownHandler(document,this._documentKeyDown,this);var pager=this.findPager();if(pager&&pager.get_hasSummary()){pager.refreshSummary();$common.addResizeHandler(element,this._gridResize,this);}},_bodyFocus:function(){var form=this.get_form();if(form&&form.get_isActive()){if(Sys.Browser.isIE8){this._focusRowsTable();} this._notifyFormFocusControl();}},_clearRowsTable:function(){var commandColumns=this._commandColumns;if(!commandColumns)return;var firstCellIndex=this._getFirstColumnCellIndex();var columnCount=commandColumns.length;var cellIndices=new Array(columnCount);for(var i=0;i<columnCount;i++){cellIndices[i]=firstCellIndex+commandColumns[i].get_index();} var row=this._rows.firstChild;while(row!=null){if(row._state=="1"){var cells=row.childNodes;for(var j=0;j<columnCount;j++){var cellIndex=cellIndices[j];var cell=cells[cellIndex];var cellText=cell.firstChild;if(cellText){$clearHandlers(cellText);}}} row=row.nextSibling;}},_initRowsTableEvent:function(){var table=this._rowsTable;$common.addMouseOverHandler(table,this._rowsMouseOver,this);$common.addMouseOutHandler(table,this._rowsMouseOut,this);$common.addMouseUpHandler(table,this._rowsMouseUp,this);$common.addMouseDownHandler(table,this._rowsMouseDown,this);$common.addDblClickHandler(table,this._rowsDblClick,this);$common.addMouseWheelHandler(table,this._rowsMouseWheel,this);$common.addContextMenuHandler(table,this._rowsContextMenu,this);},get_visible:function(){return this._visible;},set_visible:function(value){if(this._visible!=value){this._visible=value;if(this.get_isInitialized()){Sys.UI.Controls.Grid.callBaseMethod(this,'set_visible',[value]);if(!this._body){this.doFormInit();}}}},get_height:function(){return this.get_element().offsetHeight;},set_height:function(value){var borderSize=this._getBorderSize();var otherSize=borderSize;if(this._headerBar){otherSize+=this._headerBar.offsetHeight;} if(this._footerBar){otherSize+=this._footerBar.offsetHeight;} if(this._body&&value>otherSize){$common.setHeight(this.get_element(),value-borderSize);$common.setHeight(this._body,value-otherSize);}},_documentKeyDown:function(e){var form=this.get_form();if(form&&form.get_isActive()&&$common.findFocusedGrid(form)==this){this._rowsKeyDown(e);}},canFocus:function(){return!this.get_readOnly()||this.get_recordCount()>0;},get_followPager:function(){return this._followPager;},set_followPager:function(value){this._followPager=value;},_resetPagerWidth:function(){var width=this.get_element().offsetWidth;var pager=this.findPager();if(pager){pager.set_width(width);} var followPager=this.get_followPager();if(followPager){followPager.set_width(width);}},_gridResize:function(e){this._resetPagerWidth();},_getBorderSize:function(){var skinPoperties=this._skinPoperties;return(skinPoperties.borderSize+skinPoperties.borderPadding)*2;},_getLineWidth:function(){return this.get_showLines()?1:0;},_doAdjustHeaderSpacer:function(){if(this.get_showHeader()&&this.get_showScrollBar()){this._doAdjustHeaderFooterSpacer(this._headerBar,this._header,this._headerSpacer,true);}},_doAdjustFooterSpacer:function(){if(this.get_showFooter()&&this.get_showScrollBar()){this._doAdjustHeaderFooterSpacer(this._footerBar,this._footer,this._footerSpacer,false);}},_doAdjustHeaderFooterSpacer:function(div,table,td,isHeader){var scrollBarWidth=16;var spacerWidth=td.offsetWidth;var lineWidth=this._getLineWidth();if(!this.get_showHScrollBar()){var tdLeft=td.offsetLeft;var element=this.get_element();var width=element.offsetWidth-tdLeft-this._getBorderSize()-lineWidth;if(spacerWidth!=width){element.style.overflow="hidden";if(width>scrollBarWidth){if(Sys.Browser.isIE8){table.style.tableLayout="";} table.style.width=(tdLeft+width+lineWidth)+"px";td.style.width=width+"px";} else{var width=tdLeft+scrollBarWidth+lineWidth;table.style.width=width+"px";element.style.width=width+"px";td.style.width=scrollBarWidth+"px";}}} else{var allColumnWidth=this.get_columnCount()==0?this._allColumnWidth:this._getAllColumnWidth();if(allColumnWidth<=0)return;var barWidth=div.offsetWidth;var width=barWidth-allColumnWidth-lineWidth;if(spacerWidth!=width){if(width<scrollBarWidth){width=scrollBarWidth;} var colGroup=this._colGroup;if(isHeader&&colGroup){var cols=colGroup.childNodes;var col=cols[cols.length-1];col.width=width;} else{td.width=width;} var newTableWidth=allColumnWidth+width+lineWidth;this._setTableWidth(table,newTableWidth);}}},_doAdjustBodyWidth:function Sys$UI$Controls$Grid$_doAdjustBodyWidth(){var style=this._body.style;var newWidth=(this.get_element().offsetWidth-this._getBorderSize())+"px";if(style.width!=newWidth){style.width=newWidth;}},get_rowNoColumnWidth:function(){return this._rowNoColumnWidth;},get_rowNoColumnCaption:function(){var headerRow=this._headerRow;return headerRow&&this.get_showRowNo()?headerRow.childNodes[0].firstChild.innerHTML:"";},get_columns:function(){var columns=new Array();columns.length=this._columns.length;var i=j=0;while(i<columns.length){if(!this._columns[i++]._noUse){columns[j++]=this._columns[i-1];}} columns.length=j;return columns;},_createColumns:function(){if(this.get_allowSort()){$skin.addImageToCache("grid","sortShape");} var firstCellIndex=this._getFirstColumnCellIndex();var showHeader=this.get_showHeader();var footerRow=this._footerRow;var tdCache;if(showHeader){tdCache={};if(this._maxHeaderLevel>1){var headerRows=$common.getTableBody(this._header);var headerRow=headerRows.firstChild;while(headerRow!=null){this._initTdCache(headerRow,tdCache);headerRow=headerRow.nextSibling;}} else{this._initTdCache(this._headerRow,tdCache);}} var canSummary=this.get_showFooter();var hasSummaryColumn=false;var columnsParams=this._columnsParams;var columnCount=columnsParams.length;this._columns=new Array(columnCount);var columnIdPrefix=this.get_id()+"_column";for(var i=0;i<columnCount;i++){var params=columnsParams[i];var headerElement=showHeader?tdCache[columnIdPrefix+i]:null;var footerElement=footerRow?footerRow.childNodes[firstCellIndex+i]:null;var column=this._createColumn(i,params,headerElement,footerElement);this._columns[i]=column;if(canSummary&&!hasSummaryColumn&&column.get_isClientSum()){hasSummaryColumn=true;} if(column instanceof Sys.UI.Controls.MultiSelectColumn){this._loadedItems=[];this._multiSelectColumn=column;} else if(column instanceof Sys.UI.Controls.RowDeleteColumn){this._rowDeleteColumn=column;} if(!column.get_readOnly()&&!this._loadedItems){this._loadedItems=[];}} if(tdCache){delete tdCache;} delete this._columnsParams;this._hasSummaryColumn=hasSummaryColumn;},_initTdCache:function(row,tdCache){var td=row.firstChild;while(td!=null){var id=td.id;if(id){tdCache[id]=td;} td=td.nextSibling;}},_createColumn:function(index,params,headerElement,footerElement){var columnType=params.type;var props=params.properties;if(!columnType){columnType=Sys.UI.Controls.Column;props.readOnly=true;} var column=new columnType();column._grid=this;column._params=params;column._allEvents=params.events;var elements=new Object();elements.header=headerElement;elements.footer=footerElement;column._elements=elements;column._index=index;Sys$Component$_setProperties(column,props);return column;},_getStartRecordIndex:function(){var pager=this.findPager();if(pager){return pager.get_pageItemIndex();} else{return 0;}},_internalAddCommandColumn:function(column){var commandColumns=this._commandColumns;if(!commandColumns){commandColumns=this._commandColumns=[];} Array.add(commandColumns,column);},_internalDoPagerBeforeRefresh:function(){if(this._loadedItems){this._refreshLoadedItems=true;}},_initLoadedItems:function(){if(!this._loadedItems){return false;} if(this._refreshLoadedItems){Array.clear(this._loadedItems);this._refreshLoadedItems=false;return false;} var multiSelectColumn=this._multiSelectColumn;var dataField=multiSelectColumn?multiSelectColumn.get_dataField():null;var recordCount=this.get_recordCount();var controller=this.get_dataController();var startRecordIndex=this._getStartRecordIndex();for(var i=0;i<recordCount;i++){var record=this._loadedItems[i+startRecordIndex];if(!record){record={};this._loadedItems[i+startRecordIndex]=record;} record.data=controller.getRecord(i);record.recordIndex=i;if(record.data&&dataField){record.selected=this.getRowEnabled(i)?record.data[dataField]:false;}} return true;},_loadPreLoadedRow:function(rowCount){var loadedItems=this._loadedItems;if(loadedItems){var controller=this.get_dataController();var startRecordIndex=this._getStartRecordIndex();var handler=this.get_events().getHandler("getLoadedItems");if(handler){for(var i=0;i<rowCount;i++){var record=loadedItems[i+startRecordIndex];if(!record){record={};record.data=controller.getRecord(i);record.recordIndex=i;loadedItems[i+startRecordIndex]=record;}} loadedItems=this._doGetLoadedItems();} for(var i=0;i<rowCount;i++){var record=loadedItems[i+startRecordIndex];if(record){controller.modifyRecord(i,record.data);}}}},_initDataRows:function(){if(this._rowsEnabled){delete this._rowsEnabled;} this._setSelectedRow(null);var dataRowCount=this.get_dataController().get_recordCount();var curCount=this.get_rowCount();var rowCount=Math.max(dataRowCount,this.get_defaultRowCount());var row;this._loadPreLoadedRow(dataRowCount);this.doBeforeDataBind();var sb=new Sys.StringBuilder();var oldTable=this._rowsTable;sb.append('<table border="0" cellpadding="0" cellspacing="1" class="GridBodyRows" width="'+oldTable.width+'" style="'+oldTable.style.cssText+'">');sb.append("<tbody>");var showRowNo=this.get_showRowNo();var getRowNoHandler=showRowNo?this.get_events().getHandler("getRowNo"):null;var columnCount=this.get_columnCount();var cellRenderingHandler=this.get_events().getHandler("cellRendering");var disableCopy=this.get_allowCopy()?"":"unselectable=\"on\" ";for(var i=0;i<rowCount;i++){var hasData=i<dataRowCount;this._addRowFast(sb,i,showRowNo,getRowNoHandler,columnCount,hasData,cellRenderingHandler,disableCopy);} sb.append("</tbody>");sb.append("</table>");if(curCount>0){this._clearRowsTable();} $clearHandlers(oldTable);$removeNode(oldTable);var body=this._body;body.innerHTML=sb.toString();var table=this._rowsTable=body.firstChild;this._rows=table.firstChild;var rowDeleteColumn=this._rowDeleteColumn;if(this._rowDeleteColumn&&dataRowCount<rowCount){for(var i=dataRowCount;i<rowCount;i++){var row=this._getRow(i);rowDeleteColumn.doInit(row,i);}} this._initRowsTableEvent();if(this._cellMergeItems){this._initCellMerge();} this._calcAllColumnSummary();if(dataRowCount>0){this.doAfterDataBind();var firstRow=this._getRow(0);this._setSelectedRow(firstRow,true);this._checkShowImmediateEditor(firstRow);} else if(this._dataSourceChanging){this.doSelectionChanged();} this._dataSourceChanging=false;},_addRowFast:function(sb,rowIndex,showRowNo,getRowNoHandler,columnCount,hasData,cellRenderingHandler,disableCopy){sb.append('<tr class="GridBodyRow" _rowIndex="').append(rowIndex).append('">');if(showRowNo){sb.append('<td class="GridBodyRowNoCell" width="').append(this._rowNoColumnWidth).append('">');var html=this._getRowNoHTMLFast(rowIndex,getRowNoHandler);sb.append(html);sb.append("</td>");} for(var i=0;i<columnCount;i++){var column=this.getColumnByIndex(i);var style="";if(!column.get_visible()){style+="display:none;";} var colors=this._getCellStyleFast(rowIndex,column,i,false,0,hasData,cellRenderingHandler,null);style+="color:"+colors.fontColor+";background-color:"+colors.bgColor;sb.append('<td class="GridBodyCell" ').append(disableCopy).append('width="').append(column.get_width()).append('" align="').append(column.get_textAlign()).append('" _columnIndex="').append(i).append('" style="').append(style).append('">');var html=hasData?column._getCellHTML(rowIndex):"&nbsp;";sb.append(html);sb.append("</td>");} sb.append("</tr>");},add_beforeDataBind:function(handler,handlerOwner){return this.get_events().addHandler("beforeDataBind",handler,handlerOwner);},remove_beforeDataBind:function(handler){this.get_events().removeHandler("beforeDataBind",handler);},doBeforeDataBind:function(){var handler=this.get_events().getHandler("beforeDataBind");if(handler){handler(this);}},add_afterDataBind:function(handler){this.get_events().addHandler("afterDataBind",handler);},remove_afterDataBind:function(handler){this.get_events().removeHandler("afterDataBind",handler);},doAfterDataBind:function(){var handler=this.get_events().getHandler("afterDataBind");if(handler){handler(this);}},add_focus:function(handler){this.get_events().addHandler("_focus",handler);},remove_focus:function(handler){this.get_events().removeHandler("_focus",handler);},add_change:function(handler){this.get_events().addHandler("_change",handler);},remove_change:function(handler){this.get_events().removeHandler("_change",handler);},doChange:function(e){var handler=this.get_events().getHandler("_change");if(handler){handler(this,e);} var form=this.get_form();if(form){form.doChange();} $common.setTestState("gridChanged");},get_columnCount:function(){var columns=this._columns;return columns?columns.length:0;},get_visibleColumnCount:function(){var answer=0;for(var i=0,count=this.get_columnCount();i<count;i++){var column=this.getColumnByIndex(i);if(column.get_visible()){answer++;}} return answer;},_getColumnIndexByName:function(name,visibleOnly){if(name){name=name.toLowerCase();var count=this.get_columnCount();for(var i=0;i<count;i++){var column=this.getColumnByIndex(i);var columnName=column.get_name();var dataField=column.get_dataField();if((columnName&&columnName.toLowerCase()==name)||(dataField&&dataField.toLowerCase()==name)){if(!visibleOnly||column.get_visible()){return i;}}}} return-1;},getColumn:function(name){var column=this.findColumn(name);if(!column){throw Error.invalidOperation("字段“"+name+"”不存在");} return column;},findColumn:function(name,visibleOnly){var index=this._getColumnIndexByName(name,visibleOnly);return index>=0?this.getColumnByIndex(index):null;},getColumnByIndex:function(index){return this._columns[index];},_createRow:function(rowIndex){var tr=document.createElement("tr");tr.className="GridBodyRow";if(this.get_showRowNo()){var td=$common.createTd();td.className="GridBodyRowNoCell";td.width=this._rowNoColumnWidth;tr.appendChild(td);} var columnCount=this.get_columnCount();for(var i=0;i<columnCount;i++){var column=this.getColumnByIndex(i);var td=this._createCell(column);tr.appendChild(td);} tr._rowIndex=rowIndex;return tr;},_createCell:function(column){var td=$common.createTd();td.className="GridBodyCell";if(!column.get_visible()){td.style.display="none";} td.width=column.get_width();td.align=column.get_textAlign();td._columnIndex=column.get_index();return td;},_addRow:function(rowIndex){var row=this._createRow(rowIndex);this._rows.appendChild(row);return row;},_getRow:function(index){return this._rows.childNodes[index];},get_rowCount:function Sys$UI$Controls$Grid$get_rowCount(){return this._rows.childNodes.length;},_appendRow:function(){var index=this.get_rowCount();var row=this._addRow(index);this._initRowNo(row,index);if(this._rowDeleteColumn){this._rowDeleteColumn.doInit(row,index);} return row;},_getEventTargetRow:function(e){var cell=e.target;if(cell.tagName=="TD"){return cell.parentNode;} else if(cell.parentNode&&cell.parentNode.tagName=="TD"){return cell.parentNode.parentNode;} return null;},_getEventTargetCell:function(row,e){var cell=e.target;if(cell.parentNode&&cell.parentNode.tagName=="TD"){cell=cell.parentNode;} if(cell.tagName=="TD"){var index=Array.indexOf(row.childNodes,cell);if(this.get_showRowNo())index--;if(index<0){return null;} else{return cell;}} return null;},_focusBody:function(){try{this._body.focus();} catch(e){}},focus:function Sys$UI$Controls$Grid$focus(){this._focusBody();var selectedRow=this._selectedRow;if(!selectedRow&&this.get_rowCount()>0){selectedRow=this._getRow(0);this._setSelectedRow(selectedRow);} if(selectedRow){if(!this.get_readOnly()){var editingColumnIndex=this._getEditingColumnIndex();if(editingColumnIndex>=0){this._focusRowCell(selectedRow,editingColumnIndex);} else{var result=this._focusRowFirstCell(selectedRow);if(!result){this._focusRowsTable();}}} else{this._focusRowsTable();}} this._notifyFormFocusControl();},_notifyFormFocusControl:function(){var form=this.get_form();if(form){var oldValue=form.get_focusedControl();form.set_focusedControl(this);var handler=this.get_events().getHandler("_focus");if(handler&&oldValue!=this){handler(this,e);}}},doFormDeactivate:function Sys$UI$Controls$Grid$doFormDeactivate(){this._hideEditor();if(this.get_allowResize()){for(var i=0,count=this.get_columnCount();i<count;i++){var column=this.getColumnByIndex(i);column._internalDoFormDeactivate();}}},setRowsHint:function(value){var element=this._rows;if(element){element.title=value;}},setRowHint:function(rowIndex,value){this._checkRowIndex(rowIndex);var row=this._getRow(rowIndex);row.title=value;},setRowBgColor:function(rowIndex,value){this._setRowCellColor(rowIndex,"_bgColor",value);},setRowFontColor:function(rowIndex,value){this._setRowCellColor(rowIndex,"_fontColor",value);},_setRowCellColor:function(rowIndex,name,value){this._checkRowIndex(rowIndex);var row=this._getRow(rowIndex);var firstCellIndex=this._getFirstColumnCellIndex();var rowCells=row.childNodes;var columnCount=this.get_columnCount();for(var i=0;i<columnCount;i++){var cell=rowCells[firstCellIndex+i];cell[name]=value;} this._setRowStyle(row,0);},setRowColumnBgColor:function(rowIndex,column,value){this._checkRowIndex(rowIndex);var row=this._getRow(rowIndex);var column=this._internalGetColumn(column);var cell=this._getRowCell(row,column.get_index());cell._bgColor=value;cell._columnBgColor=value;this._setRowStyle(row,0);},setRowColumnEnabled:function(rowIndex,column,enabled){this._checkRowIndex(rowIndex);var row=this._getRow(rowIndex);var column=this._internalGetColumn(column);if(!column.setEditable){throw Error.invalidOperation("列“"+column+"”不支持 setRowColumnEnabled");} var cell=this._getRowCell(row,column.get_index());column.setEditable(enabled,cell);},add_rowMouseHover:function(handler){this.get_events().addHandler("rowMouseHover",handler);},remove_rowMouseHover:function(handler){this.get_events().removeHandler("rowMouseHover",handler);},get_mouseHoverRowData:function(){return this._getRowDataByRowElement(this._mouseHoverRow);},_getRowIndex:function(row){var answer=row._rowIndex;return typeof(answer)=="string"?parseInt(answer):answer;},get_mouseHoverRowIndex:function(){return this._mouseHoverRow?this._getRowIndex(this._mouseHoverRow):-1;},get_activeRowData:function(){var data=this.get_mouseHoverRowData();return data?data:this.get_selectedRowData();},add_bodyMouseOut:function(handler){this.get_events().addHandler("bodyMouseOut",handler);},remove_bodyMouseOut:function(handler){this.get_events().removeHandler("bodyMouseOut",handler);},_bodyMouseOut:function(e){var p={x:e.clientX,y:e.clientY};var r=$common.getBounds(this._body);if(!$common.ptInRect(p,r)){var handler=this.get_events().getHandler("bodyMouseOut");if(handler){var eventArgs=new Sys.UI.Controls.GridMouseHoverEventArgs(false,e.clientX,e.clientY);handler(this,eventArgs);}}},_bodyScroll:function(e){if(this._headerBar){this._headerBar.scrollLeft=this._body.scrollLeft;} if(this._footerBar){this._footerBar.scrollLeft=this._body.scrollLeft;}},_setActiveRowIndex:function(rowIndex){this._mouseHoverRow=this._getRow(rowIndex);},_rowsMouseOver:function Sys$UI$Controls$Grid$_rowsMouseOver(e){var row=this._getEventTargetRow(e);if(row){if(row._state!="1"&&this._commandColumns){this._initRowCommandColumns(row);this._internalSetRowState(row);} this._setRowStyle(row,1);if(this._rowDeleteColumn){this._rowDeleteColumn.doHover(row,true);} if(this._mouseHoverRow!=row){this._mouseHoverRow=row;this.doRowMouseHover(e,true);}} if(!this.get_wordWrap()){this._handleNoWrapTextHint(e,this._rowsTable);}},_internalSetRowState:function(row){row.setAttribute("_state","1");},_initRowCommandColumns:function(row){var commandColumns=this._commandColumns;for(var i=0,count=commandColumns.length;i<count;i++){var column=commandColumns[i];var cell=this._getRowCell(row,column.get_index());column.initCellEvent(this._getRowIndex(row),cell);}},_rowsMouseOut:function(e){var row=this._getEventTargetRow(e);if(row){this._setRowStyle(row,0);if(this._rowDeleteColumn){this._rowDeleteColumn.doHover(row,false);} this._mouseHoverRow=null;this.doRowMouseHover(e,false);}},_handleNoWrapTextHint:function(e,tableElement){var target=e.target;var hint="";if(target.tagName=="DIV"){var parentNode=target.parentNode;if(parentNode&&parentNode.tagName=="TD"){var needHint=false;var tdWidth=parentNode.offsetWidth;if(Sys.Browser.isIE6){needHint=target.offsetWidth>tdWidth;} else{var calcWidthDiv=window.__calcWidthDiv;if(!calcWidthDiv){calcWidthDiv=window.__calcWidthDiv=$common.createDiv();calcWidthDiv.className="GridBodyCellText";var style=calcWidthDiv.style;style.position="absolute";style.left="0px";style.top="0px";style.visibility="hidden";document.body.appendChild(calcWidthDiv);} calcWidthDiv.innerHTML=target.innerHTML;needHint=calcWidthDiv.offsetWidth>tdWidth;} if(needHint){hint=target.innerHTML;if(hint){hint=hint.replace(/&nbsp;/g," ");}}}} tableElement.title=hint;},_footerMouseOver:function(e){this._handleNoWrapTextHint(e,this._footer);},get_mouseHoverTime:function(){return this._mouseHoverTime;},set_mouseHoverTime:function(value){this._mouseHoverTime=value;},_clearMouseHoverTimer:function(){if(this._mouseHoverTimer){this._mouseHoverTimer=null;window.clearTimeout(this._mouseHoverTimer);delete this._mouseHoverTimer;} this._mouseHoverTimerHandler=null;},_invokeRowMouseHoverHandler:function(){var handler=this.get_events().getHandler("rowMouseHover");if(handler){handler(this,this._gridMouseHoverEventArgs);} this._mouseHoverTimer=null;},doRowMouseHover:function(e,isHover){this._gridMouseHoverEventArgs=new Sys.UI.Controls.GridMouseHoverEventArgs(isHover,e.clientX,e.clientY);if(this._mouseHoverTime>0){if(isHover){if(!this._mouseHoverTimer){if(!this._mouseHoverTimerHandler){this._mouseHoverTimerHandler=Function.createDelegate(this,this._invokeRowMouseHoverHandler);} this._mouseHoverTimer=window.setTimeout(this._mouseHoverTimerHandler,this._mouseHoverTime);}} else{if(!this._mouseHoverTimer){this._invokeRowMouseHoverHandler();}}} else{this._invokeRowMouseHoverHandler();}},_rowsMouseDown:function(e){if(this._isResizing)return;if(!this.get_readOnly()){this._focusBody();} var row=this._getEventTargetRow(e);if(row){if(row!=this._selectedRow){this._setSelectedRow(row);} window.asyncCall(Function.createDelegate(this,function(){this._notifyFormFocusControl();}));} e.cancel();},_getCellColumnIndex:function(cell){var answer=cell._columnIndex;return typeof(answer)=="string"?parseInt(answer):answer;},_getCellColumn:function(cell){var columnIndex=this._getCellColumnIndex(cell);if(columnIndex>=0){return this.getColumnByIndex(columnIndex);} else{return null;}},_rowsDblClick:function(e){var row=this._selectedRow;if(!row){return;} if(!e||this._getEventTargetRow(e)==row){var ok=true;if(e){var td=this._getEventTargetCell(row,e);if(td){var column=this._getCellColumn(td);if(column){if(!this.get_readOnly()){if(column.get_immediateEditor()){ok=false;}} if(ok&&!column.get_isEditing()){column.doReadOnlyDblClick();}}}} else{var handler=this.get_events().getHandler("rowEnterPress");if(handler){handler(this);ok=false;}} if(ok){this.doRowDblClick();}}},add_rowEnterPress:function(handler){this.get_events().addHandler("rowEnterPress",handler);},remove_rowEnterPress:function(handler){this.get_events().removeHandler("rowEnterPress",handler);},doRowEnterPress:function(e){var handler=this.get_events().getHandler("rowEnterPress");if(handler){var eventArgs=new Sys.CancelEventArgs();var error=null;try{handler(this,eventArgs);} catch(ex){error=ex;} var cancel=eventArgs.get_cancel();if(cancel){e.cancel();} if(error){throw error;} return cancel;} else{return false;}},add_rowDblClick:function(handler){this.get_events().addHandler("rowDblClick",handler);},remove_rowDblClick:function(handler){this.get_events().removeHandler("rowDblClick",handler);},doRowDblClick:function(){var handler=this.get_events().getHandler("rowDblClick");if(handler){handler(this);}},get_selectedRowIndex:function(){return this._selectedRow?this._getRowIndex(this._selectedRow):-1;},set_selectedRowIndex:function(value){if(value>=0&&value<this.get_rowCount()){this._setSelectedRow(this._getRow(value));}},add_selectionChanged:function(handler,handlerOwner){return this.get_events().addHandler("selectionChanged",handler,handlerOwner);},remove_selectionChanged:function(handler){this.get_events().removeHandler("selectionChanged",handler);},doSelectionChanged:function(){var handler=this.get_events().getHandler("selectionChanged");if(handler){handler(this);}},get_selectedRowData:function(){return this._getRowDataByRowElement(this._selectedRow);},clearSelectedRowData:function(){var row=this._selectedRow;if(row){var rowIndex=this._getRowIndex(row);var data=this.get_dataController().clearRecord(rowIndex);this.modifySelectedRowData(data);}},_getRowDataByRowElement:function(row){if(row){var rowIndex=this._getRowIndex(row);return this.get_dataController().getRecord(rowIndex);} return null;},_checkShowImmediateEditor:function(row){if(this.get_readOnly()||this.get_isDisposed())return;for(var i=0,count=this.get_columnCount();i<count;i++){var column=this.getColumnByIndex(i);if(column.get_immediateEditor()){var cell=this._getRowCell(row,i);if(cell&&this._doCellBeginEdit(column,cell,row)){column._doShowEditor(cell,false);}}}},_setSelectedRow:function Sys$UI$Controls$Grid$_setSelectedRow(row,disableScrollToView){if(row&&!this._isRowSelectable(row)){return;} if(this._selectedRow==row){return;} if(this._selectedRow){if(!this.get_readOnly()){this._hideEditor();} this._doSelectionBeforeChanged();var oldSelected=this._selectedRow;this._selectedRow=row;this._setRowStyle(oldSelected,0);} else{this._selectedRow=row;} this._initSelectedRowStype();if(this._selectedRow){if(!disableScrollToView&&this.get_showScrollBar()){$common.scrollToView(this._selectedRow,this._body);} this.doSelectionChanged();var row=this._selectedRow;for(var i=0,count=this.get_columnCount();i<count;i++){var column=this.getColumnByIndex(i);if(column.get_immediateEditor()){var cell=this._getRowCell(row,i);this._doCellBeginEdit(column,cell,row);}}}},add_selectionBeforeChanged:function(handler){this.get_events().addHandler("selectionBeforeChanged",handler);},remove_selectionBeforeChanged:function(handler){this.get_events().removeHandler("selectionBeforeChanged",handler);},_doSelectionBeforeChanged:function(){var handler=this.get_events().getHandler("selectionBeforeChanged");if(handler){handler(this);}},_blurFormColumn:function(){var handler=this.get_events().getHandler("selectionBeforeChanged");if(handler){this._hideEditor();handler(this);}},add_pagerPageBeforeChanged:function(handler){this.get_events().addHandler("pagerPageBeforeChanged",handler);},remove_pagerPageBeforeChanged:function(handler){this.get_events().removeHandler("pagerPageBeforeChanged",handler);},_internalDoPagerPageBeforeChanged:function(){this._initLoadedItems();var handler=this.get_events().getHandler("pagerPageBeforeChanged");if(handler){var eventArgs=new Sys.CancelEventArgs();handler(this,eventArgs);return!eventArgs.get_cancel();} return true;},_initSelectedRowStype:function(){if(this._selectedRow){this._setRowStyle(this._selectedRow,2);}},_internalGetIsResizing:function(){return this._isResizing;},_internalSetIsResizing:function(value){this._isResizing=value;},get_activeColumn:function(){return this._activeColumn;},_rowsMouseUp:function(e){if(this._isResizing)return;var row=this._getEventTargetRow(e);if(row&&this._isRowSelectable(row)){if(row!=this._selectedRow){this._setSelectedRow(row);} var cell=this._getEventTargetCell(row,e);if(cell){if(!this.get_readOnly()){this._showEditor(cell);} var column=this._getCellColumn(cell);this._activeColumn=column;var multiSelectColumn=this._multiSelectColumn;if(multiSelectColumn&&column!=multiSelectColumn&&column.get_readOnly()&&multiSelectColumn.get_visible()&&multiSelectColumn.get_toggleByClickRow()){window.asyncCall(Function.createDelegate(this,function(){this._toggleSelectedRowSelected();}));} var handler=this.get_events().getHandler("rowClick");if(handler){var eventArgs=new Sys.UI.Controls.GridRowClickEventArgs(this._getRowIndex(row),column);handler(this,eventArgs);}}} e.cancel();},add_rowClick:function(handler){this.get_events().addHandler("rowClick",handler);},remove_rowClick:function(handler){this.get_events().removeHandler("rowClick",handler);},get_pageSize:function(){return this._pageSize;},set_pageSize:function(value){this._pageSize=value;},_focusRowsTable:function(){var elt=this._rowsTable;window.asyncCall(function(){try{elt.focus();} catch(e){}});},_rowsKeyDown:function(e){var k=e.keyCode;var readOnly=this.get_readOnly();var selectedRow=this._selectedRow;var editing=!readOnly&&selectedRow;var oldIndex=selectedRow?this._getRowIndex(selectedRow):-1;var rowCount=this.get_rowCount();var recordCount=this.get_recordCount();var newIndex=oldIndex;var pager=this.findPager();var result=false;switch(k){case Sys.UI.Key.left:break;case Sys.UI.Key.right:break;case Sys.UI.Key.enter:if(editing){if(!this.doRowEnterPress(e)){if(!this._hasEditor()){this._focusRowFirstCell(selectedRow);}}} else{this._rowsDblClick();} result=true;break;case Sys.UI.Key.esc:if(editing&&this._hasEditor()){this._exitEdit();result=false;} break;case Sys.UI.Key.up:if(oldIndex>=0){newIndex=oldIndex-1;} break;case Sys.UI.Key.down:if(oldIndex>=0){newIndex=oldIndex+1;} break;case Sys.UI.Key.pageUp:if(pager){pager.prevPage();result=true;} else if(oldIndex>=0){newIndex=oldIndex-this.get_pageSize();if(editing&&newIndex<0){newIndex=0;}} break;case Sys.UI.Key.pageDown:if(pager){pager.nextPage();result=true;} else if(oldIndex>=0){newIndex=oldIndex+this.get_pageSize();if(editing&&newIndex>=recordCount){newIndex=recordCount-1;}} break;case Sys.UI.Key.home:if(pager){pager.firstPage();result=true;} else if(readOnly){newIndex=0;} break;case Sys.UI.Key.end:if(pager){pager.lastPage();result=true;} else if(readOnly){newIndex=recordCount-1;} break;case Sys.UI.Key.del:if(e.ctrlKey||e.altKey||e.shiftKey){var canDelete=!this.get_readOnly()&&!this.get_modifyOnly();if(canDelete){this._checkDeleteSelectedRow();this.focus();result=true;}} break;case Sys.UI.Key.space:var multiSelectColumn=this._multiSelectColumn;if(multiSelectColumn){if(selectedRow){e.cancel();this._toggleSelectedRowSelected();} result=true;} break;} if(newIndex!=oldIndex){if(oldIndex<0){newIndex=0;} if(newIndex>=0&&newIndex<rowCount){var editingColumnIndex=-1;if(editing){editingColumnIndex=this._getEditingColumnIndex();} var row=this._getRow(newIndex);this._setSelectedRow(row);if(editingColumnIndex<0&&this._multiSelectColumn){editingColumnIndex=this._multiSelectColumn.get_index();} if(editingColumnIndex>=0){this._focusRowCellWrap(row,editingColumnIndex);} result=true;} else if(!result){if(pager){if(newIndex<0){pager.prevPage();result=true;} else if(newIndex>=recordCount){pager.nextPage();result=true;}}}} if(result){e.cancel();} else{this.doRowKeyDown(e);}},_exitEdit:function(){this._hideEditor();this._initSelectedRowStype();this._focusRowsTable();},add_rowKeyDown:function(handler,handlerOwner){this.get_events().addHandler("rowKeyDown",handler,handlerOwner);},remove_rowKeyDown:function(handler){this.get_events().removeHandler("rowKeyDown",handler);},doRowKeyDown:function(e){var handler=this.get_events().getHandler("rowKeyDown");var keyCode=e.keyCode;if(handler&&(keyCode==Sys.UI.Key.left||keyCode==Sys.UI.Key.right)){handler(this,e);e.cancel();return true;} return false;},_rowsMouseWheel:function(e){var keyCode=0;var wheelDelta=e.rawEvent.wheelDelta;if(wheelDelta>0){keyCode=Sys.UI.Key.up;} else if(wheelDelta<0){keyCode=Sys.UI.Key.down;} if(keyCode>0){e.keyCode=keyCode;this._rowsKeyDown(e);}},_rowsContextMenu:function(e){e.cancel();var handler=this.get_events().getHandler("contextMenu");if(handler){var eventArgs=new Sys.CancelEventArgs();handler(this,eventArgs);if(eventArgs.get_cancel()){return;}} var row=this._selectedRow;var popupMenu=this.get_popupMenu();if(row&&popupMenu){this.get_form()[popupMenu].popup(e);}},add_contextMenu:function(handler,handlerOwner){this.get_events().addHandler("contextMenu",handler,handlerOwner);},remove_contextMenu:function(handler){this.get_events().removeHandler("contextMenu",handler);},focusSelectedRowColumn:function(column){this._focusRowsTable();this._focusRowColumn(this._selectedRow,column);},focusRowColumn:function(rowIndex,column){this._focusRowColumn(this._getRow(rowIndex),column);},focusNextRowColumn:function(column){var row=this._selectedRow;if(row){var nextRow=this._getNextRow(row);if(nextRow){this._setSelectedRow(nextRow);column=this._internalGetColumn(column);this._focusRowCell(nextRow,column.get_index());}}},_focusRowColumn:function(row,column){if(row){column=this._internalGetColumn(column);var columnIndex=column.get_index();if(!this._focusRowCell(row,columnIndex)){var nextRow=this._getNextRow(row);if(nextRow){this._setSelectedRow(nextRow);this._focusRowCell(nextRow,columnIndex);}}}},_focusNextCell:function(column,thisCell){var row=thisCell?thisCell.parentNode:this._selectedRow;var next=column.get_index()+1;this._focusRowCellOrNextRow(row,next);},_focusRowCellOrNextRow:function(row,columnIndex){if(!this._focusRowCell(row,columnIndex)){var nextRow=this._getNextRow(row);if(nextRow){this._setSelectedRow(nextRow);this._focusRowCell(nextRow,0);} else{this.endEdit();}}},_getNextRow:function(row){var theRowCount=this.get_rowCount();var canAppend=!this.get_modifyOnly();var rowCount=canAppend?theRowCount:this.get_recordCount();var nextRow=null;var rowIndex=this._getRowIndex(row);if(rowIndex<rowCount-1){nextRow=this._getRow(rowIndex+1);} else if(canAppend){var maxRowCount=this.get_maxRowCount();if(maxRowCount==0||theRowCount<maxRowCount){nextRow=this._appendRow();} else if(rowCount>0){nextRow=this._getRow(0);}} return nextRow;},checkCanAppend:function(){var theRowCount=this.get_recordCount();var maxRowCount=this.get_maxRowCount();if(maxRowCount>0&&theRowCount>=maxRowCount){$common.alert("已达到最大数据行数 "+maxRowCount);throw Error.abort();}},_focusPrevCell:function Sys$UI$Controls$Grid$_focusPrevCell(thisCell){var row=thisCell.parentNode;var prev=this._getCellColumnIndex(thisCell)-1;if(!this._focusRowCell(row,prev,true)){var newRow=null;var rowIndex=this._getRowIndex(row);if(rowIndex>0){newRow=this._getRow(rowIndex-1);} if(newRow){this._setSelectedRow(newRow);this._focusRowCell(newRow,this.get_columnCount()-1,true);} else{this.focusPrevControl();}} return true;},_focusRowCell:function Sys$UI$Controls$Grid$_focusRowCell(row,startCellIndex,prevMode){if(!this._isRowSelectable(row)){return true;} if(!prevMode){return this._doFocusRowCellNext(row,startCellIndex,this.get_columnCount()-1);} else{var firstCellIndex=this._getFirstColumnCellIndex();for(var i=startCellIndex;i>=0;i--){var cell=row.childNodes[firstCellIndex+i];if(this._showEditor(cell,true)){return true;}} return false;}},_focusRowCellWrap:function Sys$UI$Controls$Grid$_focusRowCellWrap(row,startCellIndex){if(!this._isRowSelectable(row)){return true;} var ok=this._doFocusRowCellNext(row,startCellIndex,this.get_columnCount()-1);if(!ok&&startCellIndex>0){ok=this._doFocusRowCellNext(row,0,startCellIndex-1);} return ok;},_doFocusRowCellNext:function Sys$UI$Controls$Grid$_doFocusRowCell(row,startCellIndex,endCellIndex){var firstCellIndex=this._getFirstColumnCellIndex();for(var i=startCellIndex;i<=endCellIndex;i++){var cell=row.childNodes[firstCellIndex+i];if(this._showEditor(cell,true)){return true;}} return false;},_focusRowFirstCell:function Sys$UI$Controls$Grid$_focusRowFirstCell(row){return this._focusRowCell(row,0);},_internalFocusSelectedRowFirstCell:function(){if(this._multiSelectColumn){return false;} var selectedRow=this._selectedRow;if(selectedRow){return this._focusRowCell(selectedRow,0);}},_internalFocusSelectedRowLastCell:function(){if(this._multiSelectColumn){return false;} var selectedRow=this._selectedRow;if(selectedRow){return this._focusRowCell(selectedRow,this.get_columnCount()-1,true);}},_hideNonImmediateEditor:function(){var columnCount=this.get_columnCount();for(var i=0;i<columnCount;i++){var column=this.getColumnByIndex(i);if(!column.get_immediateEditor()){column._hideEditor();}}},add_cellBeginEdit:function(handler){this.get_events().addHandler("cellBeginEdit",handler);},remove_cellBeginEdit:function(handler){this.get_events().removeHandler("cellBeginEdit",handler);},add_cellRendering:function(handler,handlerOwner){return this.get_events().addHandler("cellRendering",handler,handlerOwner);},remove_cellRendering:function(handler){this.get_events().removeHandler("cellRendering",handler);},_doCellBeginEdit:function(column,cell,row){if(!row){row=cell.parentNode;} var rowIndex=this._getRowIndex(row);var rowsEnabled=this._rowsEnabled;if(rowsEnabled){var enabled=rowsEnabled[rowIndex];if(typeof(enabled)!="undefined"&&!enabled){return false;}} if(column.getEditable){if(!column.getEditable(cell)){return false;}} var handler=this.get_events().getHandler("cellBeginEdit");if(handler){var eventArgs=new Sys.UI.Controls.GridCellBeginEditEventArgs(rowIndex,column.get_index(),column);handler(this,eventArgs);var editable=!eventArgs.get_cancel();if(column.setEditable){column.setEditable(editable,cell);} return editable;} return true;},getSelectedRowColumnAllowEdit:function(sender){var column=sender.column;if(!column)column=sender;if(!column.get_enabled()||column.get_readOnly()){return false;} var cell=this._getSelectedRowCell(column.get_index());return cell?this._doCellBeginEdit(column,cell):false;},add_focusedColumnChanged:function(handler){this.get_events().addHandler("focusedColumnChanged",handler);},remove_focusedColumnChanged:function(handler){this.get_events().removeHandler("focusedColumnChanged",handler);},_showEditor:function Sys$UI$Controls$Grid$_showEditor(cell,checkTabStop){var columnIndex=this._getCellColumnIndex(cell);var column=this.getColumnByIndex(columnIndex);if(!column.get_visible()||column.get_readOnly()||(checkTabStop&&!column.get_tabStop())){return false;} else{if(this._activeCell!=cell){this._hideNonImmediateEditor();} if(!this._doCellBeginEdit(column,cell)){return false;} column._showEditor(cell);this._activeCell=cell;if(this._focusedColumn!=column){this._focusedColumn=column;var handler=this.get_events().getHandler("focusedColumnChanged");if(handler){handler(this);}} return true;}},_hasEditor:function(){var columnCount=this.get_columnCount();for(var i=0;i<columnCount;i++){var column=this.getColumnByIndex(i);if(column&&column._hasEditor()){return true;}} return false;},_getEditingColumnIndex:function(){var column=this.get_focusedColumn();return column?column.get_index():-1;},get_focusedColumn:function(){var columnCount=this.get_columnCount();for(var i=0;i<columnCount;i++){var column=this.getColumnByIndex(i);if(column.get_isEditing()){return column;}} return null;},endEdit:function Sys$UI$Controls$Grid$endEdit(){this._hideEditor();},_postEditValue:function(){this._hideEditor();if(this._selectedRow){this._doSelectionBeforeChanged();}},_hideEditor:function Sys$UI$Controls$Grid$_hideEditor(clearChangedFirst){var columnCount=this.get_columnCount();for(var i=0;i<columnCount;i++){var column=this.getColumnByIndex(i);if(clearChangedFirst){column._clearChanged();} column._hideEditor();} var row=this._selectedRow;if(row){row.style.height="";}},_getFirstColumnCellIndex:function(){return this.get_showRowNo()?1:0;},_getSelectedRowCell:function(columnIndex){return this._getRowCell(this._selectedRow,columnIndex);},_getRowCell:function(row,columnIndex){if(row){var firstCellIndex=this._getFirstColumnCellIndex();var index=firstCellIndex+columnIndex;if(index>=0&&index<row.childNodes.length){return row.childNodes[index];}} return null;},_setRowStyle:function(row,type){var rowIndex=this._getRowIndex(row);var columnCount=this.get_columnCount();var firstCellIndex=this._getFirstColumnCellIndex();var customRendering=(rowIndex<this.get_recordCount())||this._useCustomRendering;var cellRenderingHandler=customRendering?this.get_events().getHandler("cellRendering"):null;var rowCells=row.childNodes;var isSelected=((type==2)||(row==this._selectedRow))&&!this.get_hideSelection();for(var i=0,j=firstCellIndex;i<columnCount;i++,j++){var cell=rowCells[j];this._setCellStyleFast(rowIndex,i,cell,isSelected,type,customRendering,cellRenderingHandler);}},_initCellStyle:function(columnIndex,cell){var row=cell.parentNode;var isSelected=row==this._selectedRow;var cellRenderingHandler=this.get_events().getHandler("cellRendering");this._setCellStyleFast(this._getRowIndex(row),columnIndex,cell,isSelected,0,true,cellRenderingHandler);},_setCellStyleFast:function Sys$UI$Controls$Grid$_setCellStyleFast(rowIndex,columnIndex,cell,isSelected,type,customRendering,cellRenderingHandler){var column=this.getColumnByIndex(columnIndex);var colors=this._getCellStyleFast(rowIndex,column,columnIndex,isSelected,type,customRendering,cellRenderingHandler,cell);cell.style.color=colors.fontColor;cell.style.backgroundColor=colors.bgColor;},get_useEvenRowColor:function(){return this._useEvenRowColor;},set_useEvenRowColor:function(value){this._useEvenRowColor=value;},get_useMultiRowCaption:function(){return this._useMultiRowCaption;},set_useMultiRowCaption:function(value){this._useMultiRowCaption=value;},get_useCustomRendering:function(){return this._useCustomRendering;},set_useCustomRendering:function(value){this._useCustomRendering=value;},_getCellStyleFast:function(rowIndex,column,columnIndex,isSelected,type,customRendering,cellRenderingHandler,cell){var skinColors=this._skinColors;var fontColor,bgColor;if(!customRendering){customRendering=this._useCustomRendering;} if(!column.get_enabled()){fontColor=skinColors.disabledText;bgColor=skinColors.disabledBg;} else if(isSelected){fontColor=skinColors.selectedText;bgColor=skinColors.selectedBg;var newFontColor=null;if(cell&&cell._fontColor){newFontColor=cell._fontColor;} if(customRendering&&cellRenderingHandler){var eventArgs=new Sys.UI.Controls.GridCellRenderingEventArgs(rowIndex,columnIndex,column);cellRenderingHandler(this,eventArgs);newFontColor=eventArgs.get_fontColor();} if(newFontColor){fontColor=this._inverseColor(newFontColor);}} else if(type==0){if((this.get_readOnly()||this.get_modifyOnly())&&this.get_useEvenRowColor()){var isEven=rowIndex%2==1;if(isEven){fontColor=skinColors.evenText;bgColor=skinColors.evenBg;} else{fontColor=skinColors.normalText;bgColor=skinColors.normalBg;}} else{fontColor=skinColors.normalText;bgColor=skinColors.normalBg;} if(cell){if(cell._fontColor){fontColor=cell._fontColor;} if(cell._bgColor){bgColor=cell._bgColor;}} if(customRendering&&cellRenderingHandler){var eventArgs=new Sys.UI.Controls.GridCellRenderingEventArgs(rowIndex,columnIndex,column);cellRenderingHandler(this,eventArgs);var newFontColor=eventArgs.get_fontColor();if(newFontColor){fontColor=newFontColor;} var newBgColor=eventArgs.get_bgColor();if(newBgColor){bgColor=newBgColor;}}} else if(type==1){fontColor=skinColors.hoverText;bgColor=skinColors.hoverBg;if(cell&&cell._columnBgColor){bgColor=cell._columnBgColor;} if(customRendering&&cellRenderingHandler){var eventArgs=new Sys.UI.Controls.GridCellRenderingEventArgs(rowIndex,columnIndex,column);cellRenderingHandler(this,eventArgs);var newFontColor=eventArgs.get_fontColor();if(newFontColor){fontColor=newFontColor;}}} return{"fontColor":fontColor,"bgColor":bgColor};},_colorMap:{"red":"#ff0000","green":"#008000","blue":"#0000ff"},_inverseColor:function(color){if(color){var ok=color.length==7&&color.charAt(0)=='#';if(!ok){var newColor=this._colorMap[color];if(newColor){color=newColor;ok=true;}} if(ok){color=color.substring(1,7);color="00000"+(0xffffff-parseInt(color,16)).toString(16);color="#"+color.substr(color.length-6,6);}} return color;},get_recordCount:function(){return this.get_dataController().get_recordCount();},_isRowSelectable:function(row){return this._isRowSelectableByIndex(this._getRowIndex(row));},_isRowSelectableByIndex:function(rowIndex){if(this.get_readOnly()||this.get_modifyOnly()){return rowIndex<this.get_recordCount();} else{return true;}},add_getRowNo:function(handler,handlerOwner){return this.get_events().addHandler("getRowNo",handler,handlerOwner);},remove_getRowNo:function(handler){this.get_events().removeHandler("getRowNo",handler);},_initRowNo:function(row,rowIndex){if(this.get_showRowNo()){var getRowNoHandler=this.get_events().getHandler("getRowNo");this._initRowNoFast(row,rowIndex,getRowNoHandler);}},_initRowNoFast:function(row,rowIndex,getRowNoHandler){var html=this._getRowNoHTMLFast(rowIndex,getRowNoHandler);row.childNodes[0].innerHTML=html;},_getRowNoHTMLFast:function(rowIndex,getRowNoHandler){var dataRowIndex=this._dataRowFirst+rowIndex;var rowNo;if(this._isRowSelectableByIndex(rowIndex)){rowNo=dataRowIndex+1;if(getRowNoHandler&&rowIndex<this.get_recordCount()){var eventArgs=new Sys.UI.Controls.GridGetRowNoEventArgs(rowNo,this.getRowData(rowIndex));getRowNoHandler(this,eventArgs);rowNo=eventArgs.get_rowNo();}} else{rowNo="&nbsp;";} return"<div class=\"GridBodyRowNoCellText\">"+rowNo+"</div>";},selectedRowColumnDataChanged:function(column){this._notifyColumnDataChanged(this._selectedRow,column);},_internalGetColumn:function(column){if(typeof(column)=="string"){column=this.getColumn(column);} return column;},_notifyColumnDataChanged:function(row,column){column=this._internalGetColumn(column);var cell=this._getRowCell(row,column.get_index());if(cell){column._hideEditor();column.initCellHTML(this._getRowIndex(row),cell);}},_initRowData:function(row,rowIndex){var showRowNo=this.get_showRowNo();var getRowNoHandler=showRowNo?this.get_events().getHandler("getRowNo"):null;var hasData=this.get_dataController().get_hasRecord();var columnCount=this.get_columnCount();var firstCellIndex=this._getFirstColumnCellIndex();if(showRowNo){this._initRowNoFast(row,rowIndex,getRowNoHandler);} var columns=this._columns;var cells=row.childNodes;for(var i=0,j=firstCellIndex;i<columnCount;i++,j++){var cell=cells[j];if(hasData){var column=columns[i];column.initCellHTML(rowIndex,cell);} else{cell.innerHTML="&nbsp;";}} if(!hasData&&this._rowDeleteColumn){this._rowDeleteColumn.doInit(row,rowIndex);}},_checkRowIndex:function(rowIndex){var count=this.get_rowCount();if(rowIndex<0||rowIndex>=count){throw Error.invalidOperation(String.format("行索引范围应为 [0-{0}]",count-1));}},_checkColumnIndex:function(columnIndex){var count=this.get_columnCount();if(columnIndex<-1||columnIndex>=count){throw Error.invalidOperation(String.format("列索引范围应为 -1 或 [0-{0}]",count-1));}},setCellText:function(rowIndex,columnIndex,text){this._checkRowIndex(rowIndex);this._checkColumnIndex(columnIndex);var row=this._getRow(rowIndex);var cellIndex;if(columnIndex<0){cellIndex=this.get_showRowNo()?0:-1;} else{cellIndex=this._getFirstColumnCellIndex()+columnIndex;} if(cellIndex>=0){var cell=row.childNodes[cellIndex];cell.innerHTML=Sys.UI.Controls.Column.getHTML(text);if(columnIndex>=0){this._initCellStyle(columnIndex,cell);}}},_getAllColumnWidth:function(){var width=0;var count=this.get_columnCount();for(var i=0;i<count;i++){var column=this.getColumnByIndex(i);if(column.get_visible()){var columnWidth=column.get_width();width+=columnWidth+1;}} return width+1+(this.get_showRowNo()?this._rowNoColumnWidth+1:0);},get_dataController:function(){if(!this._dataController){this._dataController=new Sys.UI.Controls.GridObjectDataController(this,this._dataSource);this._dataController.initialize();} return this._dataController;},get_guid:function(){return this._guid;},set_guid:function(value){this._guid=value;},get_label:function(){return this._label;},set_label:function(value){this._label=value;},get_tag:function(){return this._tag;},set_tag:function(value){this._tag=value;},get_readOnly:function(){return this._readOnly;},set_readOnly:function(value){if(this._readOnly!=value){this._readOnly=value;if(this.get_isInitialized()){if(value){this._hideEditor();} this._refreshRowNo(true);}}},get_modifyOnly:function(){return this._modifyOnly;},set_modifyOnly:function(value){if(this._modifyOnly!=value){this._modifyOnly=value;if(this.get_isInitialized()){this._refreshRowNo();}}},get_showHeader:function(){return this._showHeader;},set_showHeader:function(value){this._showHeader=value;},get_maxHeaderLevel:function(){return this._maxHeaderLevel;},set_maxHeaderLevel:function(value){this._maxHeaderLevel=value;},get_showFooter:function(){return this._showFooter;},set_showFooter:function(value){this._showFooter=value;},get_showRowNo:function(){return this._showRowNo;},set_showRowNo:function(value){this._showRowNo=value;},get_showLines:function(){return this._showLines;},set_showLines:function(value){this._showLines=value;},get_hideSelection:function(){return this._hideSelection;},set_hideSelection:function(value){this._hideSelection=value;},get_allowCopy:function(){return this._allowCopy;},set_allowCopy:function(value){this._allowCopy=value;},get_allowSort:function(){return this._allowSort;},set_allowSort:function(value){if(this._allowSort!=value){if(this.get_isInitialized()){if(!value){this.clearSortFlag();} this._allowSort=value;this._reinitColumnsHeader();} else{this._allowSort=value;}}},get_allowResize:function(){return this._allowResize;},set_allowResize:function(value){if(this._allowResize!=value){this._allowResize=value;if(this.get_isInitialized()){this._reinitColumnsHeader();}}},_reinitColumnsHeader:function(){for(var i=0,count=this.get_columnCount();i<count;i++){var column=this.getColumnByIndex(i);column._internalInitHeader();}},get_showScrollBar:function(){return this._showScrollBar;},set_showScrollBar:function(value){this._showScrollBar=value;},get_showHScrollBar:function(){return this._showHScrollBar;},set_showHScrollBar:function(value){this._showHScrollBar=value;},get_allColumnWidth:function(){return this._allColumnWidth;},set_allColumnWidth:function(value){this._allColumnWidth=value;},get_defaultRowCount:function(){return this._defaultRowCount;},set_defaultRowCount:function(value){this._defaultRowCount=value;},get_maxRowCount:function(){var answer=this._maxRowCount;return answer>=0?answer:this.get_defaultRowCount();},set_maxRowCount:function(value){this._maxRowCount=value;},get_textColor:function(){return this._textColor;},set_textColor:function(value){this._textColor=value;},get_popupMenu:function(){return this._popupMenu;},set_popupMenu:function(value){this._popupMenu=value;},get_needRowIndex:function(){return this._needRowIndex;},set_needRowIndex:function(value){this._needRowIndex=value;},get_wordWrap:function(){return this._wordWrap;},set_wordWrap:function(value){this._wordWrap=value;},get_columnsParams:function(){return this._columnsParams;},set_columnsParams:function(value){this._columnsParams=value;},_checkHasMultiSelectColumn:function(){var multiSelectColumn=this._multiSelectColumn;if(!multiSelectColumn){throw Error.invalidOperation("Grid没有选择列！");} return multiSelectColumn.get_dataField();},get_selectedItems:function(){this._checkHasMultiSelectColumn();this._initLoadedItems();var value=new Array(this._loadedItems.length);var count=0;var needRowIndex=this.get_needRowIndex();for(var i=0;i<value.length;i++){var item=this._loadedItems[i];if(item&&item.selected){value[count]=item.data;if(needRowIndex){item.data.__rowIndex=i;} count++;}} value.length=count;return value;},deleteSelectedItems:function(){var selectedItems=this.get_selectedItems();var pager=this.findPager();if(!pager){for(var i=0;i<selectedItems.length;i++){this.deleteRow(selectedItems[i].recordIndex);}} else{var remainItemCount=pager.get_itemCount()-selectedItems.length;var pageIndex=pager.get_pageIndex();var pageSize=pager.get_pageSize();for(;(remainItemCount<pageSize*pageIndex+1)&&pageIndex>0;pageIndex--);pager.reloadPage(pageIndex);}},add_getLoadedItems:function(handler){this.get_events().addHandler("getLoadedItems",handler);},remove_getLoadedItems:function(handler){this.get_events().removeHandler("getLoadedItems",handler);},_internalSetNeedPreloadItems:function(value){this._needPreloadItems=value;},_getPagerPreloadItemDecimalField:function(pager){var preloadItemFields=pager.get_preloadItemFields();if(preloadItemFields){var fields=preloadItemFields.split(',');return fields[fields.length-1].trim();} return null;},_doGetLoadedItems:function(getAllItems){var answer=this._loadedItems;var pager=this.findPager();var handler=this.get_events().getHandler("getLoadedItems");if(answer&&pager&&(handler||this._needPreloadItems)){answer=Array.clone(this._loadedItems);var decimalField=this._getPagerPreloadItemDecimalField(pager);if(this._needPreloadItems){var preloadItems=this._preloadItems;if(!preloadItems){preloadItems=this._preloadItems=pager._internalGetPreloadItems();} for(var i=0,count=preloadItems.length;i<count;i++){var preloadItem=preloadItems[i];var rowIndex=preloadItem["__rowIndex"];if(!answer[rowIndex]){var record={};record.data=preloadItem;answer[rowIndex]=record;}}} if(handler){var eventArgs=new Sys.UI.Controls.GridGetLoadedItemsEventArgs(answer,pager.get_itemCount(),decimalField);handler(this,eventArgs);} if(getAllItems&&decimalField){var count=answer.length;for(var i=count-1;i>=0;i--){var preloadItem=answer[i];if(preloadItem&&preloadItem.data&&preloadItem.data[decimalField]==null){answer[i]=null;}}}} return answer;},get_allItems:function(){if(!this._loadedItems){this._loadedItems=[];} if(!this._needPreloadItems){this._needPreloadItems=true;} return this._getLoadedOrAllItems(true);},resetLoadedItems:function(){var loadedItems=this._loadedItems;if(!loadedItems)return;for(var i=0,count=loadedItems.length;i<count;i++){var item=loadedItems[i];if(item&&item.__isLoadedItem){delete item.__isLoadedItem;}}},get_loadedItems:function(){return this._getLoadedOrAllItems(false);},_getLoadedOrAllItems:function(getAllItems){if(!this._initLoadedItems())return null;var loadedItems=this._doGetLoadedItems(getAllItems);var value=new Array(loadedItems.length);var count=0;var needRowIndex=this.get_needRowIndex();for(var i=0,count0=value.length;i<count0;i++){var item=loadedItems[i];if(item&&item.data){if(needRowIndex){item.data.__rowIndex=i;} value[count]=item.data;count++;}} value.length=count;return value;},_toggleSelectedRowSelected:function(){var rowIndex=this.get_selectedRowIndex();if(this.getRowEnabled(rowIndex)){var oldValue=this.getRowSelected(rowIndex);var newValue=!oldValue;this.setRowSelected(rowIndex,newValue);var multiSelectColumn=this._multiSelectColumn;multiSelectColumn.set_value(newValue);multiSelectColumn._raiseChange(null,newValue,oldValue);}},getSelectedRowSelected:function(){return this.getRowSelected(this.get_selectedRowIndex());},setSelectedRowSelected:function(selected){this.setRowSelected(this.get_selectedRowIndex(),selected);},getRowSelected:function(rowIndex){this._checkRowIndex(rowIndex);var dataField=this._checkHasMultiSelectColumn();return this.getRowData(rowIndex)[dataField];},setRowSelected:function(rowIndex,selected){var dataField=this._checkHasMultiSelectColumn();this._doSetRowSelected(rowIndex,selected,dataField);},getRowEnabled:function(rowIndex){var rowsEnabled=this._rowsEnabled;if(!rowsEnabled){return true;} var answer=rowsEnabled[rowIndex];return typeof(answer)=="undefined"?true:answer;},setRowEnabled:function(rowIndex,enabled){this._checkRowIndex(rowIndex);var multiSelectColumn=this._multiSelectColumn;if(multiSelectColumn){var row=this._getRow(rowIndex);var cellIndex=this._getFirstColumnCellIndex()+multiSelectColumn.get_index();var cell=row.childNodes[cellIndex];if(cell){var checkBox=cell.firstChild;if(checkBox){checkBox.disabled=!enabled;}}} var rowsEnabled=this._rowsEnabled;if(!rowsEnabled){rowsEnabled=this._rowsEnabled=[];} rowsEnabled[rowIndex]=enabled;},_doSetRowSelected:function(rowIndex,selected,dataField){var rowData=this.getRowData(rowIndex);if(rowData){rowData[dataField]=selected;this.modifyRowData(rowIndex,rowData);}},_doSelectAll:function(selected){var dataField=this._checkHasMultiSelectColumn();var count=this.get_recordCount();for(var i=0;i<count;i++){if(this.getRowEnabled(i)){this._doSetRowSelected(i,selected,dataField);}}},selectAll:function(){this._doSelectAll(true);},deselectAll:function(){this._doSelectAll(false);},get_configID:function(){return this._configID;},set_configID:function(value){this._configID=value;},get_bands:function(){return this._bands;},set_bands:function(value){this._bands=value;},get_dataField:function(){return this._dataField;},set_dataField:function(value){this._dataField=value;},get_dataSource:function(){return this._dataSource;},set_dataSource:function(value){var supportsObjProp=true;if(value&&value.dataType&&value.dataType==1){supportsObjProp=false;var fields=value.fields;var fieldCount=fields.length;var columnsParams=this._columnsParams;if(columnsParams){var columnCount=columnsParams.length;for(var i=0;i<columnCount;i++){var props=columnsParams[i].properties;var dataField=props.dataField;if(dataField&&Array.indexOf(fields,dataField)<0){props.dataField=dataField.toLowerCase();}} var fieldSizes=value.fieldSizes;if(fieldSizes){var fieldSizeMap=new Object();for(var i=0;i<fieldCount;i++){fieldSizeMap[fields[i]]=fieldSizes[i];} for(var i=0;i<columnCount;i++){var props=columnsParams[i].properties;var dataField=props.dataField;if(dataField){var fieldSize=fieldSizeMap[dataField];if(fieldSize>0){props.dataSize=fieldSize;}}}}} var rows=value.rows;var rowCount=rows.length;var recordList=new Array(rowCount);for(var i=0;i<rowCount;i++){var row=rows[i];var record=new Object();for(var j=0;j<fieldCount;j++){record[fields[j]]=row[j];} recordList[i]=record;} delete value;value=recordList;} if(this._dataSource!=value){this._doBeforeDataSourceChanged();} this._dataSource=value;var dataController=this.get_dataController();if(dataController){dataController.set_supportsObjProp(supportsObjProp);dataController.clearEditBuffer();}},get_columnExpands:function(){return this._columnExpands;},set_columnExpands:function(value){this._columnExpands=value;if(this.get_isInitialized()){this._initColumnExpands();}},get_cellMergeItems:function(){return this._cellMergeItems;},set_cellMergeItems:function(value){if(this.get_isInitialized()&&this._cellMergeItems){this._beforeInitCellMerge();} this._cellMergeItems=value;},_doBeforeDataSourceChanged:function(){this._setSelectedRow(null);this._dataSourceChanging=true;},get_pagerId:function(){return this._pagerId;},set_pagerId:function(value){this._pagerId=value;},get_pagerClientId:function(){var pager=this.findPager();return pager?pager.get_id():null;},findPager:function(){var pagerId=this.get_pagerId();return pagerId?this.get_form()[pagerId]:null;},get_pager:function(){var pager=this.findPager();if(!pager){throw Error.invalidOperation("找不到Grid的默认Pager："+this.get_pagerId());} return pager;},dataBind:function(data){var oldIsEmpty=this.get_recordCount()==0;var dataField=this._dataField;var value=null,hasValue=false;if(typeof(data)!="undefined"){value=data;hasValue=true;} else if(dataField){var dataController=this.get_form().get_dataController();value=dataController.getValue(dataField);hasValue=true;} if(hasValue){this.set_dataSource(value);var newIsEmpty=!value||value.length==0;if(oldIsEmpty&&newIsEmpty){this.get_dataController()._dataSource=this._dataSource;} else{this.dataChanged();}} if(this.get_allowSort()&&dataField){this.clearSortFlag();}},clear:function(){this.dataBind(null);},doSaveData:function Sys$UI$Controls$Grid$doSaveData(ignoreValidation){if(this._dataField){this._internalSaveData(ignoreValidation);}},_internalSaveData:function(ignoreValidation){if(this.get_readOnly()){return null;} this._postEditValue();var data=this.get_dataController().save();var dataField=this._dataField;if(dataField){var dataController=this.get_form().get_dataController();dataController.setValue(dataField,data);} if(!ignoreValidation){this._validate(data);} return data;},saveData:function(ignoreValidation){var form=this.get_form();form.setValidationControl(this);var data=this._internalSaveData(ignoreValidation);form.get_validationManager().checkResults();return data;},_validate:function(data){var validationManager=this.get_form().get_validationManager();var _label=this.get_label();if(!_label){_label="明细";} var detailValidationNode=validationManager.validate(this._dataField,data,_label,null,this);if(detailValidationNode&&validationManager.get_isValid()){var rowCount=data.length;var columnCount=this.get_columnCount();var dataHasRowIndex=this.get_needRowIndex();for(var i=0;i<rowCount;i++){var rowIndex=dataHasRowIndex?data[i].__rowIndex:i;for(var columnIndex=0;columnIndex<columnCount;columnIndex++){this._doValidateColumnByIndex(validationManager,detailValidationNode,rowIndex,columnIndex);} if(!validationManager.get_isValid()){this.set_selectedRowIndex(rowIndex);break;}}}},_doValidateColumnByIndex:function(validationManager,detailValidationNode,rowIndex,columnIndex){var column=this.getColumnByIndex(columnIndex);var value=this.get_dataController().getCellValue(rowIndex,column);this._doValidateColumn(validationManager,detailValidationNode,rowIndex,column,value);},_doValidateColumn:function(validationManager,detailValidationNode,rowIndex,column,value){var dataField=column.get_dataField();if(dataField){var _label=column.get_caption();var rowName="第"+(rowIndex+1)+"行 ";validationManager.validate(dataField,value,_label,rowName,this,detailValidationNode);}},_validateColumn:function(rowIndex,column,value){var validationManager=this.get_form().get_validationManager();var detailValidationNode=validationManager.getChildValidationNode(this._dataField);this._doValidateColumn(validationManager,detailValidationNode,rowIndex,column,value);},dataChanged:function(){if(!this.get_isInitialized()||!this.get_visible())return;this.get_dataController()._dataSource=this._dataSource;this._initDataRows();if(this._body.scrollLeft>0||(this._headerBar&&this._headerBar.scrollLeft>0)){this._bodyScroll();}},refresh:function(dataSource){if(typeof(dataSource)!="undefined"){this.set_dataSource(dataSource);} this.dataChanged();},add_newRecord:function(handler){this.get_events().addHandler("newRecord",handler);},remove_newRecord:function(handler){this.get_events().removeHandler("newRecord",handler);},_internalNewRecord:function(data){var handler=this.get_events().getHandler("newRecord");if(handler){var eventArgs=new Sys.UI.Controls.GridNewRecordEventArgs(data);handler(this,eventArgs);for(var name in data){var column=this.findColumn(name);if(column){if(column._hasEditor()){} else{this.selectedRowColumnDataChanged(column);}}}}},appendRowData:function(data,disableSetAsSelected){var pager=this.findPager();if(pager&&!pager.get_isLastPage()){this._internalLastPageThenAppendRowData(pager,data);} else if(pager){if(this.get_dataController().get_recordCount()+1>pager.get_pageSize()){this._internalLastPageThenAppendRowData(pager,data);} else{this._internalAppendRowData(data);}} else{this._internalAppendRowData(data,disableSetAsSelected);}},_internalLastPageThenAppendRowData:function(pager,data){pager.incItemCount();var rowIndex=data.__rowIndex;if(rowIndex>=0){var pageSize=pager.get_pageSize();var pageIndex=Math.floor(rowIndex/pageSize);pager.gotoPage(pageIndex,Function.createDelegate(this,function(){var row=this._getRow(rowIndex-pageIndex*pageSize);this._setSelectedRow(row);}));} else{pager.lastPage(Function.createDelegate(this,function(){var index=this.get_dataController().indexOfRecord(data);if(index<0){this._internalAppendRowData(data);} else{var row=this._getRow(index);this._setSelectedRow(row);}}));}},_internalAppendRowData:function(data,disableSetAsSelected){var row=this._doAppendRow();this._initNewRowData(row,data,disableSetAsSelected);this._calcAllColumnSummary();},_initNewRowData:function(row,data,disableSetAsSelected){var rowIndex=this._getRowIndex(row);if(!disableSetAsSelected){this._hideEditor();} this.get_dataController().modifyRecord(rowIndex,data);this._initRowData(row,rowIndex);if(!disableSetAsSelected){this._setSelectedRow(row);} var pager=this.findPager();if(pager){pager.incItemCount();}},_doAppendRow:function(){var row;var recordCount=this.get_recordCount();var rowCount=this.get_rowCount();if(rowCount>recordCount){for(var i=0;i<rowCount;i++){if(this.isEmptyRow(i)){return this._getRow(i);}}} else{row=this._appendRow();var bodyHeight=this._body.offsetHeight;var rowsHeight=this._rowsTable.offsetHeight;this._body.scrollTop=rowsHeight-bodyHeight;} return row;},appendRow:function(){var row=this._doAppendRow();this._setSelectedRow(row);return this._getRowIndex(row);},insertRowData:function(rowIndex,data){this._checkRowIndex(rowIndex);this.get_dataController().insertRecord(rowIndex,data);var row=this._doInsertRow(rowIndex);this._initNewRowData(row,data);this._calcAllColumnSummary();this._setSelectedRow(row);return this._getRowIndex(row);},insertRow:function(rowIndex){if(this.get_recordCount()<=0){return this.appendRowData(new Object());} else{return this.insertRowData(rowIndex,new Object());}},_doInsertRow:function(rowIndex){var row=this._createRow(rowIndex);var beforeRow=this._getRow(rowIndex);this._rows.insertBefore(row,beforeRow);this._resetRowIndex(rowIndex+1);return row;},_isValidRecordIndex:function(rowIndex){var count=this.get_recordCount();return rowIndex>=0&&rowIndex<count;},_checkRecordIndex:function(rowIndex){if(!this._isValidRecordIndex(rowIndex)){var count=this.get_recordCount();throw Error.invalidOperation(String.format("行记录索引范围应为 [0-{0}]",count-1));}},isEmptyRow:function(rowIndex){if(rowIndex>=0&&rowIndex<this.get_recordCount()){var data=this.get_dataController().getRecord(rowIndex);return this._isEmptyData(data);} return true;},_isEmptyData:function(data){if(!data)return true;for(var name in data){if(data[name]){return false;}} return true;},findRowData:function(rowIndex){return this._isValidRecordIndex(rowIndex)?this.get_dataController().getRecord(rowIndex):null;},getRowData:function(rowIndex){this._checkRecordIndex(rowIndex);return this.get_dataController().getRecord(rowIndex);},modifyRowData:function(rowIndex,data){this._checkRecordIndex(rowIndex);this._doModifyRowData(rowIndex,data);},_doModifyRowData:function(rowIndex,data){if(!this._isEmptyData(data)){var columnCount=this.get_columnCount();for(var i=0;i<columnCount;i++){var column=this.getColumnByIndex(i);var dataField=column.get_dataField();if(dataField&&typeof(data[dataField])=="undefined"){var defaultValue=column.getDefaultValue();if(defaultValue!=undefined){data[dataField]=defaultValue;}}}} this.get_dataController().modifyRecord(rowIndex,data);var row=this._getRow(rowIndex);this._initRowData(row,rowIndex);this._setRowStyle(row,0);this.doChange();this._calcAllColumnSummary();},modifySelectedRowData:function(data){var selectedRow=this._selectedRow;if(!selectedRow){throw Error.invalidOperation("没有选中行");} this._doModifyRowData(this._getRowIndex(selectedRow),data);},deleteSelectedRow:function Sys$UI$Controls$Grid$deleteSelectedRow(){var selectedRow=this._selectedRow;if(selectedRow){this.deleteRow(this._getRowIndex(selectedRow));}},_refreshRowNo:function(refreshRowsStyle){var rowDeleteColumn=this._rowDeleteColumn;for(var i=0,count=this.get_rowCount();i<count;i++){var row=this._getRow(i);this._initRowNo(row,i);if(refreshRowsStyle){this._setRowStyle(row,0);} if(rowDeleteColumn){rowDeleteColumn.doInit(row,i);}} if(rowDeleteColumn&&this._body.scrollLeft>0){window.asyncCall(Function.createDelegate(this,this._bodyScroll));}},_resetRowIndex:function(startRowIndex){var rowCount=this.get_rowCount();for(var i=startRowIndex;i<rowCount;i++){var row=this._getRow(i);this._initRowNo(row,i);row._rowIndex=i;}},_clearRow:function(row){var commandColumns=this._commandColumns;if(!commandColumns)return;if(row._state=="1"){var firstCellIndex=this._getFirstColumnCellIndex();var cells=row.childNodes;for(var i=0,count=commandColumns.length;i<count;i++){var cellIndex=firstCellIndex+commandColumns[i].get_index();var cell=cells[cellIndex];var cellText=cell.firstChild;if(cellText){$clearHandlers(cellText);}}}},_checkDeleteSelectedRow:function(){var selectedRow=this._selectedRow;if(selectedRow){this._internalCheckDeleteRow(this._getRowIndex(selectedRow));}},_internalCheckDeleteRow:function(rowIndex){var handler=this.get_events().getHandler("rowDeleting");if(handler){var eventArgs=new Sys.UI.Controls.GridRowDeletingEventArgs(rowIndex);handler(this,eventArgs);if(eventArgs.get_cancel()){return;}} this.deleteRow(rowIndex);},deleteRow:function Sys$UI$Controls$Grid$deleteRow(rowIndex){var rowElement=null;var count=this.get_rowCount();if(rowIndex>=0||rowIndex<count){rowElement=this._getRow(rowIndex);} if(rowElement){this._hideEditor();this.get_dataController().deleteRecord(rowIndex);count--;this._setSelectedRow(null);var newSelectedRow=null;var modifyOnly=this.get_modifyOnly();if(count>0||modifyOnly){this._clearRow(rowElement);$removeNode(rowElement);this._resetRowIndex(rowIndex);var recordCount=this.get_readOnly()||modifyOnly?this.get_recordCount():this.get_rowCount();if(recordCount>0){var selectedIndex=rowIndex<recordCount?rowIndex:rowIndex-1;newSelectedRow=this._getRow(selectedIndex);}} else{var selectedIndex=0;newSelectedRow=this._getRow(selectedIndex);this._initRowData(newSelectedRow,selectedIndex);} if(this._body.scrollLeft>0){this._bodyScroll();} this._setSelectedRow(newSelectedRow);var pager=this.findPager();if(pager){pager.deleteRecord(this._dataRowFirst+rowIndex);if(pager.get_pageCount()<=1){pager.decItemCount();} else if(pager.get_isLastPage()){if(this.get_recordCount()>0){pager.decItemCount();} else{pager.prevPage();}} else{pager.reloadPage(null,Function.createDelegate(this,function(){var recordCount=this.get_recordCount();if(recordCount>0){var newRowIndex=Math.min(rowIndex,recordCount-1);this.set_selectedRowIndex(newRowIndex);}}));}} this.doRowDeleted();this._calcAllColumnSummary();this.doChange();}},add_rowDeleting:function(handler){this.get_events().addHandler("rowDeleting",handler);},remove_rowDeleting:function(handler){this.get_events().removeHandler("rowDeleting",handler);},add_rowDeleted:function(handler){this.get_events().addHandler("rowDeleted",handler);},remove_rowDeleted:function(handler){this.get_events().removeHandler("rowDeleted",handler);},doRowDeleted:function(){var handler=this.get_events().getHandler("rowDeleted");if(handler){handler(this);}},findRow:function(propName,propValue){for(var i=0,count=this.get_recordCount();i<count;i++){var record=this.getRowData(i);if(record[propName]==propValue){return i;}} return-1;},locateRow:function(propName,propValue){var rowIndex=this.findRow(propName,propValue);if(rowIndex>=0){this.set_selectedRowIndex(rowIndex);} return rowIndex;},moveUpSelectedRow:function(){var currIndex=this.get_selectedRowIndex();if(currIndex<=0)return;var prevIndex=currIndex-1;if(this.isEmptyRow(currIndex)||this.isEmptyRow(prevIndex))return;var curr=this.getRowData(currIndex);var prev=this.getRowData(prevIndex);this.modifyRowData(prevIndex,curr);this.modifyRowData(currIndex,prev);this.set_selectedRowIndex(prevIndex);},moveDownSelectedRow:function(){var currIndex=this.get_selectedRowIndex();if(currIndex>=this.get_recordCount()-1)return;var nextIndex=currIndex+1;if(this.isEmptyRow(currIndex)||this.isEmptyRow(nextIndex))return;var curr=this.getRowData(currIndex);var next=this.getRowData(nextIndex);this.modifyRowData(nextIndex,curr);this.modifyRowData(currIndex,next);this.set_selectedRowIndex(nextIndex);},_beforeInitCellMerge:function(){var items=this._cellMergeItems;var count=items.length;for(var i=count-1;i>=0;i--){var item=items[i];var rowIndex=item.rowIndex;var row=this._getRow(rowIndex);if(row){var fromColumn=this.getColumn(item.fromColumn);var toColumn=this.getColumn(item.toColumn);var firstColIndex=fromColumn.get_index();var columnCount=this.get_columnCount();for(var j=firstColIndex;j<columnCount;j++){var column=this.getColumnByIndex(j);var cell=this._getRowCell(row,j);if(j==firstColIndex){cell.colSpan=1;cell.width=column.get_width();if(item.textAlign){cell.firstChild.style.textAlign="";} if(item.textBgColor){cell._bgColor="";}} else if(column.get_visible()){cell.style.display="";} if(column==toColumn){break;}}}}},_initCellMerge:function(initWidthOnly){var rowsTable=this._rowsTable;rowsTable.style.tableLayout="";var items=this._cellMergeItems;for(var i=0,count=items.length;i<count;i++){var item=items[i];var rowIndex=item.rowIndex;var row=this._getRow(rowIndex);if(row){var fromColumn=this.getColumn(item.fromColumn);if(!fromColumn.get_visible()){throw Error.invalidOperation("列“"+item.fromColumn+"”不可见");} var toColumn=this.getColumn(item.toColumn);var displayColumn=this.getColumn(item.displayColumn);var colSpan=0;var firstColWidth=0;var firstColIndex=fromColumn.get_index();var columnCount=this.get_columnCount();for(var j=firstColIndex;j<columnCount;j++){var column=this.getColumnByIndex(j);if(column.get_visible()){firstColWidth+=column.get_width();colSpan++;} if(column==toColumn){break;}} for(var j=firstColIndex;j<columnCount;j++){var column=this.getColumnByIndex(j);var cell=this._getRowCell(row,j);if(j==firstColIndex){cell.colSpan=colSpan;cell.width=firstColWidth;if(!initWidthOnly){cell.innerHTML=displayColumn.internalGetCellHTML(rowIndex);if(item.textAlign){cell.firstChild.style.textAlign=item.textAlign;} var bgColor=item.textBgColor;if(bgColor){cell._bgColor=bgColor;cell.style.backgroundColor=bgColor;}}} else if(column.get_visible()){cell.style.display="none";} if(column==toColumn){break;}}}}},add_summaryLoaded:function(handler){this.get_events().addHandler("summaryLoaded",handler);},remove_summaryLoaded:function(handler){this.get_events().removeHandler("summaryLoaded",handler);},getSummaryValue:function(dataField){var summaryItems=this._summaryItems;if(summaryItems){var summaryItem=summaryItems[dataField];if(summaryItem){return summaryItem.value;}} return null;},set_summaryItems:function(items){this._summaryItems=items;var summaryItemPrefix=this._summaryItemPrefix;if(!summaryItemPrefix){summaryItemPrefix=this._summaryItemPrefix=["","最小 ","最大 ","平均 ","计数 ",""];} for(var dataField in items){var column=this.findColumn(dataField,true);if(column&&column.get_useServerSum()){var summaryItem=items[dataField];var prefix=summaryItemPrefix[summaryItem.summaryKind];var value=summaryItem.value;var formatString=summaryItem.formatString;this._setColumnSummary(column,value,formatString,prefix);column._internalSetHasServerSum(true);}} var handler=this.get_events().getHandler("summaryLoaded");if(handler){handler(this);}},_setColumnSummary:function(column,value,formatString,prefix){var isNubmerColumn=(column instanceof Sys.UI.Controls.NumberColumn);if(!isNubmerColumn&&column.getIsNumberType){isNubmerColumn=column.getIsNumberType();} var text=value!=null?(prefix?prefix:"")+(formatString?value.format(formatString,isNubmerColumn?column.get_displayThousandSeperator():false):(isNubmerColumn?column.formatNumber(value):value.toString())):"";if(isNubmerColumn&&value!=null){var decimalDigits=column.get_decimalDigits();if(decimalDigits<=0){decimalDigits=column.get_decimalScale();} if(decimalDigits>0){value=Math.roundTo(value,decimalDigits);}} column.set_summaryValue(value);column.set_footer(text);},_calcAllColumnSummary:function(){if(!this._hasSummaryColumn)return;var sumValues={};var columnCount=this.get_columnCount();var sumColumnCount=0;var sumColumns=[];for(var j=0;j<columnCount;j++){var column=this.getColumnByIndex(j);var dataField=column.get_dataField();if(dataField&&column.get_isClientSum()&&!column.get_useServerSum()){sumValues[dataField]=null;Array.add(sumColumns,column);sumColumnCount++;}} if(sumColumnCount==0)return;var loadedItems=this._doGetLoadedItems();if(loadedItems){this._calcLoadedItemsSummary(loadedItems,sumValues);} var recordCount=this.get_recordCount();for(var i=0;i<recordCount;i++){var rowData=this.getRowData(i);if(rowData){this._calcRowSummary(rowData,sumValues,sumColumns);}} delete sumColumns;for(var dataField in sumValues){var sumValue=sumValues[dataField];var column=this.getColumn(dataField);if(sumValue!=null&&(sumValue!=0||recordCount>0)){this._setColumnSummary(column,sumValue);} else{column.set_summaryValue(0);column.set_footer("");}} this._summaryChanged();},_isValueNeedSum:function(value){return value!=null&&value!=="";},_calcRowSummary:function(rowData,sumValues,sumColumns){var i=0;for(var dataField in sumValues){var value=rowData[dataField];if(this._isValueNeedSum(value)){if(sumValues[dataField]==null){sumValues[dataField]=0;} if(sumColumns){value=sumColumns[i].loadEditValue(value);} sumValues[dataField]+=value;} i++;}},_calcLoadedItemsSummary:function(loadedItems,sumValues){var curPageRecordStart=this._dataRowFirst;var curPageRecordMax=curPageRecordStart+this.get_recordCount();for(var i=0,count=loadedItems.length;i<count;i++){if(i>=curPageRecordStart&&i<curPageRecordMax)continue;var loadedItem=loadedItems[i];if(loadedItem){var rowData=loadedItem.data;if(rowData){this._calcRowSummary(rowData,sumValues);}}}},add_summaryChanged:function(handler){this.get_events().addHandler("summaryChanged",handler);},remove_summaryChanged:function(handler){this.get_events().removeHandler("summaryChanged",handler);},_summaryChanged:function(){var handler=this.get_events().getHandler("summaryChanged");if(handler){handler(this);}},_internalCalcColumnSummary:function(column){var dataField=column.get_dataField();if(!dataField)return;var sum=0;var hasSum=false;var loadedItems=this._doGetLoadedItems();if(loadedItems){var curPageRecordStart=this._dataRowFirst;var curPageRecordMax=curPageRecordStart+this.get_recordCount();for(var i=0,count=loadedItems.length;i<count;i++){if(i>=curPageRecordStart&&i<curPageRecordMax)continue;var loadedItem=loadedItems[i];if(loadedItem){var rowData=loadedItem.data;if(rowData){var value=rowData[dataField];if(this._isValueNeedSum(value)){sum+=value;hasSum=true;}}}}} for(var i=0,count=this.get_recordCount();i<count;i++){var rowData=this.getRowData(i);if(rowData){var value=rowData[dataField];if(this._isValueNeedSum(value)){sum+=column.loadEditValue(value);hasSum=true;}}} if(sum==0&&!hasSum){sum=null;} this._setColumnSummary(column,sum);this._summaryChanged();},clearSortFlag:function(){if(this.get_allowSort()){this._clearSort(null);}},_clearSort:function Sys$UI$Controls$Grid$_clearSort(exceptColumn){var columnCount=this.get_columnCount();for(var i=0;i<columnCount;i++){var column=this.getColumnByIndex(i);if(column!=exceptColumn){column._clearSort();}}},_doSort:function Sys$UI$Controls$Grid$_doSort(){var columnCount=this.get_columnCount();var pager=this.findPager();if(!pager){for(var i=0;i<columnCount;i++){var column=this.getColumnByIndex(i);if(column.get_isSorted()){this._doSortBy(column);break;}} return;} var orders=[];var columnCount=this.get_columnCount();for(var i=0;i<columnCount;i++){var column=this.getColumnByIndex(i);if(column.get_isSorted()){var order=new Object();order.dataField=column.get_dataField();order.ascending=column.get_isSortAscending();Array.add(orders,order);}} pager._internalRefreshSort(orders);},add_columnSort:function(handler,handlerOwner){return this.get_events().addHandler("columnSort",handler,handlerOwner);},remove_columnSort:function(handler){this.get_events().removeHandler("columnSort",handler);},_doSortBy:function Sys$UI$Controls$Grid$_doSortBy(column){this._postEditValue();var handler=this.get_events().getHandler("columnSort");if(handler){var eventArgs=new Sys.UI.Controls.GridColumnSortEventArgs(column);handler(this,eventArgs);if(eventArgs.get_cancel()){return;}} var ascending=column.get_isSortAscending();var controller=this.get_dataController();controller.sortBy(column,ascending);var count=this.get_recordCount();for(var i=0;i<count;i++){var row=this._getRow(i);this._initRowData(row,i);this._setRowStyle(row,0);}},_internalGetColumnVisible:function(column){var visible=column.get_designVisible();if(this._configData){var columnsVisible=this._configData.ColumnsVisible;if(columnsVisible){var columnVisible=columnsVisible[column.get_name()];if(typeof(columnVisible)!="undefined"){visible=columnVisible;}}} return visible;},_internalSetColumnVisible:function(column,visible,saveConfig){if(saveConfig){if(!this._configData){this._configData=new Object();} var columnsVisible=this._configData.ColumnsVisible;if(!columnsVisible){columnsVisible=this._configData.ColumnsVisible=new Object();} var name=column.get_name();if(visible==column.get_designVisible()){delete columnsVisible[name];} else{columnsVisible[name]=visible;}} else{column.set_designVisible(visible);} if(this._body.scrollLeft>0){this._body.scrollLeft=0;this._bodyScroll();} this._refreshColumnVisible(column);},_getColumnVisibleIndex:function(column){var index=-1;for(var i=0,count=this.get_columnCount();i<count;i++){var theColumn=this.getColumnByIndex(i);if(theColumn==column){break;} else if(theColumn.get_visible()){index++;}} return index+1;},_adjustGroupColVisible:function(column,visible){var colGroup=this._colGroup;if(colGroup){var visibleIndex=this._getColumnVisibleIndex(column);if(this.get_showRowNo()){visibleIndex++;} var col=colGroup.childNodes[visibleIndex];if(visible){var newCol=document.createElement("col");newCol.width=column.get_width();if(col){colGroup.insertBefore(newCol,col);} else{colGroup.appendChild(newCol);}} else{$removeNode(col);}}},_refreshColumnVisible:function Sys$UI$Controls$Grid$_refreshColumnVisible(column){if(!this.get_readOnly()){this._hideEditor();} var visible=column.get_visible();var columnIndex=column.get_index();var incWidth=column.get_width()+1;incWidth*=visible?1:-1;var showScrollBar=this.get_showScrollBar();if(this.get_showHeader()){if(showScrollBar){var headerWidth=this._savedHeaderWidth;if(!headerWidth){headerWidth=this._header.offsetWidth;} else{this._savedHeaderWidth=null;} this._setTableWidth(this._header,headerWidth+incWidth);} var td=column.get_headerElement();$common.setDisplay(td,visible);var band=column.get_band();if(band){this._refreshBand(band);}} this._adjustGroupColVisible(column,visible);if(showScrollBar){if(this._body.offsetWidth+incWidth<this.get_element().offsetWidth-this._getBorderSize()){this._body.style.width=(this._body.offsetWidth+incWidth)+"px";} var rowsTableWidth=this._rowsTable.offsetWidth;if(rowsTableWidth>0){this._rowsTable.style.width=(rowsTableWidth+incWidth)+"px";}} else{var newWidth=this._header.offsetWidth;var element=this.get_element();element.style.overflow="hidden";element.style.width=newWidth+"px";this._doAdjustBodyWidth();this._rowsTable.style.width=this._body.style.width;} var rowCount=this.get_rowCount();for(var i=0;i<rowCount;i++){var row=this._getRow(i);var td=this._getRowCell(row,columnIndex);$common.setDisplay(td,visible);column.initCellHTML(i,td);} if(showScrollBar){this._doAdjustHeaderSpacer();this._doAdjustBodyWidth();} else{this.get_element().style.overflow="";} if(this.get_showFooter()){var td=column.get_footerElement();$common.setDisplay(td,visible);this._refreshFooterWidth();}},_refreshFooterWidth:function(){this._footer.style.width=this._header.offsetWidth+"px";for(var i=0,count=this.get_columnCount();i<count;i++){var col=this.getColumnByIndex(i);var tdFooter=col.get_footerElement();var tdHeader=col.get_headerElement();tdFooter.style.width=tdHeader.offsetWidth+"px";} if(this.get_showScrollBar()){var footerNodes=this._footerRow.childNodes;footerNodes[footerNodes.length-1].style.width=this._headerSpacer.offsetWidth+"px";}},_refreshColumnWidth:function(column,newWidth,oldWidth){if(!this.get_showScrollBar()){throw Error.invalidOperation("没有滚动条时不会支持调整列宽");} column._hideEditor();var incWidth=newWidth-oldWidth;if(this.get_showHeader()){this._setTableWidth(this._header,this._header.offsetWidth+incWidth);var td=column.get_headerElement();td.width=newWidth;var band=column.get_band();if(band){this._refreshBand(band);}} this._adjustGroupColWidth(column,newWidth);if(this._body.offsetWidth+incWidth<this.get_element().offsetWidth-this._getBorderSize()){this._body.style.width=(this._body.offsetWidth+incWidth)+"px";} var newRowsTableWidth=this._rowsTable.offsetWidth+incWidth;if(newRowsTableWidth>0){this._rowsTable.style.width=newRowsTableWidth+"px";} var columnIndex=column.get_index();var rowCount=this.get_rowCount();for(var i=0;i<rowCount;i++){var row=this._getRow(i);var td=this._getRowCell(row,columnIndex);td.width=newWidth;} if(this._cellMergeItems){this._initCellMerge(true);} this._doAdjustHeaderSpacer();this._doAdjustBodyWidth();if(this.get_showFooter()){this._refreshFooterWidth();}},_adjustGroupColWidth:function(column,width){var colGroup=this._colGroup;if(colGroup){var visibleIndex=this._getColumnVisibleIndex(column);if(this.get_showRowNo()){visibleIndex++;} var col=colGroup.childNodes[visibleIndex];col.width=width;}},_refreshBand:function(band){if(!band){throw Error.argumentNull("band");} var bandColumns=band.columns;var visibleCount=0;var visibleWidth=0;for(var i=0,count=bandColumns.length;i<count;i++){var bandColumn=bandColumns[i];if(bandColumn.get_visible()){visibleCount++;visibleWidth+=bandColumn.get_width();}} var bandElement=band.element;var visible=visibleCount>0;$common.setDisplay(bandElement,visible);if(visible){bandElement.colSpan=visibleCount;bandElement.width=visibleWidth;}},_internalGetColumnCaption:function(column){var caption=column.get_designCaption();if(this._configData){var columnsCaption=this._configData.ColumnsCaption;if(columnsCaption){var columnCaption=columnsCaption[column.get_name()];if(columnCaption){caption=columnCaption;}}} return caption;},_internalGetColumnWidth:function(column){var width=column.get_designWidth();if(this._configData){var columnsWidth=this._configData.ColumnsWidth;if(columnsWidth){var columnWidth=columnsWidth[column.get_name()];if(columnWidth>0){width=columnWidth;}}} return width;},get_configData:function(){return this._configData;},set_configData:function(value){this._configData=value;},_internalSetColumnCaption:function(column,caption,saveConfig){if(saveConfig){if(!this._configData){this._configData=new Object();} var columnsCaption=this._configData.ColumnsCaption;if(!columnsCaption){columnsCaption=this._configData.ColumnsCaption=new Object();} var name=column.get_name();if(caption==column.get_designCaption()){delete columnsCaption[name];} else{columnsCaption[name]=caption;}} else{column.set_designCaption(caption);} column._internalRefreshCaption();},_clearConfigColumnCaption:function(column){if(!this._configData)return;var columnsCaption=this._configData.ColumnsCaption;if(!columnsCaption)return;var name=column.get_name();delete columnsCaption[name];},_internalSetColumnWidth:function(column,newWidth,oldWidth,saveConfig){if(saveConfig){if(!this._configData){this._configData=new Object();} var columnsWidth=this._configData.ColumnsWidth;if(!columnsWidth){columnsWidth=this._configData.ColumnsWidth=new Object();} var name=column.get_name();if(newWidth==column.get_designWidth()){delete columnsWidth[name];} else{columnsWidth[name]=newWidth;}} else{column.set_designWidth(newWidth);} this._refreshColumnWidth(column,newWidth,oldWidth);if(this._body.scrollLeft>0){this._bodyScroll();} if(saveConfig){this._configDataChanged=true;}},_clearColumnWidth:function(name){var configData=this._configData;if(configData){var columnsWidth=configData.ColumnsWidth;if(columnsWidth){delete columnsWidth[name];}}},_internalSwapColumn:function(column1,column2){column1._hideEditor();column2._hideEditor();var elements1=column1._elements;var elements2=column2._elements;var columnIndex1=column1.get_index();var columnIndex2=column2.get_index();column1._internalSetElements(elements2,columnIndex2);column2._internalSetElements(elements1,columnIndex1);var columns=this._columns;columns[columnIndex1]=column2;columns[columnIndex2]=column1;this._refreshColumn(column1);this._refreshColumn(column2);},_refreshColumn:function(column){var visible=column.get_visible();var width=column.get_width();if(this.get_showHeader()){var td=column.get_headerElement();td.width=width;td.align=column.get_headerAlign();$common.setDisplay(td,visible);} column._internalRefreshCaption();var index=column.get_index();for(var i=0,count=this.get_rowCount();i<count;i++){var row=this._getRow(i);var td=this._getRowCell(row,index);td.width=width;td.align=column.get_textAlign();td._columnIndex=index;column.initCellHTML(i,td);this._initCellStyle(index,td);$common.setDisplay(td,visible);} if(this.get_showFooter()){var td=column.get_footerElement();td.width=width;$common.setDisplay(td,visible);} column._internalRefreshFooter();},_internalRefreshColumnContent:function(column){var index=column.get_index();for(var i=0,count=this.get_rowCount();i<count;i++){var row=this._getRow(i);var td=this._getRowCell(row,index);column.initCellHTML(i,td);} if(this.get_showFooter()){column._internalRefreshFooter();}},_internalRefreshColumnStyle:function(column){var index=column.get_index();for(var i=0,count=this.get_rowCount();i<count;i++){var row=this._getRow(i);var td=this._getRowCell(row,index);this._initCellStyle(index,td);}},_internalResetConfig:function(){for(var i=0,count=this.get_columnCount();i<count;i++){var column=this.getColumnByIndex(i);column.set_caption(column.get_designCaption(),true);column.set_visible(column.get_designVisible(),true);column.set_width(column.get_designWidth(),true);} if(this._configData){delete this._configData;this._configData=null;}},_internalSaveConfig:function(syncCall){var configData=this.get_configData();if(configData){var columnsVisible=configData.ColumnsVisible;if(Object.isEmpty(columnsVisible)){delete configData.ColumnsVisible;columnsVisible=null;} var columnsCaption=configData.ColumnsCaption;if(Object.isEmpty(columnsCaption)){delete configData.ColumnsCaption;columnsCaption=null;} var columnsWidth=configData.ColumnsWidth;if(Object.isEmpty(columnsWidth)){delete configData.ColumnsWidth;columnsWidth=null;} if(columnsVisible==null&&columnsCaption==null&&columnsWidth==null){configData=null;}} var gridId=this.get_guid()+"_"+this.get_configID();var service=Carpa.Web.Script.DataService.create();if(syncCall){try{service.SaveGridConfig(gridId,configData,true);} catch(e){}} else{service.SaveGridConfig(gridId,configData,Function.emptyMethod,Function.emptyMethod);}},config:function(hideNotAllowConfigColumns){var url=$common.getSysUIBaseURI()+"Grid/GridConfig.gspx";var form=new Sys.UI.Form(this._grid,518,301);form._grid=this;form._hideNotAllowConfigColumns=hideNotAllowConfigColumns;form.showModal(url);},filter:function(){var pager=this.findPager();if(!pager){throw Error.invalidOperation("过滤暂时只支持有分页器的 Grid");} var url=$common.getSysUIBaseURI()+"Grid/GridFilter.gspx";var form=new Sys.UI.Form(this._grid,300,260);form._grid=this;form.showModal(url);},_findBand:function(name){var bands=this._bands;if(!bands||!name)return null;name=name.toLowerCase();for(var i=0,count=bands.length;i<count;i++){var band=bands[i];var bandName=band.name;if(bandName&&bandName.toLowerCase()==name){return band;}} return null;},_getFirstColumnExpandCount:function(){var columnExpands=this._columnExpands;var firstColumnExpand=columnExpands&&columnExpands.length>0?columnExpands[0]:null;return!firstColumnExpand||!firstColumnExpand.captions?-1:firstColumnExpand.captions.length;},_initColumnExpands:function(){if(this._body.scrollLeft>0){this._body.scrollLeft=0;} this._clearColumnHeadersHighlight();var columnExpands=this._columnExpands;if(columnExpands){for(var i=0,count=columnExpands.length;i<count;i++){this._initColumnExpand(columnExpands[i]);}} this._doAdjustHeaderSpacer();this._doAdjustFooterSpacer();},expandColumn:function(name,dataFields,captions){if(!dataFields)dataFields=[];if(!captions)captions=[];var columnExpand={name:name,dataFields:dataFields,captions:captions};var columnExpands=[columnExpand];this.set_columnExpands(columnExpands);},_initColumnExpand:function(columnExpand){var name=columnExpand?columnExpand.name:null;if(!name)return;var band=this._findBand(name);if(!band){var column=this.findColumn(name);if(!column){throw Error.invalidOperation("列“"+name+"”不存在");} this._expandColumn(column,columnExpand);} else{this._expandBand(band,columnExpand);}},_initBand:function(band){if(band.element)return;band.element=$get(this.get_id()+"_band"+band.index);var bandIndex=band.index;var columns=band.columns=[];for(var i=0,count=this.get_columnCount();i<count;i++){var column=this.getColumnByIndex(i);if(column.get_bandIndex()==bandIndex){Array.add(columns,column);}}},getBandByIndex:function(index){var bands=this._bands;if(index>=0&&bands&&index<bands.length){var band=bands[index];this._initBand(band);return band;} return null;},_expandBand:function(band,columnExpand){this._initBand(band);var captions=columnExpand.captions;var dataFields=columnExpand.dataFields;var reportFields=columnExpand.reportFields;if(!reportFields){reportFields=[];} var expandCount=captions?captions.length:0;var expanded=band.expanded;if(!expanded){expanded=band.expanded=[band];var columns=band.columns;for(var i=0,columnCount=columns.length;i<columnCount;i++){var column=columns[i];column.set_groupName(band.name);}} var oldCount=band.expanded.length;for(var i=0;i<oldCount;i++){var bandVisible=i<expandCount;this._initOldBand(expanded[i],bandVisible,i,captions[i],dataFields,reportFields[i]);} for(var i=oldCount;i<expandCount;i++){expanded[i]=this._addNewBand(band,i,captions[i],dataFields,reportFields[i]);} this._resetPagerWidth();},_initOldBand:function(band,bandVisible,expandIndex,caption,dataFields,reportField){var bandElement=band.element;this._savedHeaderWidth=this._header.offsetWidth;$common.setDisplay(bandElement,bandVisible);if(bandVisible){bandElement.firstChild.innerHTML=caption;} var columns=band.columns;var columnCount=columns.length;for(var i=0;i<columnCount;i++){var column=columns[i];var designVisible=column.get_designVisible();var columnVisible=bandVisible&&designVisible;column.set_visible(columnVisible,true);if(columnVisible){column._noUse=false;var dataField=dataFields[expandIndex*columnCount+i];column.set_dataField(dataField);this._initColumnReportField(column,column,reportField,dataField);} else{column._noUse=designVisible?true:false;}}},_initColumnReportField:function(newColumn,column,reportField,dataField){if(reportField){newColumn.set_reportField(reportField+column.get_designCaption());} else{newColumn.set_reportField(dataField);}},_expandColumn:function(column,columnExpand){var captions=columnExpand.captions;var dataFields=columnExpand.dataFields;var reportFields=columnExpand.reportFields;if(!reportFields){reportFields=[];} var expandCount=captions?captions.length:0;var expanded=column.expanded;if(!expanded){expanded=column.expanded=[column];column.set_groupName(column.get_name());} var oldCount=column.expanded.length;for(var i=0;i<oldCount;i++){var columnVisible=i<expandCount;this._initOldColumn(expanded[i],columnVisible,captions[i],dataFields[i],reportFields[i]);} for(var i=oldCount;i<expandCount;i++){expanded[i]=this._addNewColumn(column,i,captions[i],dataFields[i],reportFields[i]);} this._resetPagerWidth();},_initOldColumn:function(column,columnVisible,caption,dataField,reportField){column.set_visible(columnVisible,true);this._clearConfigColumnCaption(column);if(columnVisible){column.set_caption(caption,true);column.set_designCaption(caption);column.set_dataField(dataField);column.set_reportField(reportField);}},_addNewColumn:function(column,expandIndex,caption,dataField,reportField){var headerElement=column.get_headerElement();var indexOffset=expandIndex;var newHeaderElement=this._insertTd(headerElement,indexOffset,column.get_designCaption(),true);var newFooterElement=null;var footerElement=column.get_footerElement();if(footerElement){newFooterElement=this._insertTd(footerElement,indexOffset,"",false);} var newColumn=this._insertColumn(column.get_index()+expandIndex,column.get_params(),column.get_name(),dataField,newHeaderElement,newFooterElement);newColumn.set_caption(caption,true);newColumn.set_designCaption(caption);newColumn.set_reportField(reportField);newColumn.set_groupName(column.get_name());var bandIndex=column.get_bandIndex();if(bandIndex>=0){var band=this.getBandByIndex(bandIndex);newColumn.set_bandIndex(bandIndex);newColumn.set_band(band);band.columns[expandIndex]=newColumn;this._refreshBand(band);} if(!newColumn.get_visible()){this._refreshColumnVisible(newColumn);} this._doAdjustRowsTableWidth();return newColumn;},_doAdjustRowsTableWidth:function(){var gridBodyWidth=this._headerRow.offsetWidth;if(this._headerSpacer){gridBodyWidth-=(this._headerSpacer.offsetWidth+this._getLineWidth());} this._rowsTable.width=gridBodyWidth;},_createHeaderTd:function(templateTd,caption,isHeader){var td=$common.createTd();var className=isHeader?"GridHeaderCaption":"GridFooterCell";td.className=className;td.width=templateTd.width;td.align=templateTd.align;td.colSpan=templateTd.colSpan;td.rowSpan=templateTd.rowSpan;var div=$common.createDiv();div.className=className+"Text";div.innerHTML=caption;td.appendChild(div);return td;},_insertTd:function(templateTd,indexOffset,text,isHeader){var newTd=this._createHeaderTd(templateTd,text,isHeader);var tr=templateTd.parentNode;var tdIndex=Array.indexOf(tr.childNodes,templateTd);var beforeTdIndex=tdIndex+indexOffset;if(beforeTdIndex==tr.childNodes.length){tr.appendChild(newTd);} else{tr.insertBefore(newTd,tr.childNodes[beforeTdIndex]);} return newTd;},_addNewBand:function(band,expandIndex,caption,dataFields,reportField){var staticBands=this.get_bands();var expandBandIndexStart=staticBands&&staticBands.length>0?staticBands.length-1:0;var newBand=new Object();var bandElement=band.element;var bandWidth=bandElement.offsetWidth;var newBandElement=this._insertTd(bandElement,expandIndex,caption,true);newBand.element=newBandElement;var incWidth=0;var columns=band.columns;var count=columns.length;newBand.columns=new Array(count);var indexOffset=expandIndex*count;for(var i=0;i<count;i++){var column=columns[i];var headerElement=column.get_headerElement();var newHeaderElement=this._insertTd(headerElement,indexOffset,column.get_designCaption(),true);var newFooterElement=null;var footerElement=column.get_footerElement();if(footerElement){newFooterElement=this._insertTd(footerElement,indexOffset,"",false);} var dataField=dataFields[expandIndex*count+i];var newColumn=this._insertColumn(column.get_index()+expandIndex*count,column.get_params(),column.get_name(),dataField,newHeaderElement,newFooterElement);newColumn.set_groupName(band.name);this._initColumnReportField(newColumn,column,reportField,dataField);newColumn.set_bandIndex(expandBandIndexStart+expandIndex);newColumn.set_band(newBand);incWidth+=(newColumn.get_width()+1);newBand.columns[i]=newColumn;} if(Sys.Browser.isIE8){var header=this._header;this._setTableWidth(header,header.offsetWidth+incWidth);} for(var i=0;i<count;i++){var newColumn=newBand.columns[i];newColumn._internalRefreshCaption();if(!newColumn.get_visible()){this._refreshColumnVisible(newColumn);}} this._doAdjustRowsTableWidth();return newBand;},_setTableWidth:function(table,width){if(Sys.Browser.isIE8){table.style.tableLayout="";table.style.width=width+"px";table.style.tableLayout="fixed";} else{table.style.width=width+"px";}},_insertColumn:function(index,params,templateName,dataField,headerElement,footerElement){for(var i=index,count=this.get_columnCount();i<count;i++){var column=this.getColumnByIndex(i);column.set_index(i+1);} var newColumn=this._createColumn(index,params,headerElement,footerElement);newColumn.set_dataField(dataField);newColumn.set_name(templateName+index);newColumn._isNew=true;Array.insert(this._columns,index,newColumn);var columnWidth=newColumn.get_width();var colGroup=this._colGroup;if(colGroup){this._adjustGroupColVisible(newColumn,true);} else{headerElement.width=columnWidth;} if(footerElement){footerElement.width=columnWidth;} for(var i=0,count=this.get_rowCount();i<count;i++){var tr=this._getRow(i);var td=this._createCell(newColumn);if(index==tr.childNodes.length){tr.appendChild(td);} else{tr.insertBefore(td,tr.childNodes[index]);}} return newColumn;},_clearColumnHeadersHighlight:function(){if(this._lastHighlightRect&&this._lastHighlightColumn){this._doHighlightColumnHeaders(this._lastHighlightColumn,this._lastHighlightRect,false);this._lastHighlightRect=null;}},highlightColumnHeaders:function(name,rect){if(this._lastHighlightRect){this._doHighlightColumnHeaders(name,this._lastHighlightRect,false);} this._doHighlightColumnHeaders(name,rect,true);this._lastHighlightRect=rect;this._lastHighlightColumn=name;},_doHighlightColumnHeaders:function(name,rect,active){var column=this.getColumn(name);var td=column.get_headerElement();var cells=td.parentNode.childNodes;var index0=Array.indexOf(cells,td);var x0=rect.x;var y0=rect.y;var x1=rect.x+rect.width-1;var y1=rect.y+rect.height-1;for(var x=x0;x<=x1;x++){var td=cells[index0+x];var captionElement=$common.getFirstChildByTagName(td,"div");var rows=captionElement.childNodes;for(var y=y0;y<=y1;y++){var div=rows[y];div.style.backgroundColor=active?"#FFA535":"";}}}}
Sys.UI.Controls.Grid.registerClass('Sys.UI.Controls.Grid',Sys.UI.Control);Sys.UI.Controls.Grid.create=function(parentElement,properties,events){var div=document.createElement("div");div.className="Grid";if(properties.width){div.style.width=properties.width+"px";delete properties.width;} if(properties.height){div.style.height=properties.height+"px";delete properties.height;} var columns=properties.columnProperties;var columnCount=columns.length;var showHeader=properties.showHeader;if(Object.isUndefined(showHeader)){showHeader=true;} if(showHeader){var headerWidth=0;var showRowNo=properties.showRowNo;if(Object.isUndefined(showRowNo)){showRowNo=true;} for(var i=0;i<columnCount;i++){var column=columns[i];headerWidth+=column.width;} var rowNoColumnWidth=Sys.UI.Controls.Grid.getRowNoColumnWidth();if(showRowNo){headerWidth+=rowNoColumnWidth;} var table=$common.createTable(1);table.className="GridHeader";table.width=headerWidth;var tbody=$common.createTBody();var tr=$common.createTr();tr.className="GridHeaderRow";var renderHeader=function(width,align,caption){var td=$common.createTd();td.className="GridHeaderCaption";td.width=width;td.align=align;var div=document.createElement("div");div.className="GridHeaderCaptionText";div.innerHTML=caption;td.appendChild(div);tr.appendChild(td);};if(showRowNo){renderHeader(rowNoColumnWidth,"center","No.");} for(var i=0;i<columnCount;i++){var column=columns[i];renderHeader(column.width,"",column.caption);} renderHeader(16,"","&nbsp;");tbody.appendChild(tr);table.appendChild(tbody);div.appendChild(table);} var body=document.createElement("div");if(properties.hint){body.title=properties.hint;delete properties.hint;} body.className="GridBody ScrollBar";div.appendChild(body);parentElement.appendChild(div);var grid=$create(Sys.UI.Controls.Grid,properties,div,events);grid.doFormInit();return grid;}
Sys.UI.Controls.Grid.getRowNoColumnWidth=function(){return $skin.getElement("grid","properties").rowNoColumnWidth;}
Sys.UI.Controls.CustomGridDataController=function(grid,dataSource){Sys.UI.Controls.CustomGridDataController.initializeBase(this,[dataSource]);this._grid=grid;this._editBuffer=null;}
Sys.UI.Controls.CustomGridDataController.prototype={initialize:function(){Sys.UI.Controls.CustomGridDataController.callBaseMethod(this,'initialize');},dispose:function(){delete this._editBuffer;this._grid=null;Sys.UI.Controls.CustomGridDataController.callBaseMethod(this,'dispose');},get_grid:function(){return this._grid;},getCellValue:function(rowIndex,column){return this.doGetCellValue(rowIndex,column.get_dataField());},getCellText:function(rowIndex,column,value){var fieldName=column.get_displayField();if(fieldName){value=this.doGetCellValue(rowIndex,fieldName);} else if(typeof(value)==="undefined"){value=this.doGetCellValue(rowIndex,column.get_dataField());} return value!=null?value:"";},doGetCellValue:function(rowIndex,fieldName){throw Error.notImplemented();},clearEditBuffer:function(){if(this._editBuffer){delete this._editBuffer;}},_getEditBuffer:function(){var buffer=this._editBuffer;if(!buffer){buffer=new Object();this._editBuffer=buffer;} return buffer;},_isEquals:function(recordValue,value){if(!recordValue||Type.isInstanceOfPrimitiveType(value)){return recordValue==value;} else{return false;}},setCellValue:function(rowIndex,column,value){var changed=this.doSetCellValue(rowIndex,column,value);if(changed){this.get_grid().doChange();}},doSetCellValue:function(rowIndex,column,value){throw Error.notImplemented();},getRecordList:function(){throw Error.notImplemented();},get_hasRecord:function(){return this._dataSource!=null||this._editBuffer!=null;},get_recordCount:function(){var recordList=this.getRecordList();return Math.max((recordList?recordList.length:0),this._getRecordCountInEditBuffer());},_getRecordCountInEditBuffer:function(){var answer=0;var buffer=this._editBuffer;if(buffer){for(var index in buffer){answer=Math.max(answer,parseInt(index)+1);}} return answer;},recordExists:function(data){return this.indexOfRecord(data)>=0;},indexOfRecord:function(data){var recordList=this.getRecordList();if(recordList){var count=recordList.length;for(var index=0;index<count;index++){if(this.recordEquals(data,recordList[index])){return index;}}} return this._indexOfRecordInEditBuffer(data);},_indexOfRecordInEditBuffer:function(data){var buffer=this._editBuffer;if(buffer){for(var index in buffer){if(this.recordEquals(data,buffer[index])){return index;}}} return-1;},recordEquals:function(data1,data2){throw Error.notImplemented();},modifyRecord:function(rowIndex,data){var recordList=this.getRecordList();if(recordList&&rowIndex<recordList.length){recordList[rowIndex]=data;} else{this._setRecordInEditBuffer(rowIndex,data);}},_setRecordInEditBuffer:function(rowIndex,data){var buffer=this._getEditBuffer();var record=buffer[rowIndex];if(!record&&(typeof(data)=="undefined"||data==null)){return;} if(!record){buffer[rowIndex]=data;var record=new Object();this.doNewRecord(record);for(var name in record){if(typeof(data[name])=="undefined"){data[name]=record[name];}}} else{buffer[rowIndex]=data;}},doNewRecord:function(data){var grid=this.get_grid();var columnCount=grid.get_columnCount();for(var i=0;i<columnCount;i++){var column=grid.getColumnByIndex(i);column.initNewRecord(data);} grid._internalNewRecord(data);},getRecord:function(rowIndex){var recordList=this.getRecordList();if(recordList&&rowIndex<recordList.length){return recordList[rowIndex];} return this._getRecordInEditBuffer(rowIndex);},clearRecord:function(rowIndex){var data=this.getRecord(rowIndex);for(var name in data){delete data[name];} return data;},_getRecordInEditBuffer:function(rowIndex){var buffer=this._editBuffer;return buffer?buffer[rowIndex]:null;},deleteRecord:function(rowIndex){var recordList=this.getRecordList();if(recordList&&rowIndex<recordList.length){Array.removeAt(recordList,rowIndex);this._moveEditBuffer(rowIndex,-1);return;} this._deleteRecordInEditBuffer(rowIndex);},_deleteRecordInEditBuffer:function(rowIndex){var buffer=this._editBuffer;if(buffer){delete buffer[rowIndex];this._moveEditBuffer(rowIndex,-1);}},insertRecord:function(rowIndex,data){var recordList=this.getRecordList();if(recordList&&rowIndex<recordList.length){Array.insert(recordList,rowIndex,data);this._moveEditBuffer(rowIndex,1);return;} this._insertRecordInEditBuffer(rowIndex,data);},_insertRecordInEditBuffer:function(rowIndex,data){this._moveEditBuffer(rowIndex,1);this._setRecordInEditBuffer(rowIndex,data);},_moveEditBuffer:function(startIndex,offset){var buffer=this._editBuffer;if(!buffer)return;var indexes=[];for(var index in buffer){var iIndex=parseInt(index);if(iIndex>=startIndex){Array.add(indexes,iIndex);}} indexes.sort(function(a,b){return a-b;});if(offset>0){for(var i=indexes.length-1;i>=0;i--){var index=indexes[i];var record=buffer[index];delete buffer[index];buffer[index+offset]=record;}} else{for(var i=0;i<indexes.length;i++){var index=indexes[i];var record=buffer[index];delete buffer[index];buffer[index+offset]=record;}}},save:function(){throw Error.notImplemented();},sortBy:function(column,ascending){var count=this.get_recordCount();var indexes=new Array(count);var list=new Array(count);var recordCount=0;for(var i=0;i<count;i++){list[recordCount]=this.getRecord(i);indexes[recordCount]=recordCount;recordCount++;} list.length=recordCount;var isNotNumberValue=function(value){return isNaN(value)||typeof(value)!="number";};var isNumber=(column instanceof Sys.UI.Controls.NumberColumn)||(column instanceof Sys.UI.Controls.PercentColumn);var isBool=Sys.UI.Controls.CheckBoxColumn.isInstanceOfType(column);var isEmptyObject=function(o){for(var index in o){return false;} return true;};indexes.sort(Function.createDelegate(this,function(index1,index2){if(isNumber){var value1=this.getCellValue(index1,column);var value2=this.getCellValue(index2,column);if(value1==null){var record=this.getRecord(index1);if(!isEmptyObject(record))value1=0;} if(value2==null){var record=this.getRecord(index2);if(!isEmptyObject(record))value2=0;} if(isNotNumberValue(value1)){return 1;} else if(isNotNumberValue(value2)){return-1;} else{return ascending?value1-value2:value2-value1;}} else if(isBool){var value1=this.getCellValue(index1,column);var value2=this.getCellValue(index2,column);value1=value1?1:0;value2=value2?1:0;return ascending?value1-value2:value2-value1;} else{var str1=column.getCellText(index1);var str2=column.getCellText(index2);if(!str1){return 1;} else if(!str2){return-1;} else{return ascending?str1.toString().localeCompare(str2):str2.toString().localeCompare(str1);}}}));for(var i=0;i<count;i++){if(i<recordCount){var index=indexes[i];var data=list[index];this.modifyRecord(i,data);} else{this.modifyRecord(i,null);}}}}
Sys.UI.Controls.CustomGridDataController.registerClass('Sys.UI.Controls.CustomGridDataController',Sys.UI.CustomDataController);Sys.UI.Controls.GridObjectDataController=function(grid,dataSource){Sys.UI.Controls.GridObjectDataController.initializeBase(this,[grid,dataSource]);}
Sys.UI.Controls.GridObjectDataController.prototype={doGetCellValue:function(rowIndex,fieldName){if(!fieldName)return null;var record;var buffer=this._editBuffer;if(buffer){record=buffer[rowIndex];if(record){value=this._doGetObjProp(record,fieldName);if(typeof(value)!=="undefined"){return value;}}} var dataSource=this._dataSource;record=dataSource&&rowIndex<dataSource.length?dataSource[rowIndex]:null;return record?this._doGetObjProp(record,fieldName):null;},doSetCellValue:function(rowIndex,column,value){var dataField=column?column.get_dataField():null;if(!dataField)return false;var changed=false;var dataSource=this._dataSource;var record=null;if(dataSource&&rowIndex<dataSource.length){record=dataSource[rowIndex];if(!record){record=new Object();dataSource[rowIndex]=record;this.doNewRecord(record);changed=true;} else{changed=!this._isEquals(record[dataField],value);} record[dataField]=value;} else{var buffer=this._getEditBuffer();record=buffer[rowIndex];if(!record){changed=value!=null;if(changed){record=new Object();buffer[rowIndex]=record;this.doNewRecord(record);}} else{changed=!this._isEquals(record[dataField],value);} if(record){record[dataField]=value;}} return changed;},getRecordList:function(){return this._dataSource;},recordEquals:function(data1,data2){var idField="id";var id1=data1[idField];var id2=data2[idField];if(id1&&id2){return id1==id2;} for(var name in data1){var value1=data1[name];var value2=data2[name];if(value1!=value2){if(Date.isInstanceOfType(value1)&&Date.isInstanceOfType(value2)){return value1.getTime()==value2.getTime();} else{return false;}}} return true;},save:function(){var needRowIndex=this._grid.get_needRowIndex();var list=this._dataSource;if(list){list=Array.clone(list);for(var i=list.length-1;i>=0;i--){var data=list[i];var isEmpty=true;if(data){for(var name in data){if(name!="__rowIndex"){isEmpty=false;break;}}} if(isEmpty){Array.removeAt(list,i);} else if(needRowIndex){data.__rowIndex=i;}}} else{list=[];} var buffer=this._editBuffer;if(buffer){var indexes=[];for(var index in buffer){Array.add(indexes,parseInt(index));} indexes.sort(function(a,b){return a-b;});for(var i=0;i<indexes.length;i++){var index=indexes[i];var record=buffer[index];var modified=new Object();var hasData=false;for(var name in record){var value=record[name];modified[name]=value;if(value!=null&&!hasData){hasData=typeof(value)=="string"?value.length>0:true;}} if(hasData){if(needRowIndex){modified.__rowIndex=index;} Array.add(list,modified);}}} return list;}}
Sys.UI.Controls.GridObjectDataController.registerClass('Sys.UI.Controls.GridObjectDataController',Sys.UI.Controls.CustomGridDataController);Sys.UI.Controls.ColumnSortOrder=function(){throw Error.notImplemented();}
Sys.UI.Controls.ColumnSortOrder.prototype={none:0,ascending:1,descending:2}
Sys.UI.Controls.ColumnSortOrder.registerEnum("Sys.UI.Controls.ColumnSortOrder");Sys.UI.Controls.ColumnSummaryKind=function(){throw Error.notImplemented();}
Sys.UI.Controls.ColumnSummaryKind.prototype={none:0,sum:1}
Sys.UI.Controls.ColumnSummaryKind.registerEnum("Sys.UI.Controls.ColumnSummaryKind");Sys.UI.Controls.Column=function(){Sys.UI.Controls.Column.initializeBase(this);this._grid=null;this._params=null;this._allEvents=null;this._elements=null;this._readOnly=false;this._element=null;this._control=null;this._lastCell=null;this._active=false;this._index=-1;this._changeHandler=null;this._enterPressHandler=null;this._lastValue=null;this._visible=null;this._footerReplaceText=null;this._dataField=null;this._displayField=null;this._enabled=true;this._tabStop=true;this._allowSort=true;this._allowConfig=true;this._sortOrder=Sys.UI.Controls.ColumnSortOrder.none;this._bandIndex=-1;this._name=null;this._groupName=null;this._designWidth=null;this._designVisible=true;this._reportVisible=null;this._reportShowFooter=true;this._designCaption=null;this._designReportCaption=null;this._reportField=null;this._allowFilter=true;this._filterType=0;this._dataSize=0;this._headerAlign="";this._textAlign="";this._valueType=Sys.UI.Controls.ValueType._default;this._summaryKind=Sys.UI.Controls.ColumnSummaryKind.none;this._summaryText="";this._useServerSum=true;this._hasServerSum=false;this._headerHint="";this._replaceText=null;this._filterChars=null;}
Sys.UI.Controls.Column.prototype={initialize:function(){Sys.UI.Controls.Column.callBaseMethod(this,'initialize');this._initHeader();this._initFooter();this._initEvents();},dispose:function(){this._disposeControl();this._getHTML=null;this._disposeHeader();delete this._elements;this._changeHandler=null;this._enterPressHandler=null;this._getDisplayTextHandler=null;this._params=null;this._allEvents=null;this._grid=null;Sys.UI.Controls.Column.callBaseMethod(this,'dispose');},_disposeControl:function(){var control=this._control;if(control){var outerElement=control.get_element()._outerElement;if(outerElement){$clearHandlers(outerElement);} control.dispose();this._control=null;} this._element=null;},_disposeHeader:function(){if(this._elements&&this._elements.header){$clearHandlers(this._elements.header);} this._internalDoFormDeactivate();},_internalDoFormDeactivate:function(){if(this._resizer){this._resizer.dispose();this._resizer=null;}},get_headerElement:function(){var elements=this._elements;return elements?elements.header:null;},get_footerElement:function(){var elements=this._elements;return elements?elements.footer:null;},_internalSetElements:function(elements,index){this._disposeHeader();this._elements=elements;this._initHeader();this._index=index;},_initFooter:function(){var summaryText=this.get_summaryText();if(summaryText){this.set_footer(summaryText);}},_initHeader:function(){var headerElement=this.get_headerElement();if(!headerElement)return;var headerHint=this.get_headerHint();if(headerHint){headerElement.title=headerHint;} this._elements.captionElement=$common.getFirstChildByTagName(headerElement,"div");if(this.get_allowSort()){var sortOrder=this.get_sortOrder();if(sortOrder!=Sys.UI.Controls.ColumnSortOrder.none){this._setSortOrder(sortOrder);}} this._internalInitHeader();},_internalInitHeader:function(){var headerElement=this.get_headerElement();if(!headerElement)return;var needMouseOver=false;if(this.get_allowSort()){needMouseOver=true;if(!this._mouseOutAdded){$common.addMouseOutHandler(headerElement,this._doHeaderMouseOut,this);$common.addMouseDownHandler(headerElement,this._doHeaderMouseDown,this);$common.addMouseUpHandler(headerElement,this._doHeaderMouseUp,this);this._mouseOutAdded=true;}} if(this.get_allowResize()){needMouseOver=true;} if(needMouseOver&&!this._mouseOverAdded){$common.addMouseOverHandler(headerElement,this._doHeaderMouseOver,this);this._mouseOverAdded=true;}},_initEvents:function(){var events=this._allEvents;if(events){this._getDisplayTextHandler=events.getDisplayText;} if(this.getIsCommandColumn()){this._grid._internalAddCommandColumn(this);}},getIsCommandColumn:function(){return false;},doReadOnlyDblClick:function(){var events=this._allEvents;if(!events||!this.get_enabled())return;var dblClickHandler=events.dblClick;if(dblClickHandler){dblClickHandler(this);}},_doHeaderMouseOver:function(e){if(this.get_allowSort()){this._initHeaderActive(false);} this._checkInitResizer();},_checkInitResizer:function(){if(this.get_allowResize()){var resizer=this._resizer;if(!resizer){resizer=this._resizer=new Sys.UI.Controls._ColumnResizer(this);resizer.initialize();} else{resizer.initSizeGripper();}}},_doHeaderMouseOut:function(e){if(this.get_allowSort()){this._initHeaderNormal();}},_doHeaderMouseDown:function(e){this._initHeaderActive(true);},_getGridIsResizing:function(){return this._grid._internalGetIsResizing();},_doHeaderMouseUp:function(e){this._initHeaderActive(false);if(this._getGridIsResizing()){return;} this._doSort(this._sortOrder!=Sys.UI.Controls.ColumnSortOrder.ascending?Sys.UI.Controls.ColumnSortOrder.ascending:Sys.UI.Controls.ColumnSortOrder.descending);},_doSort:function(sortOrder,e){var grid=this.get_grid();if(!grid.get_allowSort()||!this.get_dataField())return;if(e&&e.ctrlKey&&this.get_isSorted()){this._setSortOrder(Sys.UI.Controls.ColumnSortOrder.none);} else{grid._clearSort(this);this._setSortOrder(sortOrder);} grid._doSort();},_getHeaderColors:function(type){var skinElement=$skin.getElement("grid","headerColors");return skinElement?skinElement[type]:null;},_initHeaderNormal:function(){var buttonColors=this._getHeaderColors("normal");$common.setBackground(this.get_headerElement(),buttonColors);},_initHeaderActive:function(down){if(!this.get_grid().get_allowSort())return;var headerElement=this.get_headerElement();headerElement.title="按"+this.get_caption()+"排序";var buttonColors=this._getHeaderColors("active");$common.setBackground(headerElement,buttonColors,down);},get_sortOrder:function(){return this._sortOrder;},set_sortOrder:function(value){if(this._sortOrder!=value){this._sortOrder=value;if(this.get_isInitialized()){this._doSort(value);}}},get_isSorted:function Sys$UI$Controls$Column$get_isSorted(){return this._sortOrder!=Sys.UI.Controls.ColumnSortOrder.none;},get_isSortAscending:function Sys$UI$Controls$Column$get_isSortAscending(){return this._sortOrder==Sys.UI.Controls.ColumnSortOrder.ascending;},_clearSort:function Sys$UI$Controls$Column$_clearSort(){if(this.get_isSorted()){this._setSortOrder(Sys.UI.Controls.ColumnSortOrder.none);}},_clearSortOrder:function(){var captionElement=this._elements.captionElement;$common.setStyleFloat(captionElement,"");var headerElement=this.get_headerElement();var div=headerElement.firstChild;headerElement.appendChild(captionElement);$removeNode(div);this._elements.sortFlag=null;},_setSortOrder:function Sys$UI$Controls$Column$_setSortOrder(sortOrder){this._sortOrder=sortOrder;var sortFlagElement=this._elements.sortFlag;if(!sortFlagElement){var headerElement=this.get_headerElement();var div=$common.createDiv();var captionElement=this._elements.captionElement;$common.setStyleFloat(captionElement,"left");div.appendChild(captionElement);var sortDiv=$common.createDiv();sortDiv.className="GridHeaderSortShape";$common.setStyleFloat(sortDiv,"right");div.appendChild(sortDiv);sortFlagElement=this._elements.sortFlag=sortDiv;headerElement.appendChild(div);} var html="";var skinImage=$skin.getImage("grid","sortShape");switch(sortOrder){case Sys.UI.Controls.ColumnSortOrder.none:this._clearSortOrder();return;case Sys.UI.Controls.ColumnSortOrder.ascending:html=$common.getGlyphDivHTML(skinImage,1);break;case Sys.UI.Controls.ColumnSortOrder.descending:html=$common.getGlyphDivHTML(skinImage,0);break;} sortFlagElement.innerHTML=html;},get_grid:function(){return this._grid;},get_owner:function(){return this._grid;},get_form:function(){return this.get_grid().get_form();},get_index:function(){return this._index;},set_index:function(value){this._index=value;},get_bandIndex:function(){return this._bandIndex;},set_bandIndex:function(value){this._bandIndex=value;},get_band:function(){var band=this._band;return band?band:this._grid.getBandByIndex(this.get_bandIndex());},set_band:function(value){this._band=value;},get_designVisible:function(){return this._designVisible;},set_designVisible:function(value){this._designVisible=value;if(this.get_isInitialized()){this._params.properties.designVisible=value;}},get_visible:function(){var answer=this._visible;if(answer==null){answer=this._visible=this._grid._internalGetColumnVisible(this);} return answer;},set_visible:function(value,saveConfig){if(value!=this.get_visible()){this._visible=value;this._grid._internalSetColumnVisible(this,value,saveConfig);}},get_designCaption:function(){return this._designCaption;},set_designCaption:function(value){this._designCaption=value;},get_caption:function(){return this._grid._internalGetColumnCaption(this);},set_caption:function(value,saveConfig){if(value!=this.get_caption()){this._grid._internalSetColumnCaption(this,value,saveConfig);}},get_designReportCaption:function(){var answer=this._designReportCaption;if(!answer){answer=this._designCaption;if(!answer){answer=this.get_caption();}} return answer;},set_designReportCaption:function(value){this._designReportCaption=value;},get_reportCaption:function(){var answer=this._designReportCaption;return answer?answer:this.get_caption();},get_reportVisible:function(){var answer=this._reportVisible;return answer==null?this.get_visible():answer;},set_reportVisible:function(value){this._reportVisible=value;},get_reportShowFooter:function(){return this._reportShowFooter;},set_reportShowFooter:function(value){this._reportShowFooter=value;},get_reportField:function(){var reportField=this._reportField;if(!reportField){reportField=this.get_designReportCaption();var bandIndex=this.get_bandIndex();if(bandIndex>=0){var band=this._grid.getBandByIndex(bandIndex);if(band){var prefix=band.reportField;if(!prefix){prefix=band.caption;} reportField=prefix+reportField;} else{reportField=reportField+(bandIndex+1).toString();}}} return reportField;},set_reportField:function(value){this._reportField=value;},_internalRefreshCaption:function(){var captionElement=this._elements.captionElement;if(captionElement){var caption=this.get_caption();if(this._grid.get_useMultiRowCaption()){caption=this._getMultiRowCaption(caption);captionElement.style.padding="0px";} else{captionElement.style.padding="";} captionElement.innerHTML=caption;}},_getMultiRowCaption:function(caption){var html="";var rows=caption.split("｜");var lineColor=this._grid._skinColors.headerLine;for(var i=0,count=rows.length;i<count;i++){var style;if(i!=count-1){style=" style=\"border-bottom: 1px solid "+lineColor+"\"";} else{style="";} var div="<div"+style+">"+rows[i]+"</div>";html+=div;} return html;},get_summaryValue:function(value){return this._summaryValue;},set_summaryValue:function(value){this._summaryValue=value;},get_footer:function(){var text=this.get_footerReplaceText();if(!text){text=this.get_replaceText();} var footer=this._footer||"";if(text){var grid=this.get_grid();if(!grid.get_readOnly()){var rowCount=grid.get_rowCount();for(var i=0;i<rowCount;i++){if(this.getCellText(i)==text)return text;} return footer;} return text;} return footer;},set_footer:function(value){this._footer=value;this._internalRefreshFooter();},_internalRefreshFooter:function(){this.doRefreshFooter();},doRefreshFooter:function(){var footerElement=this.get_footerElement();if(footerElement){var element=footerElement.firstChild;element.innerHTML=this.get_footer();}},get_readOnly:function(){return this._readOnly||this._grid.get_readOnly()||!this.get_enabled();},set_readOnly:function(value){this._readOnly=value;},get_enabled:function(){return this._enabled;},set_enabled:function(value){if(this._enabled!=value){this._enabled=value;if(this.get_isInitialized()){var grid=this._grid;if(!value){grid._hideEditor();} grid._internalRefreshColumnStyle(this);}}},get_tabStop:function(){return this._tabStop;},set_tabStop:function(value){this._tabStop=value;},get_allowSort:function(){var gridAllowSort=this.get_grid().get_allowSort();var allowSort=this._allowSort;return gridAllowSort&&allowSort;},set_allowSort:function(value){this._allowSort=value;},get_allowResize:function(){return this.get_grid().get_allowResize();},get_allowConfig:function(){return this._allowConfig;},set_allowConfig:function(value){this._allowConfig=value;},get_filterType:function(){return this._filterType;},set_filterType:function(value){this._filterType=value;},get_params:function(){return this._params;},get_control:function(){return this._control;},get_name:function(){return this._name;},set_name:function(value){this._name=value;},get_groupName:function(){return this._groupName;},set_groupName:function(value){this._groupName=value;},get_dataField:function(){return this._dataField;},set_dataField:function(value){this._dataField=value;},get_displayField:function(){return this._displayField;},set_displayField:function(value){this._displayField=value;},get_dataSize:function(){return this._dataSize;},set_dataSize:function(value){this._dataSize=value;},get_designWidth:function(){return this._designWidth;},set_designWidth:function(value){this._designWidth=value;},get_width:function(){return this._grid._internalGetColumnWidth(this);},set_width:function(value,saveConfig){var oldWidth=this.get_width();if(value!=oldWidth){this._grid._internalSetColumnWidth(this,value,oldWidth,saveConfig);}},get_headerAlign:function(){return this._headerAlign;},set_headerAlign:function(value){this._headerAlign=value;},get_textAlign:function(){return this._textAlign;},set_textAlign:function(value){this._textAlign=value;},get_valueType:function(){return this._valueType;},set_valueType:function(value){this._valueType=value;},get_summaryKind:function(){return this._summaryKind;},set_summaryKind:function(value){this._summaryKind=value;if(value!=Sys.UI.Controls.ColumnSummaryKind.none){this._useServerSum=false;} if(this.get_isInitialized()&&value==Sys.UI.Controls.ColumnSummaryKind.sum){this._grid._hasSummaryColumn=true;}},get_summaryText:function(){return this._summaryText;},set_summaryText:function(value){this._summaryText=value;},get_headerHint:function(){return this._headerHint;},set_headerHint:function(value){this._headerHint=value;},createControlElement:function(){var element=$common.createInput();element.type="text";element.id=this._grid.get_id()+"_"+this.get_name();return element;},getControlType:function(){throw Error.notImplemented();},get_immediateEditor:function(){return false;},_hasEditor:function(){return this._lastCell!=null;},get_isEditing:function(){return this._hasEditor();},_getCellRowIndex:function(cell){var row=cell.parentNode;return this._grid._getRowIndex(row);},_revalidate:function Sys$UI$Controls$Column$_revalidate(cell,value){var validationManager=this._grid.get_form().get_validationManager();if(validationManager.checkResultsVisible(this._grid)&&validationManager.checkResultsVisible(this)){var rowIndex=this._getCellRowIndex(cell);this._grid._validateColumn(rowIndex,this,value);validationManager.showResults();}},initCellHTML:function(rowIndex,cell){if(!this._lastCell||this._lastCell!=cell){var isCommandColumn=this.getIsCommandColumn();if(isCommandColumn){var element=cell.firstChild;if(element&&element.tagName){$clearHandlers(element);}} cell.innerHTML=this._getCellHTML(rowIndex);if(isCommandColumn){this.initCellEvent(rowIndex,cell);var row=cell.parentNode;this._grid._internalSetRowState(row);}} else{var value=this.doInitControlValue(rowIndex);this.doAfterInitControlValue(value);}},doAfterInitControlValue:function(value){this._lastValue=value;},_instantValidate:function(){var control=this._control;if(control.doInstantValidate){control.doInstantValidate();}},_hideEditor:function Sys$UI$Controls$Column$_hideEditor(){var lastCell=this._lastCell;if(lastCell){var control=this._control;if(control.get_droppedDown&&control.get_droppedDown()){control.closeUp();} this._instantValidate();lastCell.removeChild(this._element);lastCell.className="GridBodyCell";var grid=this._grid;grid._initCellStyle(this.get_index(),lastCell);var changed=this._changed;var newValue;var lastValue;if(changed){lastValue=this._lastValue;newValue=this._saveCellValue(lastCell);if(typeof(newValue)=="boolean"&&!lastValue){lastValue=false;} changed=newValue!=lastValue;} this._lastCell=null;var row=lastCell.parentNode;this.initCellHTML(grid._getRowIndex(row),lastCell);if(changed){this._raiseChange(lastCell,newValue,lastValue);} this._raiseBlur();}},get_bounds:function(){var cell=this._grid._getSelectedRowCell(this._index);if(cell){return Sys.UI.DomElement.getBounds(cell);} else if(this._control){return this._control.get_bounds();} else{return null;}},focus:function(){if(!this._readOnly&&this._index>=0){var cell=this._grid._getSelectedRowCell(this._index);if(cell){this._showEditor(cell);}}},_doFocus:function(){var control=this._control;window.asyncCall(function(){control.focus(true);});},_showEditor:function Sys$UI$Controls$Column$_showEditor(cell){this._doShowEditor(cell,true);},_doShowEditor:function Sys$UI$Controls$Column$_doShowEditor(cell,focus){var lastCell=this._lastCell;if(lastCell){if(cell==lastCell){this._doFocus();return;} this._hideEditor();} var row=cell.parentNode;var editorHeight=20;if(!row.style.height){var rowHeight=row.offsetHeight;row.style.height=(rowHeight>editorHeight?rowHeight:editorHeight)+"px";} var firstChild=cell.firstChild;if(firstChild&&firstChild.tagName=="INPUT"){firstChild.style.display="none";window.asyncCall(function(){$clearHandlers(firstChild);$removeNode(firstChild);});} else{cell.innerHTML="";} cell.className="GridInplaceCell";var element=this._element;if(!element){element=this.createControlElement();var style=element.style;if(element.type=="text"){style.backgroundColor=$skin.getControlBackgroundColor();style.borderStyle="none";if(Sys.Browser.isIE){style.padding="1px 3px 1px 3px";if(!Sys.Browser.isIE8){style.margin="-1px 0px";}} else{style.padding="4px 3px 1px 2px";}} else{}} var editorWidth=cell.offsetWidth;if(!editorWidth){throw Error.invalidOperation("取不到列的宽度: "+this.get_name());} if(element.type=="text"){if(Sys.Browser.isIE){editorWidth-=6;editorHeight-=2;} else{editorWidth-=5;editorHeight-=5;}} else if(element.type=="checkbox"){if(Sys.Browser.isStandard){editorWidth-=6;editorHeight-=6;}} element.style.width=editorWidth+"px";element.style.height=editorHeight+"px";cell.appendChild(element);if(!this._control){var props=new Object();props.tabOnEnter=false;props.isInPlace=true;this.initControlProps(props);var events=this._allEvents;if(events){this._changeHandler=events.change;if(this.needHandleEnterPress()){this._enterPressHandler=events.enterPress;delete events.enterPress;} delete events.change;delete events.getDisplayText;} else{events=new Object();this._changeHandler=null;this._enterPressHandler=null;} this._blurHandler=events.blur;events.blur=Function.createDelegate(this,this._blur);events.focus=Function.createDelegate(this,this._focus);if(this.needHandleKeyDown()){events.keyDown=Function.createDelegate(this,this.doKeyDown);} var control=this._control=$create(this.getControlType(),props,element,events,this._grid.get_form(),true);var outerElement=element._outerElement;this._element=outerElement?outerElement:element;control.column=this;control.add_change(Function.createDelegate(this,this._change));$common.addMouseOverHandler(this._element,this._stopPropagation);$common.addMouseOutHandler(this._element,this._stopPropagation);$common.addMouseDownHandler(this._element,this._stopPropagation);$common.addMouseUpHandler(this._element,this._stopPropagation);} else{var controlElement=this._control.get_element();if(controlElement._outerElement){controlElement.style.width=(editorWidth-20-6)+"px";}} this._initControlValue(cell);if(focus){this._doFocus();} this._lastCell=cell;this._active=true;this._changed=true;},_stopPropagation:function(e){e.stopPropagation();},initControlProps:function(controlProps){},focusNextCell:function(){this._grid._focusNextCell(this,this._lastCell);},focusPrevCell:function(){return this._grid._focusPrevCell(this._lastCell);},doKeyDown:function Sys$UI$Controls$Column$doKeyDown(e){var result=false;var grid=this._grid;var keyCode=e.keyCode;switch(keyCode){case Sys.UI.Key.enter:if(!grid.doRowEnterPress(e)){this.doTabOnEnter();} result=true;break;case Sys.UI.Key.tab:if(e.shiftKey&&this.focusPrevCell()){result=true;} break;case Sys.UI.Key.right:if(!this._grid.doRowKeyDown(e))result=this._handleLeftRight(true,false);break;case Sys.UI.Key.left:if(!this._grid.doRowKeyDown(e))result=this._handleLeftRight(false,false);break;case Sys.UI.Key.end:result=this._handleLeftRight(true,true);break;case Sys.UI.Key.home:result=this._handleLeftRight(false,true);break;} if(result){e.cancel();}},_handleLeftRight:function(right,endOrHome){var control=this._control;if(!control)return false;var caretPos=0;var isTextEdit=control.get_isTextEdit();if(isTextEdit){caretPos=control.get_caretPos();} if(control.get_droppedDown&&control.get_droppedDown()){return false;} if(right){var textLen=0;if(isTextEdit){var selectionText=control.get_selectionText();if(selectionText){caretPos=0;} textLen=control.get_text().length;} if(!isTextEdit||caretPos==textLen){if(!endOrHome){this.focusNextCell();return true;} else{return this._grid._internalFocusSelectedRowLastCell();}}} else{if(!isTextEdit||caretPos==0){if(!endOrHome){return this.focusPrevCell();} else{return this._grid._internalFocusSelectedRowFirstCell();}}} return false;},_raiseBlur:function(){if(this._blurHandler){this._blurHandler(this._control);}},_focus:function(e){if(!this._active){this._active=true;this._changed=true;}},_blur:function(e){this._active=false;this._raiseBlur();var grid=this._grid;window.setTimeout(function(){if(grid.get_isDisposed()){return;} var gridBlur=false;var form=grid.findForm();if(form){var focusedControl=form.get_focusedControl();if(focusedControl){if(focusedControl.get_owner){var controlOwner=focusedControl.get_owner();gridBlur=controlOwner!=grid;} else{gridBlur=true;}} else{gridBlur=false;}} if(gridBlur){grid._blurFormColumn();}},100);},_change:function Sys$UI$Controls$Column$_change(sender,e){var cell=this._lastCell;if(cell){this._instantValidate();var lastValue=this._lastValue;var value=this._saveCellValue(cell);if(value!=lastValue){this._raiseChange(cell,value,lastValue);}}},add_change:function(handler){this.get_events().addHandler("_change",handler);},remove_change:function(handler){this.get_events().removeHandler("_change",handler);},_raiseChange:function Sys$UI$Controls$Column$_raiseChange(cell,value,oldValue){if(this.get_isDisposed()){return;} var grid=this._grid;var form=grid.get_form();if(form&&form.get_isDisposing()){return;} var rowIndex=cell?this._getCellRowIndex(cell):grid.get_mouseHoverRowIndex();var eventArgs=new Sys.UI.Controls.GridColumnChangeEventArgs(rowIndex,value,oldValue);if(this._changeHandler){this._changeHandler(this,eventArgs);} var handler=this.get_events().getHandler("_change");if(handler){handler(this,eventArgs);} if(eventArgs.get_valueChanged()){value=eventArgs.get_value();this._saveCellValue(cell,value);this.initCellHTML(rowIndex,cell);} if(cell){this._revalidate(cell,value);} this._checkCalcSummary();var focusColumn=eventArgs.get_focusColumn();if(focusColumn){window.asyncCall(function(){grid.focusRowColumn(rowIndex,focusColumn);});}},_checkCalcSummary:function(){var summaryKind=this.get_summaryKind();if(summaryKind==Sys.UI.Controls.ColumnSummaryKind.sum){var grid=this._grid;if(this._hasServerSum){grid._internalSetNeedPreloadItems(true);} grid._internalCalcColumnSummary(this);}},get_useServerSum:function(){return this._useServerSum;},set_useServerSum:function(value){this._useServerSum=value;if(!value&&this._hasServerSum){this._hasServerSum=false;this._grid._internalSetNeedPreloadItems(false);}},_internalSetHasServerSum:function(value){this._hasServerSum=value;},get_isClientSum:function(){var summaryKind=this.get_summaryKind();return summaryKind==Sys.UI.Controls.ColumnSummaryKind.sum;},needHandleEnterPress:function(){return true;},needHandleKeyDown:function(){return true;},doTabOnEnter:function(){if(!this.needHandleEnterPress())return;var focusNext=true;if(this._enterPressHandler){var eventArgs=new Sys.UI.Controls.EnterPressEventArgs();this._enterPressHandler(this._control,eventArgs);focusNext=eventArgs.get_focusNext();} if(focusNext){this.focusNextCell();}},_getDataController:function(){return this._grid.get_dataController();},getCellValue:function(rowIndex){return this._getDataController().getCellValue(rowIndex,this);},_initControlValue:function(cell){var row=cell.parentNode;var rowIndex=this._grid._getRowIndex(row);var value=this.doInitControlValue(rowIndex);this._lastValue=value;},doInitControlValue:function(rowIndex){var value=this.getCellValue(rowIndex);value=this.loadEditValue(value);this._control.set_value(value);if(this.get_displayField()){var text=this.getCellText(rowIndex);this._control.set_text(text);} return value;},getCellText:function(rowIndex){var value=this.getCellValue(rowIndex);return this._doGetCellText(rowIndex,value);},get_footerReplaceText:function(){return this._footerReplaceText;},set_footerReplaceText:function(value){this._footerReplaceText=value;if(this.get_isInitialized()){this._internalRefreshFooter();}},get_replaceText:function(){return this._replaceText;},set_replaceText:function(value,disableRefresh){this._replaceText=value;if(this.get_isInitialized()&&!disableRefresh){this._grid._internalRefreshColumnContent(this);}},_doGetCellText:function(rowIndex,value){var text=this.get_replaceText();if(!text){text=this._getDataController().getCellText(rowIndex,this,value);text=this.getDisplayText(value,text);if(this._getDisplayTextHandler){var eventArgs=new Sys.UI.Controls.GridGetDisplayTextEventArgs(rowIndex,value,text);this._getDisplayTextHandler(this,eventArgs);text=eventArgs.get_text();}} else if(value==null){text="";} return text;},_getCellHTML:function(rowIndex){if(this.get_visible()){var value=this.getCellValue(rowIndex);var text=this._doGetCellText(rowIndex,value);return this.getHTML(value,text);} else{return"";}},internalGetCellHTML:function(rowIndex){var value=this.getCellValue(rowIndex);var text=this._doGetCellText(rowIndex,value);return this.getHTML(value,text);},getDisplayText:function(value,text){return text;},_internalGetTextHTML:function(text){var grid=this._grid;return Sys.UI.Controls.Column.getHTML(text,grid.get_textColor(),!grid.get_wordWrap(),grid.get_allowCopy());},_internalGetTextHTMLWithBlank:function(text){if(text&&typeof(text)=="string"){text=text.replace(/\s/g,"&nbsp;");} return this._internalGetTextHTML(text);},getHTML:function(value,text){return this._internalGetTextHTML(text);},initNewRecord:function(data){var dataField=this.get_dataField();if(dataField){var defaultValue=this.getDefaultValue();if(defaultValue!=undefined){data[dataField]=defaultValue;}}},getDefaultValue:function(){return undefined;},loadEditValue:function(value){return value;},saveEditValue:function(value){return value;},_setCellValue:function(rowIndex,value){value=this.saveEditValue(value);this._getDataController().setCellValue(rowIndex,this,value);},_clearChanged:function(){this._changed=false;},getControlValue:function(control){return control.get_value();},_saveCellValue:function(cell,value){var row=cell.parentNode;var control=this._control;if(typeof(value)=="undefined"){value=this.getControlValue(control);} if(control.convertType){value=control.convertType(value,this.get_valueType());} this._setCellValue(this._grid._getRowIndex(row),value);this._clearChanged();this._lastValue=value;return value;},get_value:function(){var control=this._control;return control?this.getControlValue(control):this._lastValue;},set_value:function(value){var control=this._control;if(control){control.set_value(value);} else{this._lastValue=value;}},get_allowFilter:function(){return this._allowFilter;},set_allowFilter:function(value){this._allowFilter=value;},canFilter:function(){return this.get_allowFilter();}}
Sys.UI.Controls.Column.registerClass('Sys.UI.Controls.Column',Sys.Component);Sys.UI.Controls.Column.getHTML=function(text,textColor,noWrap,allowCopy){if(!text&&!text.toString())text="&nbsp;";var style="";if(textColor||noWrap){style=" style=\"";if(textColor){style+="color:"+textColor+";";} if(noWrap){style+="white-space:nowrap;overflow:hidden;";} style+="\"";} var disableCopy=allowCopy?"":" unselectable=\"on\"";return"<div class=\"GridBodyCellText\""+disableCopy+style+">"+text+"</div>";}
Sys.UI.Controls.TextColumn=function(){Sys.UI.Controls.TextColumn.initializeBase(this);this._maxLength=0;this._maxByteLength=0;this._filterChars=null;this._allowTags=false;}
Sys.UI.Controls.TextColumn.prototype={getControlType:function(){return Sys.UI.Controls.TextEdit;},get_dataSize:function(){var answer=Sys.UI.Controls.TextColumn.callBaseMethod(this,'get_dataSize');return answer>0?answer:this.get_maxLength();},get_maxLength:function(){return this._maxLength;},set_maxLength:function(value){this._maxLength=value;},get_filterChars:function(){return this._filterChars;},set_filterChars:function(value){this._filterChars=value;},get_allowTags:function(){return this._allowTags;},set_allowTags:function(value){this._allowTags=value;},get_maxByteLength:function(){return this._maxByteLength;},set_maxByteLength:function(value){this._maxByteLength=value;},initControlProps:function(controlProps){controlProps.maxLength=this.get_maxLength();controlProps.maxByteLength=this.get_maxByteLength();controlProps.allowTags=this.get_allowTags();var filterChars=this.get_filterChars();if(filterChars){controlProps.filterChars=filterChars;}},getHTML:function(value,text){return this._internalGetTextHTMLWithBlank(text);}}
Sys.UI.Controls.TextColumn.registerClass('Sys.UI.Controls.TextColumn',Sys.UI.Controls.Column);Sys.UI.Controls.NumberColumn=function(){Sys.UI.Controls.NumberColumn.initializeBase(this);this._numberType=Sys.UI.Controls.NumberType._float;this._decimalPrecision=0;this._decimalScale=0;this._decimalDigits=0;this._displayThousandSeperator=false;this._displayEmptyForZero=false;}
Sys.UI.Controls.NumberColumn.prototype={getControlType:function(){return Sys.UI.Controls.NumberEdit;},get_numberType:function(){return this._numberType;},set_numberType:function(value){this._numberType=value;if(this._control){this._control.set_numberType(value);}},get_decimalDigits:function(){return this._decimalDigits;},set_decimalDigits:function(value){this._decimalDigits=value;},get_decimalPrecision:function(){return this._decimalPrecision;},set_decimalPrecision:function(value){this._decimalPrecision=value;},get_decimalScale:function(){return this._decimalScale;},set_decimalScale:function(value){this._decimalScale=value;},initControlProps:function(controlProps){controlProps.numberType=this.get_numberType();controlProps.decimalDigits=this.get_decimalDigits();controlProps.decimalPrecision=this.get_decimalPrecision();controlProps.decimalScale=this.get_decimalScale();},get_displayThousandSeperator:function(){return this._displayThousandSeperator;},set_displayThousandSeperator:function(value){this._displayThousandSeperator=value;},get_displayEmptyForZero:function(){return this._displayEmptyForZero;},set_displayEmptyForZero:function(value){this._displayEmptyForZero=value;},formatNumber:function(value){return $common.formatNumber(value,this.get_decimalDigits(),this.get_decimalScale(),this.get_displayThousandSeperator(),this.get_displayEmptyForZero());},getDisplayText:function(value,text){return this.formatNumber(value);}}
Sys.UI.Controls.NumberColumn.registerClass('Sys.UI.Controls.NumberColumn',Sys.UI.Controls.Column);Sys.UI.Controls.PercentColumn=function(){Sys.UI.Controls.PercentColumn.initializeBase(this);}
Sys.UI.Controls.PercentColumn.prototype={get_readOnly:function(){return true;},getDisplayText:function(value,text){var text=$common.formatNumber(value,this.get_decimalDigits(),this.get_decimalScale());return text?text+"%":text;}}
Sys.UI.Controls.PercentColumn.registerClass('Sys.UI.Controls.PercentColumn',Sys.UI.Controls.NumberColumn);Sys.UI.Controls.DateColumn=function(){Sys.UI.Controls.DateColumn.initializeBase(this);}
Sys.UI.Controls.DateColumn.prototype={getControlType:function(){return Sys.UI.Controls.DateEdit;},initControlProps:function(controlProps){controlProps.valueType=this.get_valueType();},getDisplayText:function(value,text){if(typeof(value)=="string"){value=Date.strToDate(value);} return Date.dateToStr(value);}}
Sys.UI.Controls.DateColumn.registerClass('Sys.UI.Controls.DateColumn',Sys.UI.Controls.Column);Sys.UI.Controls.DateTimeColumn=function(){Sys.UI.Controls.DateTimeColumn.initializeBase(this);}
Sys.UI.Controls.DateTimeColumn.prototype={get_readOnly:function(){return true;},getDisplayText:function(value,text){return typeof(value)=="string"?value:Date.dateTimeToStr(value);}}
Sys.UI.Controls.DateTimeColumn.registerClass('Sys.UI.Controls.DateTimeColumn',Sys.UI.Controls.Column);Sys.UI.Controls.SelectorColumn=function(){Sys.UI.Controls.SelectorColumn.initializeBase(this);this._selectorPage=null;this._selectorWidth=0;this._selectorHeight=0;this._selectorType=null;this._filterChars=null;this._allowTags=false;this._selectOnly=false;this._allowHandInput=false;this._shortcut=0;this._maxByteLength=0;}
Sys.UI.Controls.SelectorColumn.prototype={getControlType:function(){return Sys.UI.Controls.SelectorEdit;},get_selectorPage:function(){return this._selectorPage;},set_selectorPage:function(value){this._selectorPage=value;},get_selectorWidth:function(){return this._selectorWidth;},set_selectorWidth:function(value){this._selectorWidth=value;},get_selectorHeight:function(){return this._selectorHeight;},set_selectorHeight:function(value){this._selectorHeight=value;},get_selectorType:function(){return this._selectorType;},set_selectorType:function(value){this._selectorType=value;},get_selectOnly:function(){return this._selectOnly;},set_selectOnly:function(value){this._selectOnly=value;},get_allowHandInput:function(){return this._allowHandInput;},set_allowHandInput:function(value){this._allowHandInput=value;},get_shortcut:function(){return this._shortcut;},set_shortcut:function(value){this._shortcut=value;},get_maxByteLength:function(){return this._maxByteLength;},set_maxByteLength:function(value){this._maxByteLength=value;},add_buttonClick:function(handler,handlerOwner){return this.get_events().addHandler('buttonClick',handler,handlerOwner);},remove_buttonClick:function(handler){this.get_events().removeHandler('buttonClick',handler);},doAfterInitControlValue:function(value){},needHandleEnterPress:function(){return false;},doButtonClick:function(){var handler=this.get_events().getHandler('buttonClick');if(handler){handler(this);}},add_selectorInit:function(handler,handlerOwner){return this.get_events().addHandler("selectorInit",handler,handlerOwner);},remove_selectorInit:function(handler){this.get_events().removeHandler("selectorInit",handler);},doSelectorInit:function(eventArgs){var handler=this.get_events().getHandler("selectorInit");if(handler){handler(this,eventArgs);}},add_selectorLoaded:function(handler,handlerOwner){return this.get_events().addHandler("selectorLoaded",handler,handlerOwner);},remove_selectorLoaded:function(handler){this.get_events().removeHandler("selectorLoaded",handler);},doSelectorLoaded:function(eventArgs){var handler=this.get_events().getHandler("selectorLoaded");if(handler){handler(this,eventArgs);}},add_selectorSelected:function(handler,handlerOwner){return this.get_events().addHandler("selectorSelected",handler,handlerOwner);},remove_selectorSelected:function(handler){this.get_events().removeHandler("selectorSelected",handler);},doSelectorSelected:function(eventArgs){var handler=this.get_events().getHandler("selectorSelected");if(handler){handler(this,eventArgs);}},add_selectorBeforeSelected:function(handler,handlerOwner){return this.get_events().addHandler("selectorBeforeSelected",handler,handlerOwner);},remove_selectorBeforeSelected:function(handler){this.get_events().removeHandler("selectorBeforeSelected",handler);},doSelectorBeforeSelected:function(eventArgs){var handler=this.get_events().getHandler("selectorBeforeSelected");if(handler){handler(this,eventArgs);}},initControlProps:function(controlProps){Sys.UI.Controls.SelectorColumn.copyProps(this,controlProps);},get_filterChars:function(){return this._filterChars;},set_filterChars:function(value){this._filterChars=value;},get_allowTags:function(){return this._allowTags;},set_allowTags:function(value){this._allowTags=value;},getControlValue:function(control){var text=control.get_text();return text?control.get_value():null;},getInputAction:function(){return"选择";},getHTML:function(value,text){return this._internalGetTextHTMLWithBlank(text);}}
Sys.UI.Controls.SelectorColumn.registerClass('Sys.UI.Controls.SelectorColumn',Sys.UI.Controls.Column);Sys.UI.Controls.SelectorColumn.copyProps=function(column,controlProps){controlProps.displayField=column.get_displayField();controlProps.selectorPage=column.get_selectorPage();controlProps.selectorType=column.get_selectorType();controlProps.selectorWidth=column.get_selectorWidth();controlProps.selectorHeight=column.get_selectorHeight();var selectOnly=column.get_selectOnly();controlProps.selectOnly=selectOnly;if(selectOnly){controlProps.readOnly=true;} controlProps.allowHandInput=column.get_allowHandInput();controlProps.shortcut=column.get_shortcut();var maxByteLength=column.get_maxByteLength();if(maxByteLength>0){controlProps.maxByteLength=maxByteLength;} controlProps.allowTags=column.get_allowTags();var filterChars=column.get_filterChars();if(filterChars){controlProps.filterChars=filterChars;}}
Sys.UI.Controls.DropDownColumn=function(){Sys.UI.Controls.DropDownColumn.initializeBase(this);this._items=null;this._dropDownStyle=Sys.UI.Controls.DropDownStyle.dropDown;this._dataValueField=null;this._dataTextField=null;}
Sys.UI.Controls.DropDownColumn.prototype={getControlType:function(){return Sys.UI.Controls.DropDownEdit;},get_dropDownStyle:function(){return this._dropDownStyle;},set_dropDownStyle:function(value){this._dropDownStyle=value;},initControlProps:function(controlProps){controlProps.items=this.get_items();controlProps.dataValueField=this.get_dataValueField();controlProps.dataTextField=this.get_dataTextField();controlProps.dropDownStyle=this.get_dropDownStyle();},getDefaultValue:function(){return this._defaultValue;},get_defaultValue:function(){return this._defaultValue;},set_defaultValue:function(value){this._defaultValue=value;},get_items:function(){return this._items;},set_items:function(value){this._items=value;if(this.get_isInitialized()){if(this._hasEditor()){this._hideEditor();} if(this.get_control()){this.get_control().set_items(value);}}},get_itemData:function(){var items=this.get_items();if(items){var valueField=this.get_dataValueField();var textField=this.get_dataTextField();var data={};for(var i=0,count=items.length;i<count;i++){var item=items[i];var value=item[valueField];var text=item[textField];data[value]=text;} return data;} return null;},get_hasItems:function(){var items=this.get_items();return items&&items.length>0;},get_dataValueField:function(){return this._dataValueField;},set_dataValueField:function(value){this._dataValueField=value;},get_dataTextField:function(){return this._dataTextField;},set_dataTextField:function(value){this._dataTextField=value;},add_dropDown:function(handler){this.get_events().addHandler("dropDown",handler);},remove_dropDown:function(handler){this.get_events().removeHandler("dropDown",handler);},doDropDown:function(){var handler=this.get_events().getHandler("dropDown");if(handler){handler(this);}},getDisplayText:function(value,text){return Sys.UI.Controls.DropDownEdit.getItemTextByValue(this.get_items(),this.get_dataValueField(),this.get_dataTextField(),value);},getInputAction:function(){return"选择";}}
Sys.UI.Controls.DropDownColumn.registerClass('Sys.UI.Controls.DropDownColumn',Sys.UI.Controls.Column);Sys.UI.Controls.CheckBoxColumn=function(){Sys.UI.Controls.CheckBoxColumn.initializeBase(this);this._textChecked=null;this._textUnchecked=null;this._skinImage=null;this._checks=new Object();this._doClick=Function.createDelegate(this,this._click);this._doMouseDown=Function.createDelegate(this,this._mouseDown);}
Sys.UI.Controls.CheckBoxColumn.prototype={initialize:function(){Sys.UI.Controls.CheckBoxColumn.callBaseMethod(this,'initialize');if(this.get_readOnly()){$skin.cacheImage("grid","checkShape");}},dispose:function(){this._skinImage=null;delete this._checks;this._doClick=null;this._doMouseDown=null;Sys.UI.Controls.CheckBoxColumn.callBaseMethod(this,'dispose');},getIsCommandColumn:function(){return true;},getControlType:function(){return Sys.UI.Controls.CheckBox;},get_textChecked:function(){return this._textChecked;},set_textChecked:function(value){this._textChecked=value;},get_textUnchecked:function(){return this._textUnchecked;},set_textUnchecked:function(value){this._textUnchecked=value;},get_immediateEditor:function(){return this.get_visible()&&!this._readOnly;},createControlElement:function(){var element=$common.createCheckBox();return element;},getEditable:function(cell){if(cell){var element=cell.firstChild;if(element&&element.tagName){return Sys.UI.DomElement.getEnabled(element);}} return true;},setEditable:function(value,cell){if(this._lastCell==cell){this._hideEditor();} if(cell){var element=cell.firstChild;if(element){Sys.UI.DomElement.setEnabled(element,value);}}},getHTML:function(value,text){if(value===null){return"";} else{var html;if(this.get_readOnly()){var imageIndex=value?1:0;var html=this._checks[imageIndex];if(!html){var textChecked=this.get_textChecked();var textUnchecked=this.get_textUnchecked();if(value&&textChecked){html=this._internalGetTextHTML(textChecked);} else if(!value&&textUnchecked){html=this._internalGetTextHTML(textUnchecked);} else{if(!this._skinImage){this._skinImage=$skin.getImage("grid","checkShape");} html=$common.getGlyphDivHTML(this._skinImage,imageIndex);} this._checks[imageIndex]=html;}} else{html='<input type="checkbox" '+(value?' checked':'')+'>';} return html;}},initCellEvent:function(rowIndex,cell){if(!this.get_readOnly()&&cell!=this._lastCell){var element=cell.firstChild;if(element&&element.tagName&&!element._hasEvent){element._rowIndex=rowIndex;$common.addMouseUpHandler(element,this._doClick);$common.addMouseDownHandler(element,this._doMouseDown);element._hasEvent=true;}}},_mouseDown:function(e){this._isMouseDown=true;},_click:function(e){if(!this._isMouseDown){e.cancel();return;} this._isMouseDown=false;var rowIndex=e.target._rowIndex;if(rowIndex>=0){var value=this.getCellValue(rowIndex);var value=value?false:true;this._setCellValue(rowIndex,value);var grid=this._grid;var control=this._control;if(control){grid._setActiveRowIndex(rowIndex);if(rowIndex!=grid.get_selectedRowIndex()){grid.set_selectedRowIndex(rowIndex);} control._changeChecked(value);this._raiseChange(null,value,!value);} else{var events=this._allEvents;if(events){this._changeHandler=events.change;} this._lastValue=value;this._raiseChange(null,value,!value);} grid._rowsMouseUp(e);}}}
Sys.UI.Controls.CheckBoxColumn.registerClass('Sys.UI.Controls.CheckBoxColumn',Sys.UI.Controls.Column);Sys.UI.Controls.MultiSelectColumn=function(){Sys.UI.Controls.MultiSelectColumn.initializeBase(this);this._toggleByClickRow=false;}
Sys.UI.Controls.MultiSelectColumn.prototype={get_toggleByClickRow:function(){return this._toggleByClickRow;},set_toggleByClickRow:function(value){this._toggleByClickRow=value;}}
Sys.UI.Controls.MultiSelectColumn.registerClass('Sys.UI.Controls.MultiSelectColumn',Sys.UI.Controls.Column);Sys.UI.Controls.MultiSelectColumn.registerClass('Sys.UI.Controls.MultiSelectColumn',Sys.UI.Controls.CheckBoxColumn);Sys.UI.Controls.ButtonColumn=function(){Sys.UI.Controls.ButtonColumn.initializeBase(this);}
Sys.UI.Controls.ButtonColumn.prototype={getControlType:function(){return Sys.UI.Controls.ButtonEdit;},add_buttonClick:function(handler,handlerOwner){return this.get_events().addHandler('buttonClick',handler,handlerOwner);},remove_buttonClick:function(handler){this.get_events().removeHandler('buttonClick',handler);},doButtonClick:function(){var handler=this.get_events().getHandler('buttonClick');if(handler){handler(this);}}}
Sys.UI.Controls.ButtonColumn.registerClass('Sys.UI.Controls.ButtonColumn',Sys.UI.Controls.Column);Sys.UI.Controls.HyperLinkColumn=function(){Sys.UI.Controls.HyperLinkColumn.initializeBase(this);this._doClick=Function.createDelegate(this,this._click);}
Sys.UI.Controls.HyperLinkColumn.prototype={initialize:function(){Sys.UI.Controls.HyperLinkColumn.callBaseMethod(this,'initialize');var events=this._allEvents;if(events){var onClick=events.click;if(onClick){this.add_click(onClick);};}},dispose:function(){this._doClick=null;Sys.UI.Controls.HyperLinkColumn.callBaseMethod(this,'dispose');},getIsCommandColumn:function(){return true;},getHTML:function(value,text){return"<div class=\"GridBodyCellText GridBodyCellLinkText\">"+text+"</div>";},initCellEvent:function(rowIndex,cell){var element=cell.firstChild;if(element&&!element._hasEvent){$common.addClickHandler(element,this.doClick,this);element._hasEvent=true;}},add_click:function(handler){this.get_events().addHandler("_click",handler);},remove_click:function(handler){this.get_events().removeHandler("_click",handler);},doClick:function(e){var handler=this.get_events().getHandler("_click");if(handler){handler(this);}}}
Sys.UI.Controls.HyperLinkColumn.registerClass('Sys.UI.Controls.HyperLinkColumn',Sys.UI.Controls.TextColumn);Sys.UI.Controls.MemoColumn=function(){Sys.UI.Controls.MemoColumn.initializeBase(this);this._dropDownWidth=0;this._dropDownHeight=0;}
Sys.UI.Controls.MemoColumn.prototype={getControlType:function(){return Sys.UI.Controls._DropDownMemoEdit;},get_dropDownWidth:function(){return this._dropDownWidth;},set_dropDownWidth:function(value){this._dropDownWidth=value;},get_dropDownHeight:function(){return this._dropDownHeight;},set_dropDownHeight:function(value){this._dropDownHeight=value;},initControlProps:function(controlProps){controlProps.dropDownWidth=this.get_dropDownWidth();controlProps.dropDownHeight=this.get_dropDownHeight();},getHTML:function(value,text){return this._internalGetTextHTML($common.textToHtml(text));}}
Sys.UI.Controls.MemoColumn.registerClass('Sys.UI.Controls.MemoColumn',Sys.UI.Controls.Column);Sys.UI.Controls.ImageColumn=function(){Sys.UI.Controls.ImageColumn.initializeBase(this);this._imageUrl=null;this._hint=null;this._doClick=Function.createDelegate(this,this._click);this._imageWidth=0;this._imageHeight=0;this._useResource=true;}
Sys.UI.Controls.ImageColumn.prototype={initialize:function(){Sys.UI.Controls.ImageColumn.callBaseMethod(this,'initialize');var events=this._allEvents;if(events){var onClick=events.click;if(onClick){this.add_click(onClick);};}},dispose:function(){this._doClick=null;Sys.UI.Controls.ImageColumn.callBaseMethod(this,'dispose');},getIsCommandColumn:function(){return true;},getHTML:function(value,text){var src=this.get_imageUrl();if(value){src=this._useResource?$common.getResourceUrl(value):this.get_form().convertUrl(value);} if(src){var hint=this.get_hint();if(hint){hint=" title=\""+hint+"\"";} var imageWidth=this._imageWidth;var width=imageWidth>0?" width=\""+imageWidth+"\"":null;var imageHeight=this._imageHeight;var height=imageHeight>0?" height=\""+imageHeight+"\"":null;return"<image src=\""+src+"\""+width+height+hint+" />";} return"";},initCellEvent:function(rowIndex,cell){var element=cell.firstChild;if(element&&element.tagName&&!element._hasEvent){$common.addClickHandler(element,this.doClick,this);element._hasEvent=true;}},get_imageUrl:function(){return this._imageUrl;},set_imageUrl:function(value){this._imageUrl=value;},get_hint:function(){return this._hint;},set_hint:function(value){this._hint=value;},get_imageWidth:function(){return this._imageWidth;},set_imageWidth:function(value){this._imageWidth=value;},get_imageHeight:function(){return this._imageHeight;},set_imageHeight:function(value){this._imageHeight=value;},get_useResource:function(){return this._useResource;},set_useResource:function(value){this._useResource=value;},add_click:function(handler){this.get_events().addHandler("_click",handler);},remove_click:function(handler){this.get_events().removeHandler("_click",handler);},doClick:function(e){var handler=this.get_events().getHandler("_click");if(handler){handler(this);}}}
Sys.UI.Controls.ImageColumn.registerClass('Sys.UI.Controls.ImageColumn',Sys.UI.Controls.TextColumn);Sys.UI.Controls.DynamicColumnType=function(){throw Error.notImplemented();}
Sys.UI.Controls.DynamicColumnType.prototype={_float:0,positiveFloat:1,_int:2,positiveInt:3,text:4,date:5,selector:6}
Sys.UI.Controls.DynamicColumnType.registerEnum("Sys.UI.Controls.DynamicColumnType");Sys.UI.Controls.DynamicColumn=function(){Sys.UI.Controls.DynamicColumn.initializeBase(this);this._type=Sys.UI.Controls.DynamicColumnType.text;this._dataValueField=null;this._numberType=Sys.UI.Controls.NumberType._float;this._decimalPrecision=0;this._decimalScale=0;this._decimalDigits=0;this._displayThousandSeperator=false;this._displayEmptyForZero=false;this._selectorPage=null;this._selectorWidth=0;this._selectorHeight=0;this._selectorType=null;this._filterChars=null;this._allowTags=false;this._selectOnly=false;this._allowHandInput=false;this._shortcut=0;this._maxByteLength=0;}
Sys.UI.Controls.DynamicColumn.prototype={getControlType:function(){if(this._isNumberType()){return Sys.UI.Controls.NumberEdit;} else if(this._isDateType()){return Sys.UI.Controls.DateEdit;} else if(this._isSelectorType()){return Sys.UI.Controls.SelectorEdit;} else{return Sys.UI.Controls.TextEdit;}},getIsNumberType:function(){return this._isNumberType();},_isIntType:function(){return this._type==Sys.UI.Controls.DynamicColumnType._int||this._type==Sys.UI.Controls.DynamicColumnType.positiveInt;},_isFloatType:function(){return this._type==Sys.UI.Controls.DynamicColumnType._float||this._type==Sys.UI.Controls.DynamicColumnType.positiveFloat;},_isNumberType:function(){return this._type>=Sys.UI.Controls.DynamicColumnType._float&&this._type<=Sys.UI.Controls.DynamicColumnType.positiveInt;},_isDateType:function(){return this._type==Sys.UI.Controls.DynamicColumnType.date;},_isSelectorType:function(){return this._type==Sys.UI.Controls.DynamicColumnType.selector;},get_type:function(){return this._type;},set_type:function(value){if(this._type!=value){if(this._hasEditor()){this._hideEditor();} this._disposeControl();this._type=value;}},initControlProps:function(controlProps){if(this._isNumberType()){controlProps.numberType=this._type;controlProps.decimalPrecision=this.get_decimalPrecision();controlProps.decimalScale=this.get_decimalScale();} else if(this._isSelectorType()){Sys.UI.Controls.SelectorColumn.copyProps(this,controlProps);}},_checkNumber:function(value){return isNaN(value)?null:value;},formatNumber:function(value){return $common.formatNumber(value,this.get_decimalDigits(),this.get_decimalScale(),this.get_displayThousandSeperator(),this.get_displayEmptyForZero());},getDisplayText:function(value,text){if(this._isFloatType()){return this.formatNumber(value);} if(value&&typeof(value)=="string"){var values=this._parseSelectorValue(value);return values[1];} else{return text;}},_parseSelectorValue:function(text){var values=["",""];if(text){var a=text.split('|');if(a.length==2){values[0]=a[0];values[1]=a[1];} else{values[1]=a[0];}} return values;},loadEditValue:function(text){var value;if(this._isFloatType()){value=this._checkNumber(parseFloat(text));} else if(this._isIntType()){value=this._checkNumber(parseInt(text));} else if(this._isDateType()){value=text?Date.strToDate(text):null;value=value?value:new Date();} else if(this._isSelectorType()){var values=this._parseSelectorValue(text);value=new Object();value[this.get_dataValueField()]=values[0];value[this.get_dataTextField()]=values[1];} else{value=text;} return value;},saveEditValue:function(value){var text;if(this._isDateType()){text=Date.dateToStr(value);} else if(this._isSelectorType()){text=value[this.get_dataValueField()]+"|"+value[this.get_dataTextField()];} else{text=value!=null?value.toString():"";} return text;},convertValue:function(text){var value=this.loadEditValue(text);return this.saveEditValue(value);},get_numberType:function(value){return this._numberType;},set_numberType:function(value){this._numberType=value;},get_decimalPrecision:function(){return this._decimalPrecision;},set_decimalPrecision:function(value){this._decimalPrecision=value;},get_decimalDigits:function(){return this._decimalDigits;},set_decimalDigits:function(value){this._decimalDigits=value;},get_decimalScale:function(){return this._decimalScale;},set_decimalScale:function(value){this._decimalScale=value;},get_displayThousandSeperator:function(){return this._displayThousandSeperator;},set_displayThousandSeperator:function(value){this._displayThousandSeperator=value;},get_displayEmptyForZero:function(){return this._displayEmptyForZero;},set_displayEmptyForZero:function(value){this._displayEmptyForZero=value;},get_dataValueField:function(value){return this._dataValueField;},set_dataValueField:function(value){this._dataValueField=value;},get_dataTextField:function(value){return this.get_displayField();},set_dataTextField:function(value){this.set_displayField(value);},get_selectorPage:function(){return this._selectorPage;},set_selectorPage:function(value){this._selectorPage=value;},get_selectorWidth:function(){return this._selectorWidth;},set_selectorWidth:function(value){this._selectorWidth=value;},get_selectorHeight:function(){return this._selectorHeight;},set_selectorHeight:function(value){this._selectorHeight=value;},get_selectorType:function(){return this._selectorType;},set_selectorType:function(value){if(!value)throw Error.argumentNull("selectorType");this._selectorType=value;},get_selectOnly:function(){return this._selectOnly;},set_selectOnly:function(value){this._selectOnly=value;},get_allowHandInput:function(){return this._allowHandInput;},set_allowHandInput:function(value){this._allowHandInput=value;},get_shortcut:function(){return this._shortcut;},set_shortcut:function(value){this._shortcut=value;},get_maxByteLength:function(){return this._maxByteLength;},set_maxByteLength:function(value){this._maxByteLength=value;},get_filterChars:function(){return this._filterChars;},set_filterChars:function(value){this._filterChars=value;},get_allowTags:function(){return this._allowTags;},set_allowTags:function(value){this._allowTags=value;}}
Sys.UI.Controls.DynamicColumn.registerClass('Sys.UI.Controls.DynamicColumn',Sys.UI.Controls.Column);Sys.UI.Controls.RowDeleteColumn=function(){Sys.UI.Controls.RowDeleteColumn.initializeBase(this);}
Sys.UI.Controls.RowDeleteColumn.prototype={initialize:function(){Sys.UI.Controls.RowDeleteColumn.callBaseMethod(this,'initialize');$skin.cacheImage("grid","rowDelete");var skinImage=this._skinImage=$skin.getImage("grid","rowDelete");this._normalHtml=$common.getGlyphDivHTML(skinImage,0);this._clickHandler=Function.createDelegate(this,this._click);},dispose:function(){this._skinImage=null;this._clickHandler=null;Sys.UI.Controls.RowDeleteColumn.callBaseMethod(this,'dispose');},getIsCommandColumn:function(){return true;},get_allowSort:function(){return false;},get_allowResize:function(){return false;},getHTML:function(value,text){return!this._grid.get_readOnly()?this._normalHtml:"";},initCellEvent:function(rowIndex,cell){if(!this._grid.get_readOnly()){var element=cell.firstChild;if(element&&!element._hasEvent){element.title="删除本行";$common.addClickHandler(element,this._clickHandler);element._hasEvent=true;}}},doInit:function(row,rowIndex){var grid=this._grid;var cell=grid._getRowCell(row,this.get_index());if(cell){Sys.UI.Controls.RowDeleteColumn.callBaseMethod(this,'initCellHTML',[rowIndex,cell]);}},doHover:function(row,active){var grid=this._grid;if(!grid.get_readOnly()){var cell=grid._getRowCell(row,this.get_index());if(cell&&cell.firstChild){$common.setBackgroundImage(cell.firstChild,this._skinImage,active?1:0);}}},_click:function(e){var div=e.target;var row=div.parentNode.parentNode;if(row){var grid=this._grid;var rowIndex=grid._getRowIndex(row);if(rowIndex>=0){var eventArgs=new Sys.CancelEventArgs();var events=this._allEvents;if(events){var onClick=events.click;onClick(this,eventArgs);} if(!eventArgs.get_cancel()){grid._internalCheckDeleteRow(rowIndex);}}}}}
Sys.UI.Controls.RowDeleteColumn.registerClass('Sys.UI.Controls.RowDeleteColumn',Sys.UI.Controls.Column);Type.registerNamespace('Carpa.Web.Script');Carpa.Web.Script.DataService=function(){Carpa.Web.Script.DataService.initializeBase(this);}
Carpa.Web.Script.DataService.prototype={get_path:function(){return $getRootURI()+"Carpa.Web/Carpa.Web.Script.DataService.ajax";},GetPagerData:function(pagerId,queryParams,orders,filter,first,count,succeededCallback,failedCallback,userContext){return this._invoke('GetPagerData',{pagerId:pagerId,queryParams:queryParams,orders:orders,filter:filter,first:first,count:count},succeededCallback,failedCallback,userContext);},SetQueryState:function(pagerId,state,first,count,succeededCallback,failedCallback,userContext){return this._invoke('SetQueryState',{pagerId:pagerId,state:state,first:first,count:count},succeededCallback,failedCallback,userContext);},GetPagerSummary:function(pagerId,succeededCallback,failedCallback,userContext){return this._invoke('GetPagerSummary',{pagerId:pagerId},succeededCallback,failedCallback,userContext);},GetPagerPreloadItems:function(pagerId,fields,succeededCallback,failedCallback,userContext){return this._invoke('GetPagerPreloadItems',{pagerId:pagerId,fields:fields},succeededCallback,failedCallback,userContext);},SaveGridConfig:function(gridId,data,succeededCallback,failedCallback,userContext){return this._invoke('SaveGridConfig',{gridId:gridId,data:data},succeededCallback,failedCallback,userContext);}}
Carpa.Web.Script.DataService.registerClass('Carpa.Web.Script.DataService',Sys.Net.WebServiceProxy);Carpa.Web.Script.DataService.create=function(){var service=new Carpa.Web.Script.DataService();service.set_enableShowWaiting(false);return service;}
Sys.UI.Controls.Pager=function(element){Sys.UI.Controls.Pager.initializeBase(this,[element]);this._target=null;this._numericButtonCount=10;this._itemCount=0;this._pageSize=10;this._itemList=null;this._pageIndex=0;this._summary=null;this._prevPageButton=null;this._nextPageButton=null;this._refreshButton=null;this._pagesCell=null;this._showItemCount=true;this._showRefreshButton=$settings.gridPagerDefaultShowRefreshButton;this._showAll=false;this._hasSummary=false;this._savedQueryParams=null;this._autoFocus=true;this._summaryLabel=null;this._follow=null;this._service=null;this._hasSummaryLoaded=false;this._dataSource=null;this._preloadItemFields=null;}
Sys.UI.Controls.Pager.prototype={initialize:function(){Sys.UI.Controls.Pager.callBaseMethod(this,'initialize');this._service=Carpa.Web.Script.DataService.create();var div=$common.createDiv();div.className="PagerContent";var table=$common.createTable();var body=$common.createTBody();var row=$common.createTr();var cell=$common.createTd();var summary=this._summary=$common.createDiv();summary.className="PagerSummaryText";this._initSummary();cell.appendChild(summary);row.appendChild(cell);this._prevPageButton=this._createPageButton(row,"prevPage",this._prevPage);var cell=this._pagesCell=$common.createTd();this._createNumericButtons(cell);row.appendChild(cell);this._nextPageButton=this._createPageButton(row,"nextPage",this._nextPage);this._initNavButtons();if(this.get_showRefreshButton()&&this.get_target()){this._createTd(row,"6px");this._refreshButton=this._createPageButton(row,"refresh",this._refreshPage,"刷新");} this._createGotoEditButton(row);body.appendChild(row);table.appendChild(body);div.appendChild(table);this.get_element().appendChild(div);var followId=this.get_follow();var followControl=followId?this.get_form()[followId]:null;if(followControl){followControl.set_followPager(this);} this._dataChanged();$common.addClickHandler(cell,this._pagesClick,this);},dispose:function(){this._service=null;this._clearLastNumericButtonsRow();if(this._prevPageButton){this._prevPageButton.dispose();this._prevPageButton=null;} if(this._nextPageButton){this._nextPageButton.dispose();this._nextPageButton=null;} if(this._refreshButton){this._refreshButton.dispose();this._refreshButton=null;} if(this._pagesCell){$clearHandlers(this._pagesCell);this._pagesCell=null;} this._summary=null;this._target=null;if(this._gotoNumberEdit){this._gotoNumberEdit.dispose();this._gotoNumberEdit=null;} if(this._gotoButton){this._gotoButton.dispose();this._gotoButton=null;} this._dataSource=null;Sys.UI.Controls.Pager.callBaseMethod(this,'dispose');},get_follow:function(){return this._follow;},set_follow:function(value){this._follow=value;},get_service:function(){return this._service;},_getTargetControl:function(){var targetId=this.get_target();return targetId?this.get_form()[targetId]:null;},_dataChanged:function(){var itemList=this.get_itemList();if(itemList){var target=this._getTargetControl();if(target){target._dataRowFirst=this.get_pageIndex()*this.get_pageSize();target.refresh(itemList);}}},_createTd:function(tr,width){td=$common.createTd();tr.appendChild(td);if(width){td.style.width=width;} return td;},_doGotoPageButonClick:function(sender){if(this._gotoNumberEdit){var gotoIndex=this._gotoNumberEdit.get_value();if(gotoIndex<1||gotoIndex>this.get_pageCount()){alert("输入的页数超出了范围！");} else{this._gotoPageOnClick(gotoIndex-1);} this._gotoNumberEdit.focus();}},_doGotoEditEnterPress:function(sender){this._doGotoPageButonClick(sender);},_checkSetGotoEditButtonVisible:function(){var visible=this.get_pageCount()>this.get_numericButtonCount();this._gotoNumberEdit.set_visible(visible);this._gotoButton.set_visible(visible);},_createGotoEditButton:function(parentRow){this._createTd(parentRow,"8px");var input=$common.createInput();input.className="Edit";input.style.width="30px";this._createTd(parentRow).appendChild(input);var gotoNumberEdit=$create(Sys.UI.Controls.NumberEdit,{},input);gotoNumberEdit.set_tabOnEnter(false);gotoNumberEdit.set_numberType(Sys.UI.Controls.NumberType.positiveInt);gotoNumberEdit.add_enterPress(Function.createDelegate(this,this._doGotoEditEnterPress));this._gotoNumberEdit=gotoNumberEdit;this._createTd(parentRow,"4px");var buttonElement=document.createElement("button");buttonElement.className="Button";var buttonText=$settings.gotoPageButtonText||"转到";var buttonWidth=36;if(buttonText.length>2){buttonWidth+=(buttonText.length-2)*5;} buttonElement.style.width=buttonWidth+"px";this._createTd(parentRow).appendChild(buttonElement);var button=$create(Sys.UI.Controls.Button,{},buttonElement);button.set_text(buttonText);button.add_click(Function.createDelegate(this,this._doGotoPageButonClick));this._gotoButton=button;this._checkSetGotoEditButtonVisible();},_createPageButton:function(parentRow,elementName,onClick,hint){var skinImage=$skin.getImage("pager",elementName);var bounds=new Sys.UI.Bounds(null,null,skinImage.imageWidth,skinImage.imageHeight);var cell=$common.createTd();cell.id=this.get_id()+"_"+elementName;if(hint){cell.title=hint;} var button=new Sys.UI.Controls.CustomSkinButton(cell,skinImage,bounds);button.initialize();button.add_click(onClick,this);parentRow.appendChild(cell);return button;},get_showItemCount:function(value){return this._showItemCount;},set_showItemCount:function(value){return this._showItemCount=value;},get_showRefreshButton:function(){return this._showRefreshButton;},set_showRefreshButton:function(value){this._showRefreshButton=value;},get_showAll:function(){return this._showAll;},set_showAll:function(value,disableRefresh){this._showAll=value;if(this.get_isInitialized()&&!disableRefresh){this.refresh();}},get_summaryLabel:function(){return this._summaryLabel;},set_summaryLabel:function(value){this._summaryLabel=value;},_initSummary:function(){var pageCount=this.get_pageCount();var itemCount=this.get_showItemCount()?String.format("({0} 条记录)",this.get_itemCount()):"";var summaryLabel=this.get_summaryLabel();summaryLabel=summaryLabel?summaryLabel+" ":"";var pageLabel=this.get_showAll()?"":String.format("第 {0}/{1} 页",Math.min(this.get_pageIndex()+1,pageCount),pageCount);if(pageLabel&&itemCount){itemCount=" "+itemCount;} this._summary.innerHTML=summaryLabel+pageLabel+itemCount;},_initNavButtons:function(){var pageIndex=this.get_pageIndex();var pageCount=this.get_pageCount();this._prevPageButton.set_enabled(pageIndex>0);this._nextPageButton.set_enabled(pageIndex<pageCount-1);},_clearLastNumericButtonsRow:function(){if(this._lastNumericButtonsRow){$clearHandlers(this._lastNumericButtonsRow);this._lastNumericButtonsRow=null;}},_createNumericButtons:function(parentCell){this._clearLastNumericButtonsRow();if(this.get_numericButtonCount()<=0){return;} var table=$common.createTable(2);var body=$common.createTBody();var row=$common.createTr();if(this.get_pageCount()<=this.get_numericButtonCount()){this._createAllNumericButtonsWithOutsideEllipsis(row);} else{this._createNumericButtonsWithInsideEllipsis(row);} body.appendChild(row);table.appendChild(body);parentCell.appendChild(table);$common.addMouseOverHandler(row,this._buttonsMouseOver,this);$common.addMouseOutHandler(row,this._buttonsMouseOut,this);this._lastNumericButtonsRow=row;},_setEventTargetCellBg:function(e,backgroundColor){var cell=e.target;if(cell.tagName!="TD"){cell=cell.parentNode;} if(cell.tagName=="TD"&&!Object.isUndefined(cell._pageIndex)){cell.style.backgroundColor=backgroundColor;}},_buttonsMouseOver:function(e){this._setEventTargetCellBg(e,$skin.getActiveBackgroundColor());},_buttonsMouseOut:function(e){this._setEventTargetCellBg(e,$skin.getControlBackgroundColor());},_createAllNumericButtonsWithOutsideEllipsis:function(row){var indexes=[];var pageCount=this.get_pageCount();for(var i=0;i<pageCount;i++){Array.add(indexes,i);} this._createNumericButtonsSection(row,indexes);},_createNumericButtonsWithOutsideEllipsis:function(row,hasEllipsis){var pageIndex=this.get_pageIndex();var buttonCount=this.get_numericButtonCount();var pageCount=this.get_pageCount();var indexes=[];var num2=(pageIndex-(buttonCount/2))+(1-(buttonCount%2));var buttonPageCount=num2+buttonCount;if(num2<0){num2=0;buttonPageCount=num2+buttonCount;} if(buttonPageCount>pageCount){buttonPageCount=pageCount;num2=buttonPageCount-buttonCount;} if(hasEllipsis&&(num2>0)){Array.add(indexes,-1);} for(var i=num2;i<buttonPageCount;i++){Array.add(indexes,i);} if(hasEllipsis&&(buttonPageCount<pageCount)){Array.add(indexes,-1);} this._createNumericButtonsSection(row,indexes);},_createNumericButtonsWithInsideEllipsis:function(row){var buttonCount=this.get_numericButtonCount();if(buttonCount<3){this._createNumericButtonsWithOutsideEllipsis(row,true);} else{var pageCount=this.get_pageCount();var pageIndex=this.get_pageIndex();var indexes=[];var num2=Math.floor(buttonCount/3);var num3=(buttonCount-num2)-num2;var num4=0;var num5=num4+num2;var num6=Math.floor((pageIndex-(num3/2))+(1-(num3%2)));var num7=num6+num3;var num8=pageCount-num2;var num9=num8+num2;var flag=true;var flag2=true;if((num5+1)>num6){flag=false;num6=num4;num7=(num6+num2)+num3;} if((num8-1)<num7){flag2=false;num7=num9;num6=(num7-num2)-num3;} if(flag){for(var j=num4;j<num5;j++){Array.add(indexes,j);} Array.add(indexes,-1);} for(var i=num6;i<num7;i++){Array.add(indexes,i);} if(flag2){Array.add(indexes,-1);for(var k=num8;k<num9;k++){Array.add(indexes,k);}} this._createNumericButtonsSection(row,indexes);}},_createNumericButtonsSection:function(row,indexes){var pageIndex=this.get_pageIndex();for(var i=0;i<indexes.length;i++){var cell=$common.createTd();cell.className="PagerPageNumber";var index=indexes[i];var elt=$common.createDiv();if(index>-1){var className;var num=index+1;if(index==pageIndex){num='&nbsp;<b>'+num+'</b>&nbsp;';className="PagerPageNumberSelected";} else{cell._pageIndex=index;className="PagerPageNumberButton";} elt.className=className;elt.innerHTML=num;} else{elt.innerHTML="...";} cell.appendChild(elt);row.appendChild(cell);}},_prevPage:function(e){var pageIndex=this.get_pageIndex();if(pageIndex>0){this._gotoPageOnClick(pageIndex-1);}},_nextPage:function(e){var pageIndex=this.get_pageIndex();var pageCount=this.get_pageCount();if(pageIndex<pageCount-1){this._gotoPageOnClick(pageIndex+1);}},_refreshPage:function(e){this.refreshPage();},_pagesClick:function(e){var td=e.target;if(td.tagName=="DIV"){td=td.parentNode;} var pageIndex=td._pageIndex;if(!Object.isUndefined(pageIndex)){this._gotoPageOnClick(pageIndex);}},_gotoPageOnClick:function(pageIndex){this.gotoPage(pageIndex);},get_target:function(){return this._target;},set_target:function(value){this._target=value;},get_hasSummary:function(){return this._hasSummary;},set_hasSummary:function(value){this._hasSummary=value;},set_width:function(value){$common.setWidth(this.get_element(),value-2);},get_numericButtonCount:function(){return this._numericButtonCount;},set_numericButtonCount:function(value){this._numericButtonCount=value;},get_autoFocus:function(){return this._autoFocus;},set_autoFocus:function(value){this._autoFocus=value;},get_itemList:function(){return this._itemList;},set_itemList:function(value){this._itemList=value;},get_itemCount:function(){return this._itemCount;},set_itemCount:function(value){this._itemCount=value;if(this._pageIndex<0&&value>0){this._pageIndex=0;}},incItemCount:function(){this.set_itemCount(this._itemCount+1);this._initSummary();return this._itemCount;},decItemCount:function(){if(this._itemCount==0)return;this._itemCount--;this._initSummary();if(this._itemCount==0){this._clearNumericButtons();} return this._itemCount;},get_pageSize:function(){return this._pageSize;},set_pageSize:function(value){this._pageSize=value;},get_pageCount:function(){if(!this.get_showAll()){return Math.ceil(this._itemCount/this._pageSize);} else{return this._itemCount>0?1:0;}},get_pageIndex:function(){return this._pageIndex;},set_pageIndex:function(value){this._loadPage(value);},resetPageIndex:function(){this._pageIndex=0;},get_pageItemIndex:function(){return this.get_pageIndex()*this.get_pageSize();},get_isFirstPage:function(){return this.get_pageIndex()==0;},get_isLastPage:function(){var pageCount=this.get_pageCount();return pageCount==0||this.get_pageIndex()==pageCount-1;},firstPage:function(onSuccess){if(!this.get_isFirstPage()){this.gotoPage(0,onSuccess);}},lastPage:function(onSuccess){if(!this.get_isLastPage()){var pageCount=this.get_pageCount();this.gotoPage(pageCount>0?pageCount-1:0,onSuccess);}},prevPage:function(onSuccess){if(!this.get_isFirstPage()){this.gotoPage(this.get_pageIndex()-1,onSuccess);}},nextPage:function(onSuccess){if(!this.get_isLastPage()){this.gotoPage(this.get_pageIndex()+1,onSuccess);}},gotoPage:function(pageIndex,onSuccess){this._loadPage(pageIndex,null,null,null,null,onSuccess);},get_queryParams:function(){return this._savedQueryParams;},set_queryParams:function(value){this._savedQueryParams=value;},refresh:function(params,onSuccess){params=this._beforeRefresh(params);this._doRefresh(params,null,null,null,onSuccess);},_beforeRefresh:function(params){var savedQueryParams=this._savedQueryParams;if(savedQueryParams){if(params){Object.copyTo(params,savedQueryParams);} params=savedQueryParams;} this._hasSummaryLoaded=false;this._doPagerBeforeRefresh();return params;},_doPagerBeforeRefresh:function(){var target=this._getTargetControl();if(target){target._internalDoPagerBeforeRefresh();}},refreshPage:function(params,pageIndex,onSuccess){if(Object.isUndefinedOrNull(pageIndex)){pageIndex=this.get_pageIndex();} params=this._beforeRefresh(params);this._loadPage(pageIndex,params,null,null,null,onSuccess);},reloadPage:function(pageIndex,onSuccess){if(Object.isUndefinedOrNull(pageIndex)){pageIndex=this.get_pageIndex();} this._doPagerBeforeRefresh();this.gotoPage(pageIndex,onSuccess);},_doRefresh:function(params,orders,filter,state,onSuccess){this._loadPage(0,params,orders,filter,state,onSuccess);},_internalRefreshSort:function(orders){this._doPagerBeforeRefresh();this._doRefresh(null,orders,null,null,null);},_internalRefreshFilter:function(filter){this._hasSummaryLoaded=false;this._doRefresh(null,null,filter,null,null);},_internalRefreshState:function(state){this._hasSummaryLoaded=false;this._doRefresh(null,null,null,state,null);},add_pageIndexChanged:function(handler){this.get_events().addHandler("pageIndexChanged",handler);},remove_pageIndexChanged:function(handler){this.get_events().removeHandler("pageIndexChanged",handler);},_doPageIndexChanged:function(pageIndex){this._pageIndex=pageIndex;this._initNavButtons();this._initNumericButtons();var handler=this.get_events().getHandler("pageIndexChanged");if(handler){handler(this);}},_getDataItemCount:function(value){if(value&&value.dataType&&value.dataType==1){return value.rows.length;} else{return value.length;}},get_isLoading:function(){return this._loading;},_loadPage:function(pageIndex,params,orders,filter,state,onSuccess){if(this._loading)return;var target=this._getTargetControl();if(target){if(!target._internalDoPagerPageBeforeChanged()){return;} this._beginLoading(target);} else{this._doPageIndexChanged(pageIndex);return;} this._pageIndex=pageIndex;var pagerId=this.get_id();var count=!this.get_showAll()?this.get_pageSize():-1;var first=pageIndex*count;this._loading=true;var successHandler=Function.createDelegate(this,function(result){var dataLoaded=!onSuccess?this._dataLoaded:function Sys$UI$Controls$Pager$_loadPage$success(result){this._dataLoaded(result);onSuccess();};if(this._getDataItemCount(result.itemList)==0&&pageIndex>0){for(;pageIndex*count>=result.itemCount&&pageIndex>0;pageIndex--);this._endLoading();window.asyncCall(Function.createDelegate(this,function(){this._loadPage(pageIndex,params,orders,filter,state,onSuccess)}));} else{Function.createDelegate(this,dataLoaded)(result);}});var faildHandler=Function.createDelegate(this,this._dataFailed);if(typeof(params)==="undefined"){params=null;} if(typeof(orders)==="undefined"){orders=null;} if(typeof(filter)==="undefined"){filter=null;} var dataSource=this._dataSource;if(!dataSource){var service=this._service;var form=this.get_form();var pageTimeout=form.get_pageTimeout();if(pageTimeout>0){service.set_timeout(pageTimeout);} if(!state){service.GetPagerData(pagerId,params,orders,filter,first,count,successHandler,faildHandler);} else{service.SetQueryState(pagerId,state,first,count,successHandler,faildHandler);}} else{var itemCount=dataSource.length;var minCount=Math.min(count,itemCount-first);var itemList=new Array(minCount);for(var i=0,j=first;i<minCount;i++,j++){itemList[i]=dataSource[j];} var dataPackage={};dataPackage.itemCount=itemCount;dataPackage.itemList=itemList;successHandler(dataPackage);}},get_preloadItemFields:function(){return this._preloadItemFields;},set_preloadItemFields:function(value){this._preloadItemFields=value;},_internalGetPreloadItems:function(){var fields=this.get_preloadItemFields();if(!fields){throw Error.invalidOperation("没有调用 set_preloadItemFields 指定预加载字段表");} var pagerId=this.get_id();window.status="正在加载数据 ...";var answer=this._service.GetPagerPreloadItems(pagerId,fields,false);window.status="";return answer;},get_dataSource:function(){return this._dataSource;},dataBind:function(dataSource){if(typeof(dataSource)=="undefined")return;this._dataSource=dataSource;if(!dataSource){this.init(0);} else{this.refresh();}},deleteRecord:function(rowIndex){var dataSource=this._dataSource;if(dataSource){Array.removeAt(dataSource,rowIndex);}},_beginLoading:function(target){this._waitTimer=window.setTimeout(function(){$common.showLoading(target.get_element());},600);},_endLoading:function(){if(this._waitTimer){window.clearTimeout(this._waitTimer);delete this._waitTimer;} if($common.isWaiting()){$common.hideLoading();} this._loading=false;},_dataLoaded:function Sys$UI$Controls$Pager$_dataLoaded(result){if(this.get_isDisposed()){this._endLoading();return;} var ex=null;try{this.set_itemCount(result.itemCount);this.set_itemList(result.itemList);delete result.itemList;var target=this._getTargetControl();if(target){var columnExpands=result.columnExpands;if(columnExpands){target.set_columnExpands(columnExpands);delete result.columnExpands;} var cellMergeItems=result.cellMergeItems;if(cellMergeItems){target.set_cellMergeItems(cellMergeItems);delete result.cellMergeItems;}} this._initSummary();this._initNavButtons();this._dataChanged();this._initNumericButtons();this._checkSetGotoEditButtonVisible();if(this._hasSummary&&!this._hasSummaryLoaded){this.refreshSummary();} if(this.get_autoFocus()&&target&&target.focus){if(!target.canFocus||target.canFocus()){target.focus();}}} catch(e){ex=e;} this._endLoading();$common.setTestState("pagerDataLoaded");if(ex)throw ex;},_clearNumericButtons:function(){this._pagesCell.innerHTML="";},_initNumericButtons:function(){this._clearNumericButtons();this._createNumericButtons(this._pagesCell);},init:function(itemCount){if(!(itemCount>=0)){throw Error.argumentOutOfRange('itemCount',itemCount);} this.set_itemCount(itemCount);this._initSummary();this._initNavButtons();this._initNumericButtons();this._checkSetGotoEditButtonVisible();},_dataFailed:function(error){this._endLoading();alert(Sys.Net.WebServiceProxy.formatWebServiceFailedServerError(error.get_message()));},refreshSummary:function(){var target=this._getTargetControl();var pagerId=this.get_id();this._service.GetPagerSummary(pagerId,Function.createDelegate(this,this._summaryLoaded),Function.createDelegate(this,this._summaryFailed));},_summaryLoaded:function(result){var grid=this._getTargetControl();if(grid){grid.set_summaryItems(result);this._hasSummaryLoaded=true;}},_summaryFailed:function(error){alert("取合计失败："+error.get_message());}}
Sys.UI.Controls.Pager.registerClass('Sys.UI.Controls.Pager',Sys.UI.Control);Sys.UI.Controls._ColumnResizer=function(column){Sys.UI.Controls._ColumnResizer.initializeBase(this);this._column=column;this._mouseDownHandler=Function.createDelegate(this,this._doMouseDown);this._mouseMoveHandler=Function.createDelegate(this,this._drag);this._mouseUpHandler=Function.createDelegate(this,this._doMouseUp);this._keyPressHandler=Function.createDelegate(this,this._doKeyPress);this._mouseDblClickHandler=Function.createDelegate(this,this._doDblClick);this._draging=false;}
Sys.UI.Controls._ColumnResizer.prototype={initialize:function(){Sys.UI.Controls._ColumnResizer.callBaseMethod(this,'initialize');var sizeGripper=this._sizeGripper=this._createDiv("",1);this._initSizeGripperPosition(sizeGripper);document.body.appendChild(sizeGripper);$common.addMouseDownHandler(sizeGripper,this._mouseDownHandler);$common.addDblClickHandler(sizeGripper,this._mouseDblClickHandler);},_createDiv:function(backgroundColor,zIndexOffset){var div=$common.createDiv();div.style.cursor="col-resize";if(Sys.Browser.isIE){div.unselectable="on";} div.style.backgroundColor=backgroundColor;var zIndex=Sys.Application.getPopupElementZIndex();div.style.zIndex=zIndex+zIndexOffset;return div;},dispose:function(){var sizeGripper=this._sizeGripper;if(sizeGripper){$clearHandlers(sizeGripper);document.body.removeChild(sizeGripper);this._sizeGripper=null;} if(this._sizeSplitter){document.body.removeChild(this._sizeSplitter);this._sizeSplitter=null;} this._mouseDownHandler=null;this._column=null;Sys.UI.Controls._ColumnResizer.callBaseMethod(this,'dispose');},initSizeGripper:function(){var sizeGripper=this._sizeGripper;if(sizeGripper){this._initSizeGripperPosition(sizeGripper);}},_initSizeGripperPosition:function(sizeGripper){var headerElement=this._column.get_headerElement();var r=Sys.UI.DomElement.getBounds(headerElement);var width=10;var left=r.x+r.width-width/2;var top=r.y-1;var height=r.height+2;var grid=this._column.get_grid();var rGrid=grid.get_bounds();if(left+width<rGrid.x+rGrid.width){$common.setPosition(sizeGripper,left,top,width,height);$common.setDisplay(sizeGripper,true);} else{$common.setDisplay(sizeGripper,false);}},_doDblClick:function(e){this._columnAutoWidth();e.cancel();},_doMouseDown:function(e){this._gripperStartLocation=$common.getLocation(this._sizeGripper);this._mouseStartLocation={x:e.clientX,y:e.clientY};e.preventDefault();this._startDrag();},_startDrag:function(){this._draging=true;var sizeSplitter=this._sizeSplitter;if(!sizeSplitter){var sizeSplitter=this._sizeSplitter=this._createDiv("#777777",0);this._initSizeSplitterPosition(sizeSplitter);document.body.appendChild(sizeSplitter);} else{this._initSizeSplitterPosition(sizeSplitter);this._setSizeSplitterVisible(true);} this._splitterStartLocation=$common.getLocation(this._sizeSplitter);$common.addMouseMoveHandler(document,this._mouseMoveHandler);$common.addMouseUpHandler(document,this._mouseUpHandler);$common.addKeyPressHandler(document,this._keyPressHandler);this._notifyGridResizing(true);},_notifyGridResizing:function(isResizing){var grid=this._column.get_grid();grid._internalSetIsResizing(isResizing);},_initSizeSplitterPosition:function(sizeSplitter){var column=this._column;var headerElement=column.get_headerElement();var r=Sys.UI.DomElement.getBounds(headerElement);var width=1;var left=r.x+r.width;var grid=column.get_grid();var rGrid=grid.get_bounds();var top=rGrid.y+4;var height=rGrid.height-8;$common.setPosition(sizeSplitter,left,top,width,height);this._columnLeft=r.x;this._columnNewWidth=0;},_setSizeSplitterVisible:function(visible){var sizeSplitter=this._sizeSplitter;if(sizeSplitter){$common.setDisplay(sizeSplitter,visible);}},_drag:function Sys$UI$Controls$_ColumnResizer$_drag(e){if(!this._draging||this.get_isDisposed())return;var offsetX=e.clientX-this._mouseStartLocation.x;var x=this._gripperStartLocation.x+offsetX;var y=this._gripperStartLocation.y+e.clientY-this._mouseStartLocation.y;Sys.UI.DomElement.setLocation(this._sizeGripper,x,y);var x=this._splitterStartLocation.x+offsetX;var y=this._splitterStartLocation.y;var newWidth=x-this._columnLeft;var minWidth=23;var r=window.getClientBounds();if(newWidth>minWidth&&x<r.width){this._columnNewWidth=newWidth;Sys.UI.DomElement.setLocation(this._sizeSplitter,x,y);} e.preventDefault();},_doMouseUp:function(e){this._endDrag(false);},_doKeyPress:function(e){var k=e.keyCode?e.keyCode:e.rawEvent.keyCode;if(k==27){this._endDrag(true);}},_columnAutoWidth:function(){var column=this._column;var grid=column.get_grid();var count=grid.get_recordCount();if(count>1000){Sys.UI.MessageBox.alert("记录数大于 1000 后不能自动调整列宽");return;} window.status="正在计算列宽 ...";var maxLen=0;for(var i=0;i<count;i++){var text=column.getCellText(i);var len=String.getByteLength(text);maxLen=Math.max(len,maxLen);} var newWidth=maxLen*6+8;var widthForCaption=String.getByteLength(column.get_caption())*6+10;var widthForFooter=String.getByteLength(column.get_footer())*6+10;var minWidth=Math.max(widthForCaption,widthForFooter,23);newWidth=Math.max(newWidth,minWidth);newWidth=Math.min(newWidth,512);this._setColumnWidth(newWidth);window.status="";},_setColumnWidth:function(newWidth){this._column.set_width(newWidth,true);this.initSizeGripper();},_endDrag:function(canceled){if(this.get_isDisposed())return;this._notifyGridResizing(false);var sizeGripper=this._sizeGripper;if(canceled){$common.setLocation(sizeGripper,this._gripperStartLocation);} else{var newWidth=this._columnNewWidth;if(newWidth>0){this._setColumnWidth(newWidth);}} this._setSizeSplitterVisible(false);$common.removeMouseMoveHandler(document,this._mouseMoveHandler);$common.removeMouseUpHandler(document,this._mouseUpHandler);$common.removeKeyPressHandler(document,this._keyPressHandler);this._draging=false;}}
Sys.UI.Controls._ColumnResizer.registerClass('Sys.UI.Controls._ColumnResizer',Sys.Component);window.asGrid=function(obj){return obj;}
window.asGridCellBeginEditEventArgs=function(obj){return obj;}
window.asGridCellRenderingEventArgs=function(obj){return obj;}
window.asGridColumnChangeEventArgs=function(obj){return obj;}
window.asGridGetDisplayTextEventArgs=function(obj){return obj;}
window.asGridRowClickEventArgs=function(obj){return obj;}
window.asGridGetRowNoEventArgs=function(obj){return obj;}
window.asGridNewRecordEventArgs=function(obj){return obj;};Sys.UI.Controls._TabButton=function(tabPage,element){Sys.UI.Controls._TabButton.initializeBase(this,[element]);this._requireMouseOver=true;this._requireMouseOut=true;this._requireMouseDown=true;this._requireDblClick=true;this._requireKeyDown=true;this._tabPage=tabPage;this._tdLeft=null;this._tdMiddle=null;this._tdRight=null;this._captionElement=null;}
Sys.UI.Controls._TabButton.prototype={initialize:function(){Sys.UI.Controls._TabButton.callBaseMethod(this,'initialize');var element=this.get_element();var width=element.offsetWidth;var height=element.offsetHeight;var caption=element.innerHTML;element.className="";element.innerHTML="";var table=$common.createTable();$common.setProperties(table,{width:width,height:"100%"});var body=$common.createTBody();var tr=$common.createTr();var tabPage=this.get_tabPage();var isTop=tabPage.get_tabPosition()!=Sys.UI.Controls.TabPosition.bottom;this._skinImage=$skin.getImage("tab",isTop?"topTab":"bottomTab");var imageWidth=this._skinImage.imageWidth;var td=this._tdLeft=$common.createTd();$common.setProperties(td,{width:imageWidth});this._addFillDiv(td,imageWidth,height);tr.appendChild(td);td=this._tdMiddle=$common.createTd();var captionWidth=width-2*imageWidth;var captionClassName=isTop?"TabTopCaptionInitialize":"TabBottomCaptionInitialize";$common.setProperties(td,{width:captionWidth,height:"100%"});td.className=captionClassName;if(tabPage.get_showTabCloseButton()){this._initCloseButton(td,caption,captionWidth);} else{this._addCaptionElement(td,caption);} tr.appendChild(td);td=this._tdRight=$common.createTd();$common.setProperties(td,{width:imageWidth});this._addFillDiv(td,imageWidth,height);tr.appendChild(td);body.appendChild(tr);table.appendChild(body);this._initNormal();element.appendChild(table);},dispose:function(){if(this._closeButton){this._closeButton.dispose();this._closeButton=null;} this._tdLeft=null;this._tdMiddle=null;this._tdRight=null;this._captionElement=null;Sys.UI.Controls._TabButton.callBaseMethod(this,'dispose');},_addFillDiv:function(td,width,height){var div=$common.createDiv();$common.setBounds(div,width,height);td.appendChild(div);return div;},_addCaptionElement:function(td,caption){var div=$common.createDiv();div.style.whiteSpace="nowrap";div.innerHTML=caption;div.unselectable="on";this._captionElement=div;td.appendChild(div);},_initCloseButton:function(parentElement,caption,width){var table=$common.createTable();$common.setProperties(table,{width:width,height:"100%"});var body=$common.createTBody();var tr=$common.createTr();var skinImage=$skin.getImage("tab","closeButton");var td=$common.createTd();var buttonWidth=skinImage.imageWidth;var captionWidth=width-buttonWidth;$common.setProperties(td,{width:captionWidth,height:"100%"});this._addCaptionElement(td,caption);tr.appendChild(td);td=this._tdRight=$common.createTd();$common.setProperties(td,{width:buttonWidth,height:"100%"});td.className="TabCloseButton";td.vAlign="top";var buttonHeight=skinImage.imageHeight;var bounds=new Sys.UI.Bounds(null,null,buttonWidth,buttonHeight);var div=this._addFillDiv(td,buttonWidth,buttonHeight);var closeButton=this._closeButton=new Sys.UI.Controls.CustomSkinButton(div,skinImage,bounds);closeButton.initialize();closeButton.add_mouseDown(this._doButtonMouseDown,this);closeButton.add_click(this._doClose,this);tr.appendChild(td);body.appendChild(tr);table.appendChild(body);parentElement.appendChild(table);},get_tabPage:function(){return this._tabPage;},get_selected:function(){return this.get_tabPage().get_selected();},set_selected:function(value){value?this._initSelected():this._initNormal();},get_text:function(){return this._captionElement.innerHTML;},set_text:function(value){if(this._captionElement.innerHTML!=value){this._captionElement.innerHTML=value;}},doMouseOver:function(e){if(!this.get_selected()){this._initHover();}},_doButtonMouseDown:function(e){e.cancel();},_doClose:function Sys$UI$Controls$_TabButton$_doClose(sender,e){this.get_tabPage().close();},doDblClick:function(e){Sys.UI.Controls._TabButton.callBaseMethod(this,'doDblClick',[e]);this._doClose();},doMouseOut:function(e){if(!this.get_selected()){this._initNormal();}},doMouseDown:function(e){if(!this.get_selected()){var tabPage=this.get_tabPage();tabPage.get_pageControl().set_selectedTab(tabPage);}},doKeyDown:function(e){if(e.keyCode==Sys.UI.Key.enter){if(!this.get_selected()){this.doMouseDown();e.cancel();}}},_showCloseButton:function(show){if(this._closeButton){this._closeButton.set_visible(show);}},_initNormal:function(){this._internalInit(0);this._showCloseButton(false);},_initHover:function(){this._internalInit(1);this._showCloseButton(true);},_initSelected:function(){this._internalInit(2);this._showCloseButton(true);},_internalInit:function(state){var skinImage=this._skinImage;$common.setBackgroundImage(this._tdLeft,skinImage,state);$common.setBackgroundImage(this._tdMiddle,skinImage,3+state,"repeat-x");$common.setBackgroundImage(this._tdRight,skinImage,6+state);}}
Sys.UI.Controls._TabButton.registerClass('Sys.UI.Controls._TabButton',Sys.UI.Controls.Container);Sys.UI.Controls.TabPage=function Sys$UI$Controls$TabPage(element){Sys.UI.Controls.TabPage.initializeBase(this,[element]);this._tabButton=null;this._pageControlId=null;this._selected=false;this._name=null;this._pageControl=null;this._buttonElement=null;this._allowClose=true;}
Sys.UI.Controls.TabPage.prototype={initialize:function(){Sys.UI.Controls.TabPage.callBaseMethod(this,'initialize');var buttonElement=this._buttonElement;if(!buttonElement){buttonElement=this._buttonElement=$get(this.get_id()+"_button");} if(buttonElement&&Sys.UI.DomElement.getVisible(buttonElement)){this._initTabButton();} this.get_pageControl().addTab(this);},_initTabButton:function(){this._tabButton=new Sys.UI.Controls._TabButton(this,this._buttonElement);this._tabButton.set_form(this.get_form());this._tabButton.initialize();},dispose:function(){if(this._tabButton){this._tabButton.dispose();this._tabButton=null;} this._buttonElement=null;this._pageControl=null;Sys.UI.Controls.TabPage.callBaseMethod(this,'dispose');},get_pageControl:function(){var pageControl=this._pageControl;return pageControl?pageControl:this.get_form()[this._pageControlId];},set_pageControl:function(value){this._pageControl=value;},get_buttonElement:function(value){return this._buttonElement;},set_buttonElement:function(value){this._buttonElement=value;},get_tabButton:function(){return this._tabButton;},get_caption:function(){var tabButton=this.get_tabButton();return tabButton?tabButton.get_text():"";},set_caption:function(value){var tabButton=this.get_tabButton();if(tabButton){tabButton.set_text(value);var handler=this.get_events().getHandler("captionChanged");if(handler){handler(this);}}},add_captionChanged:function(handler){this.get_events().addHandler("captionChanged",handler);},remove_captionChanged:function(handler){this.get_events().removeHandler("captionChanged",handler);},get_tabPosition:function(){return this.get_pageControl().get_tabPosition();},get_allowClose:function(){return this._allowClose;},set_allowClose:function(value){this._allowClose=value;},get_showTabCloseButton:function(){return this.get_allowClose()?this.get_pageControl().get_showTabCloseButton():false;},close:function Sys$UI$Controls$TabPage$close(){if(this.get_allowClose()){this.get_pageControl().doTabClose(this);}},get_pageControlId:function(){return this._pageControlId;},set_pageControlId:function(value){this._pageControlId=value;},get_tabIndex:function(){return this.get_pageControl().indexOfTab(this);},get_name:function(){return this._name;},set_name:function(value){this._name=value;},get_visible:function(){var tabButton=this._tabButton;return tabButton&&tabButton.get_visible();},set_visible:function(value){if(!this._tabButton&&value&&this._buttonElement){Sys.UI.DomElement.setVisible(this._buttonElement,true);this._initTabButton();} if(this._tabButton){this._tabButton.set_visible(value);}},get_selected:function(){return this._selected;},set_selected:function(value){this._selected=value;this._selectedChanged();},_selectedChanged:function(){var active=this.get_selected();if(this._tabButton){this._tabButton.set_selected(active);} var elt=this.get_element();var style=elt.style;if(active){style.left="";style.top="";style.position="";} else{style.position="absolute";style.left="-10000px";style.top="-10000px";}}}
Sys.UI.Controls.TabPage.registerClass('Sys.UI.Controls.TabPage',Sys.UI.Control);Sys.UI.Controls.PageControlSelectEventArgs=function(oldTab,newTab){Sys.UI.Controls.PageControlSelectEventArgs.initializeBase(this);this._oldTab=oldTab;this._newTab=newTab;}
Sys.UI.Controls.PageControlSelectEventArgs.prototype={get_oldTab:function(){return this._oldTab;},get_newTab:function(){return this._newTab;},get_oldTabIndex:function(){var tab=this.get_oldTab();return tab?tab.get_tabIndex():-1;},get_newTabIndex:function(){var tab=this.get_newTab();return tab?tab.get_tabIndex():-1;}}
Sys.UI.Controls.PageControlSelectEventArgs.registerClass('Sys.UI.Controls.PageControlSelectEventArgs',Sys.CancelEventArgs);Sys.UI.Controls.TabPosition=function(){throw Error.notImplemented();}
Sys.UI.Controls.TabPosition.prototype={top:0,bottom:1}
Sys.UI.Controls.TabPosition.registerEnum("Sys.UI.Controls.TabPosition");Sys.UI.Controls.PageControl=function Sys$UI$Controls$PageControl(element){Sys.UI.Controls.PageControl.initializeBase(this,[element]);this._tabs=[];this._tabButtons=null;this._selectedTab=null;this._initTabIndex=null;this._showTabHeader=true;this._tabHeaderHidden=false;this._showTabCloseButton=false;this._tabPosition=Sys.UI.Controls.TabPosition.top;this._autoFocus=true;}
Sys.UI.Controls.PageControl.prototype={initialize:function Sys$UI$Controls$PageControl$initialize(){Sys.UI.Controls.PageControl.callBaseMethod(this,'initialize');if(this.get_showTabHeader()){$skin.cacheImage("tab","topTab");$skin.cacheImage("tab","closeButton");}},dispose:function Sys$UI$Controls$PageControl$dispose(){Sys.UI.Controls.PageControl.callBaseMethod(this,'dispose');},doFormInit:function Sys$UI$Controls$PageControl$doFormInit(){if(this._initTabIndex!=null){this._internalSetSelectedTabIndex(this._initTabIndex);}},get_showTabHeader:function Sys$UI$Controls$PageControl$get_showTabHeader(){return this._showTabHeader;},set_showTabHeader:function Sys$UI$Controls$PageControl$set_showTabHeader(value){this._showTabHeader=value;if(this.get_isInitialized()){throw Error.invalidOperation("客户端设置Tab头是否可见请用 set_tabHeaderHidden");}},get_autoFocus:function(){return this._autoFocus;},set_autoFocus:function(value){this._autoFocus=value;},get_tabHeaderHidden:function(){return this._tabHeaderHidden;},set_tabHeaderHidden:function(value){this._tabHeaderHidden=value;if(this.get_isInitialized()){var element=this.get_element();var header=$common.getFirstChildByTagName(element,"div");header.style.visibility=value?"hidden":"";}},get_showTabCloseButton:function(){return this._showTabCloseButton;},set_showTabCloseButton:function(value){this._showTabCloseButton=value;},get_tabPosition:function(){return this._tabPosition;},set_tabPosition:function(value){this._tabPosition=value;},get_tabCount:function Sys$UI$Controls$PageControl$get_tabCount(){return this._tabs.length;},getTab:function Sys$UI$Controls$PageControl$getTab(index){return this._tabs[index];},findTabByName:function(name){for(var i=0,count=this.get_tabCount();i<count;i++){var tab=this.getTab(i);if(tab.get_name()==name){return tab;}} return null;},indexOfTab:function Sys$UI$Controls$PageControl$indexOfTab(tab){return Array.indexOf(this._tabs,tab);},addTab:function Sys$UI$Controls$PageControl$addTab(tab){var index=this._tabs.length;Array.add(this._tabs,tab);return index;},removeTab:function(tab){var index=this.indexOfTab(tab);var isLast=index==this.get_tabCount()-1;var isSelected=tab.get_selected();var pageElement=tab.get_element();$removeNode(pageElement);var tabButton=tab.get_tabButton();if(tabButton){var tabElement=tabButton.get_element();var closeButton=tabButton._closeButton;if(closeButton){closeButton.get_element().style.backgroundImage="";} $removeNode(tabElement);} Array.remove(this._tabs,tab);tab.dispose();if(isSelected){this._selectedTab=null;this.set_selectedTabIndex(isLast?index-1:index);}},get_selectedTab:function(){return this._selectedTab;},set_selectedTab:function(value){var index=this.indexOfTab(value);if(index==-1){throw Error.argumentOutOfRange('value',value);} this._internalSetSelectedTab(value);},_internalSetSelectedTab:function(value){var oldTab=this._selectedTab;if(oldTab==value)return;if(oldTab!=null){if(this.get_autoFocus()){this._deactivateControls(oldTab);} var handler=this.get_events().getHandler("selecting");if(handler){var eventArgs=new Sys.UI.Controls.PageControlSelectEventArgs(oldTab,value);handler(this,eventArgs);if(eventArgs.get_cancel()){return;}} oldTab.set_selected(false);} this._selectedTab=value;if(value){value.set_selected(true);} if(this.get_autoFocus()&&oldTab!=null){this._activateControls(value);} var handler=this.get_events().getHandler("selected");if(handler){var eventArgs=new Sys.UI.Controls.PageControlSelectEventArgs(oldTab,value);handler(this,eventArgs);}},_deactivateControls:function(tab){var controls=this._getTabControls(tab);for(var i=0,count=controls.length;i<count;i++){var control=controls[i];if(control.doFormDeactivate){control.doFormDeactivate();}}},_activateControls:function(tab){var controls=this._getTabControls(tab);for(var i=0,count=controls.length;i<count;i++){var control=controls[i];if(Sys.UI.Control.canFocus(control)){window.asyncCall(function(){control.focus();});break;}}},_getTabControls:function(tab){var controls=[];this._doGetControls(tab.get_element(),true,controls);return controls;},_doGetControls:function(parentElement,isRoot,controls){if(!isRoot){var control=parentElement.control;if(control&&control.get_id()){Array.add(controls,control);}} var childNode=parentElement.firstChild;while(childNode!=null){if(childNode.tagName){this._doGetControls(childNode,false,controls);} childNode=childNode.nextSibling;}},get_selectedTabIndex:function(){var selectedTab=this.get_selectedTab();return selectedTab?selectedTab.get_tabIndex():-1;},set_selectedTabIndex:function(value){if(!this.get_isInitialized()){this._initTabIndex=value;} else{this._internalSetSelectedTabIndex(value);}},_internalSetSelectedTabIndex:function(value){if(value<-1||value>=this.get_tabCount()){throw Error.argumentOutOfRange("value");} this._internalSetSelectedTab(this.getTab(value));},add_selecting:function(handler,handlerOwner){return this.get_events().addHandler("selecting",handler,handlerOwner);},remove_selecting:function(handler){this.get_events().removeHandler("selecting",handler);},add_selected:function(handler,handlerOwner){return this.get_events().addHandler("selected",handler,handlerOwner);},remove_selected:function(handler){this.get_events().removeHandler("selected",handler);},add_tabClose:function(handler,handlerOwner){return this.get_events().addHandler("tabClose",handler,handlerOwner);},remove_tabClose:function(handler){this.get_events().removeHandler("tabClose",handler);},doTabClose:function Sys$UI$Controls$PageControl$doTabClose(tabPage){var handler=this.get_events().getHandler("tabClose");if(handler){handler(this,tabPage);}}}
Sys.UI.Controls.PageControl.registerClass('Sys.UI.Controls.PageControl',Sys.UI.Control);Sys.UI.Controls._MenuContainer=function(element){Sys.UI.Controls._MenuContainer.initializeBase(this,[element]);}
Sys.UI.Controls._MenuContainer.prototype={initialize:function(){Sys.UI.Controls._MenuContainer.callBaseMethod(this,'initialize');this.add_selectStart(this._selectStart);this.add_contextMenu(this._contextMenu);},dispose:function(){Sys.UI.Controls._MenuContainer.callBaseMethod(this,'dispose');},_selectStart:function(e){e.cancel();},_contextMenu:function(e){e.cancel();}}
Sys.UI.Controls._MenuContainer.registerClass('Sys.UI.Controls._MenuContainer',Sys.UI.Controls.NoFocusContainer);Sys.UI.Controls.MenuBar=function(element){Sys.UI.Controls.MenuBar.initializeBase(this,[element]);this._activeMenu=null;this._menus=null;this._menuMap=null;this._menuItemMap=null;}
Sys.UI.Controls.MenuBar.prototype={dispose:function(){delete this._menuMap;this._menus=null;var menuItemMap=this._menuItemMap;if(menuItemMap){for(var id in menuItemMap){var menuItem=menuItemMap[id];menuItem.dispose();} delete this._menuItemMap;} Sys.UI.Controls.MenuBar.callBaseMethod(this,'dispose');},get_activeMenu:function(){return this._activeMenu;},get_menus:function(){return this._menus;},set_menus:function(value){this._menus=value;},doFormInit:function(form){var menus=this._menus;if(!menus)return;var menuItemMap=this._menuItemMap={};var idPrefix='$'+form.get_id()+'$';for(var i=0,menuCount=menus.length;i<menuCount;i++){var items=menus[i].items;for(var j=0,itemCount=items.length;j<itemCount;j++){var item=items[j];if(item.properties.shortcut>0){var id=idPrefix+item.id;var div=this._createHiddenDiv();div.id=id;var menuItem=$createFromParams(item,div,form,true);menuItem.doFormInit(form);menuItemMap[id]=menuItem;}}}},_removeOldMenuItem:function(id){var menuItemMap=this._menuItemMap;var menuItem=menuItemMap[id];if(menuItem){var element=menuItem.get_element();menuItem.doFormUninit(this.get_form());menuItem.dispose();$removeNode(element);delete menuItemMap[id];}},_getMenuParams:function(menuId){var menusMap=this._menuMap;if(!menusMap){menusMap=this._menuMap={};var menus=this._menus;for(var i=0,count=menus.length;i<count;i++){var menu=menus[i];menusMap[menu.id]=menu;}} var answer=menusMap[menuId];if(!answer){throw Error.invalidOperation("找不到菜单 "+menuId);} return answer;},_createHiddenDiv:function(){var div=$common.createDiv();div.style.cssText="display:none";document.body.appendChild(div);return div;},_getMenu:function(menuId){var params=this._getMenuParams(menuId);var form=this.get_form();var sb=new Sys.StringBuilder();this._renderMenu(sb,params,form);var div=this._createHiddenDiv();div.innerHTML=sb.toString();var menuElement=div.firstChild;var menu=$createFromParams(params,menuElement,form);var rows=$common.getTableBody(menuElement);var row=rows.firstChild;var i=0;var items=params.items;while(row!=null){var id=row.id;if(id){var item=items[i];if(item.properties.shortcut>0){this._removeOldMenuItem(id);} var menuItem=$createFromParams(item,row,form);menuItem.doFormInit(form);i++;} row=row.nextSibling;} return menu;},_renderMenu:function(sb,params,form){var idPrefix='$'+form.get_id()+'$';var id=idPrefix+params.id;sb.append('<table class="Menu" id="').append(id).append('" border="0" cellpadding="0" cellspacing="0">');this._renderMenuHeadFoot(sb,true);sb.append("<tbody>");var items=params.items;for(var i=0,count=items.length;i<count;i++){var item=items[i];this._renderMenuItem(sb,item,idPrefix);} sb.append("</tbody>");this._renderMenuHeadFoot(sb,false);sb.append("</table>");},_renderMenuHeadFoot:function(sb,isHead){var tag=isHead?"thead":"tfoot";sb.append('<').append(tag).append('><tr><td colspan="5" /></tr></').append(tag).append('>');},_renderMenuItem:function(sb,item,idPrefix){var renderProps=item.renderProps;if(renderProps.beginGroup){sb.append('<tr class="MenuSeperator">');sb.append('<td class="MenuImage" colspan="2" />');sb.append('<td class="MenuCaption" colspan="3"><img /></td>');sb.append('</tr>');} var id=idPrefix+item.id;var props=item.properties;sb.append('<tr class="MenuItem" id="').append(id).append('"');if(renderProps.hidden){sb.append(' style="display:none"');} if(renderProps.disabled){sb.append(' disabled="true"');} sb.append('>');sb.append('<td class="MenuSpacerLeft" />');sb.append('<td class="MenuImage">');var icon=renderProps.icon;if(icon){sb.append('<img src="').append($common.getResourceUrl(icon)).append('" align="absbottom" />');} sb.append('</td>');sb.append('<td class="MenuCaption">').append(props.text).append('</td>');var hasChildren=props.subMenu;var hasShortcut=renderProps.shortcut;var className=hasChildren?"MenuMore":(hasShortcut?"MenuShortcut":"MenuNoMore");var rightArrow=!Sys.Browser.isFirefox?"<font face=\"webdings\">4</font>":"<span style=\"font-size:12px\">&#9658;</span>";var text=hasChildren?rightArrow:(hasShortcut?renderProps.shortcut:"&nbsp;");sb.append('<td class="').append(className).append('">').append(text).append('</td>');sb.append('<td class="MenuSpacerRight" />');sb.append('</tr>');}}
Sys.UI.Controls.MenuBar.registerClass('Sys.UI.Controls.MenuBar',Sys.UI.Controls._MenuContainer);Sys.UI.Controls.MenuItemBase=function(element){Sys.UI.Controls.MenuItemBase.initializeBase(this,[element]);this._requireClick=true;this._text=null;this._param=null;this._showPage=null;this._navigateUrl=null;}
Sys.UI.Controls.MenuItemBase.prototype={initialize:function(){Sys.UI.Controls.MenuItemBase.callBaseMethod(this,'initialize');},dispose:function(){Sys.UI.Controls.MenuItemBase.callBaseMethod(this,'dispose');},doClick:function(e){Sys.UI.Controls.MenuItemBase.callBaseMethod(this,'doClick',[e]);var showPage=this.get_showPage();var navigateUrl=this.get_navigateUrl();if(showPage){$common.showPage(this,showPage,this.get_text());} else if(navigateUrl){window.open(navigateUrl);}},get_hasAction:function(){return this._showPage||this._navigateUrl;},get_text:function(){return this._text;},set_text:function(value){this._text=value;if(this.get_isInitialized()){var element=this.get_element();if(element){var textElement=$common.getFirstChildByClassName(element,"MenuCaption");if(textElement){textElement.innerHTML=value;}}}},get_param:function(){return this._param;},set_param:function(value){this._param=value;},get_showPage:function(){return this._showPage;},set_showPage:function(value){this._showPage=value;},get_navigateUrl:function(){return this._navigateUrl;},set_navigateUrl:function(value){this._navigateUrl=value;}}
Sys.UI.Controls.MenuItemBase.registerClass('Sys.UI.Controls.MenuItemBase',Sys.UI.Controls.NoFocusContainer);Sys.UI.Controls.MenuRoot=function(element){Sys.UI.Controls.MenuRoot.initializeBase(this,[element]);this._requireMouseOver=true;this._requireMouseOut=true;this._requireMouseDown=true;this._menu=null;this._isActive=false;this._skinElement=null;}
Sys.UI.Controls.MenuRoot.prototype={initialize:function(){Sys.UI.Controls.MenuRoot.callBaseMethod(this,'initialize');this._documentClickHandler=Function.createDelegate(this,this._documentClick);this._skinElement=$skin.getElement("menu","menuRootActive");},dispose:function(){this._documentClickHandler=null;Sys.UI.Controls.MenuRoot.callBaseMethod(this,'dispose');},get_menu:function(){return this._menu;},set_menu:function(value){this._menu=value;},_getEventTargetMenu:function Sys$UI$Controls$MenuRoot$_getEventTargetMenu(e){var cell=e.target;if(cell.tagName=="DIV"){return cell.parentNode;} else if(cell.tagName=="TD"){return cell;} else{return null;}},get_menuBar:function(){var menuBar=this.get_parent();if(!this._parent){this.set_parent(menuBar);} return menuBar;},get_isActive:function(){return this._isActive;},doMouseOver:function(e){Sys.UI.Controls.MenuRoot.callBaseMethod(this,'doMouseOver',[e]);var elt=this._getEventTargetMenu(e);if(elt&&this.get_enabled()){var menuBar=this.get_menuBar();if(this._checkHideOtherMenu()){this._showActive();this.showMenu();this._isActive=true;} else if(!this._isActive){var activeMenu=menuBar._activeMenu;if(activeMenu!=null){if(activeMenu.get_element().parentNode==this.get_element().parentNode){this._showOver();}} else{this._showOver();}}}},doMouseOut:function(e){Sys.UI.Controls.MenuRoot.callBaseMethod(this,'doMouseOut',[e]);var elt=this._getEventTargetMenu(e);if(elt&&this.get_enabled()){if(!this._isActive){this._showNormal();}}},doMouseDown:function(e){Sys.UI.Controls.MenuRoot.callBaseMethod(this,'doMouseDown',[e]);var elt=this._getEventTargetMenu(e);if(elt&&this.get_enabled()&&(e.button==Sys.UI.MouseButton.leftButton)){if(!this._isActive){this._showActive();this.showMenu();this._isActive=true;} else{this.hideMenu();this._showOver();}}},doClick:function(e){Sys.UI.Controls.MenuRoot.callBaseMethod(this,'doClick',[e]);if(this.get_hasAction()||!this.get_menu()){if(this._isActive){this.hideMenu();} else{this._showNormal();}}},_checkHideOtherMenu:function(){var activeMenu=this.get_menuBar()._activeMenu;if(activeMenu){activeMenu.hideMenu();} return activeMenu!=null;},set_enabled:function(value){Sys.UI.Controls.MenuRoot.callBaseMethod(this,'set_enabled',[value]);if(this.get_isInitialized()){this.get_element().className=value?"MenuRoot":"MenuRootDisabled";}},_getMenuCaption:function Sys$UI$Controls$MenuRoot$_getMenuCaption(){return this.get_element().firstChild;},_showNormal:function Sys$UI$Controls$MenuRoot$_showNormal(){var elt=this._getMenuCaption();elt.style.backgroundImage="";elt.style.border="";elt.style.margin="";},_setHoverOrDown:function Sys$UI$Controls$MenuRoot$_initActive(isDown){var elt=this._getMenuCaption();var skinImage=$skin.getElementImage(this._skinElement);$common.setBackgroundImage(elt,skinImage,isDown?1:0,"repeat-x");elt.style.border=this._skinElement.border;elt.style.margin="0px 0px 0px 0px";},_showOver:function Sys$UI$Controls$MenuRoot$_showOver(){this._setHoverOrDown(false);},_showActive:function(){this._setHoverOrDown(true);},_getMenuControl:function(){var menu=this.get_menu();if(menu){var answer=this.get_form()[menu];return answer?answer:this.get_menuBar()._getMenu(menu);} return null;},showMenu:function(){var r=this.get_bounds();var x=r.x;var y=r.y+r.height-2;$common.addClickHandler(window.document,this._documentClickHandler);var menu=this._getMenuControl();if(menu){menu.show(x,y);} this.get_menuBar()._activeMenu=this;},hideMenu:function(){$common.removeClickHandler(window.document,this._documentClickHandler);var menu=this._getMenuControl();if(menu){menu.hide();} this._showNormal();this._isActive=false;this.get_menuBar()._activeMenu=null;},_documentClick:function(e){var elt=this._getEventTargetMenu(e);if(!elt||elt.className!="MenuRoot"){var menuItem=Sys.UI.Controls.MenuItem._getEventTargetMenuItem(e);if(!menuItem||!menuItem.get_hasSubMenu()){this.hideMenu();e.cancel();}}}}
Sys.UI.Controls.MenuRoot.registerClass('Sys.UI.Controls.MenuRoot',Sys.UI.Controls.MenuItemBase);Sys.UI.Controls.Menu=function(element){Sys.UI.Controls.Menu.initializeBase(this,[element]);this._requireMouseOver=true;this._requireMouseOut=true;this._requireClick=true;this._inited=false;this._skinElement=null;this._activeMenuItemElement=null;this._activeSubMenu=null;this._menuShadowArray=new Array(null,null,null,null);this._isPopup=false;}
Sys.UI.Controls.Menu._lastPopup=null;Sys.UI.Controls.Menu.prototype={initialize:function(){Sys.UI.Controls.Menu.callBaseMethod(this,'initialize');},dispose:function(){for(var i=0;i<this._menuShadowArray.length;i++){var menuShadow=this._menuShadowArray[i];if(menuShadow){menuShadow.style.visibility="hidden";$removeNode(menuShadow);this._menuShadowArray[i]=null;}} this._clearDocumentClickHandler();var element=this.get_element();if(element.style.visibility=="visible"){document.body.removeChild(element);if(this.get_isPopup()){Sys.UI.Controls.Menu._lastPopup=null;}} Sys.UI.Controls.Menu.callBaseMethod(this,'dispose');},_init:function(){if(this._inited)return;this._skinElement=$skin.getElement("menu","menuItemActive");var blankImageSrc=$skin.getBlankImageSrc();var menuProps=$skin.getElement("menu","properties");var blankImg="<img src='"+blankImageSrc+"' width="+menuProps.iconWidth+" height="+menuProps.iconHeight+">";var elt=this.get_element();var tbody=$common.getTableBody(elt);for(var i=0;i<tbody.childNodes.length;i++){var menuItem=tbody.childNodes[i];if(menuItem.className!="MenuSeperator"){if(!this._isMenuItemEnabled(menuItem)){this.setMenuItemEnabled(menuItem,false);} var menuImage=$common.getFirstChildByClassName(menuItem,"MenuImage");var img=menuImage.firstChild;if(img){img.width=menuProps.iconWidth;img.height=menuProps.iconHeight;} else{menuImage.innerHTML=blankImg;}}} for(var i=0;i<4;i++){var menuShadow=$common.createShadow();document.body.appendChild(menuShadow);this._menuShadowArray[i]=menuShadow;} this._inited=true;},doMouseOver:function(e){Sys.UI.Controls.Menu.callBaseMethod(this,'doMouseOver',[e]);var elt=Sys.UI.Controls.MenuItem._getEventTargetMenuItemElement(e);if(elt&&this._isMenuItemEnabled(elt)){this._deactivate();this._showMenuItemSubMenu(elt);this._showMenuItemOver(elt);}},doMouseOut:function(e){Sys.UI.Controls.Menu.callBaseMethod(this,'doMouseOut',[e]);var elt=Sys.UI.Controls.MenuItem._getEventTargetMenuItemElement(e);if(elt&&this._isMenuItemEnabled(elt)){this._showMenuItemNormal(elt);}},doClick:function(e){Sys.UI.Controls.Menu.callBaseMethod(this,'doClick',[e]);var menuItem=Sys.UI.Controls.MenuItem._getEventTargetMenuItemElement(e);if(menuItem&&!this._isMenuItemEnabled(menuItem)){e.cancel();}},_isMenuItemEnabled:function(elt){return Sys.UI.DomElement.getEnabled(elt);},_showMenuItemNormal:function(elt){var count=elt.childNodes.length;for(var i=1;i<count-1;i++){var td=elt.childNodes[i];var style=td.style;style.backgroundImage=td._oldBackgroundImage||"";style.backgroundRepeat=td._oldBackgroundRepeat||"";style.backgroundPosition="center center";style.borderColor="";style.borderStyle="";style.borderWidth="";if(i==1){td.firstChild.style.margin="";} else if(i==count-2){style.paddingRight="";}} this._activeMenuItemElement=null;},_showMenuItemOver:function(elt){var skinElement=this._skinElement;var skinImage=$skin.getElementImage(skinElement);var count=elt.childNodes.length;for(var i=1;i<count-1;i++){var td=elt.childNodes[i];if(!td._oldBackgroundImage){var currentStyle=Sys.UI.DomElement._getCurrentStyle(td);td._oldBackgroundImage=currentStyle.backgroundImage;td._oldBackgroundRepeat=currentStyle.backgroundRepeat;} $common.setBackgroundImage(td,skinImage,0,"repeat-x");var style=td.style;style.borderColor=skinElement.borderColor;style.borderStyle="solid";if(i==1){style.borderWidth="1px 0px 1px 1px";td.firstChild.style.margin=skinElement.imageMargin;} else if(i==count-2){style.borderWidth="1px 1px 1px 0px";style.paddingRight=skinElement.paddingRight;} else{style.borderWidth="1px 0px 1px 0px";}} this._activeMenuItemElement=elt;},setMenuItemEnabled:function(elt,value){Sys.UI.DomElement.setEnabled(elt,value);},_showMenuShadow:function(elt,x,y){elt.style.zIndex=9999;for(var i=3;i>=0;i--){var style=this._menuShadowArray[i].style;style.left=(x+(4+i))+"px";style.top=(y+(4+i))+"px";style.width=(elt.offsetWidth-(i*2))+"px";style.height=(elt.offsetHeight-(i*2))+"px";style.zIndex=elt.style.zIndex-1;style.visibility="visible";}},_hideMenuShadow:function(){for(var i=0;i<=3;i++){if(this._menuShadowArray[i]!=null){this._menuShadowArray[i].style.visibility="hidden";}}},_calcPopupPosition:function(x0,y0,popupWidth,popupHeight,ownerWidth){var rWin=window.getClientBounds();var xNew=x0;if(x0+popupWidth>rWin.width){if(ownerWidth>0){xNew=x0+ownerWidth-popupWidth;} else{xNew=rWin.width-popupWidth-4;}} var yNew=y0;if(y0+popupHeight>rWin.height){yNew=y0-popupHeight;} return{x:xNew,y:yNew};},add_popup:function(handler){this.get_events().addHandler("popup",handler);},remove_popup:function(handler){this.get_events().removeHandler("popup",handler);},popup:function(e){if(!e)return;this.popupAt(e.clientX,e.clientY);e.stopPropagation();},popupAt:function(x,y,ownerWidth){var handler=this.get_events().getHandler("popup");if(handler){handler(this);} if(!this._documentClickHandler){this._documentClickHandler=$common.addClickHandler(window.document,this._documentClick,this);} if(Sys.UI.Controls.Menu._lastPopup&&Sys.UI.Controls.Menu._lastPopup!=this){Sys.UI.Controls.Menu._lastPopup.hide();} if(!this._inited){this._init();} var element=this.get_element();var p=this._calcPopupPosition(x,y,element.offsetWidth,element.offsetHeight,ownerWidth);this.show(p.x,p.y);Sys.UI.Controls.Menu._lastPopup=this;},_clearDocumentClickHandler:function(){if(this._documentClickHandler){$common.removeClickHandler(window.document,this._documentClickHandler);this._documentClickHandler=null;}},_documentClick:function(e){this._clearDocumentClickHandler();this.hide();Sys.UI.Controls.Menu._lastPopup=null;},show:function(x,y){if(!this._inited){this._init();} var elt=this.get_element();if(elt.parentNode!=document.body){document.body.appendChild(elt);} var style=elt.style;style.position="absolute";style.left=x+"px";style.top=y+"px";this._showMenuShadow(elt,x,y);style.visibility="visible";},_deactivate:function(){if(this._activeSubMenu!=null){this._activeSubMenu.hide();this._activeSubMenu=null;} if(this._activeMenuItemElement!=null){this._showMenuItemNormal(this._activeMenuItemElement);this._activeMenuItemElement=null;}},hide:function(){this._deactivate();this._hideMenuShadow();this.get_element().style.visibility="hidden";},get_isPopup:function(){return this._isPopup;},set_isPopup:function(value){this._isPopup=value;},_getSubMenu:function(menuItem,subMenuId){var answer=this.get_form()[subMenuId];if(this.get_isPopup()){return answer;} else if(!answer){var menuRoot=menuItem.get_menuRoot();if(menuRoot){var menuBar=menuRoot.get_menuBar();if(menuBar){answer=menuBar._getMenu(subMenuId);}}} return answer;},_showMenuItemSubMenu:function(elt){var menuItem=elt.control;var subMenuId=menuItem?menuItem.get_subMenu():null;if(!subMenuId){return;} this._activeSubMenu=this._getSubMenu(menuItem,subMenuId);if(this._activeSubMenu!=null){var r=Sys.UI.DomElement.getBounds(elt);var x=r.x+r.width;var y=r.y;this._activeSubMenu._init();var sub=this._activeSubMenu.get_element();var subR=Sys.UI.DomElement.getBounds(sub);var bodyR=Sys.UI.DomElement.getBounds(document.body);if(x+subR.width>bodyR.width){x=r.x-subR.width;} this._activeSubMenu.show(x,y);this._activeSubMenu.get_element().style.zIndex=this.get_element().style.zIndex+1;}}}
Sys.UI.Controls.Menu.registerClass('Sys.UI.Controls.Menu',Sys.UI.Controls._MenuContainer);Sys.UI.Controls.MenuItem=function(element){Sys.UI.Controls.MenuItem.initializeBase(this,[element]);this._subMenu=null;this._shortcut=0;}
Sys.UI.Controls.MenuItem.prototype={initialize:function(){Sys.UI.Controls.MenuItem.callBaseMethod(this,'initialize');},dispose:function(){Sys.UI.Controls.MenuItem.callBaseMethod(this,'dispose');},doFormInit:function(form){if(this.get_enabled()){form.addShortcut(this.get_shortcut(),this.click,this);}},doFormUninit:function(form){if(this.get_enabled()){form.removeShortcut(this.get_shortcut());}},get_menuRoot:function(){var id=this.get_id();var pos=id.indexOf('_');if(pos>0){var rootId=id.substr(0,pos);var answer=$find(rootId);return answer&&(answer instanceof Sys.UI.Controls.MenuRoot)?answer:null;} return null;},doClick:function(e){if(!this.get_hasSubMenu()){var menuRoot=this.get_menuRoot();if(menuRoot&&menuRoot.get_isActive()){menuRoot.hideMenu();}} Sys.UI.Controls.MenuItem.callBaseMethod(this,'doClick',[e]);},get_subMenu:function(){return this._subMenu;},set_subMenu:function(value){this._subMenu=value;},get_hasSubMenu:function(){return this._subMenu!=null;},get_shortcut:function(){return this._shortcut;},set_shortcut:function(value){this._shortcut=value;}}
Sys.UI.Controls.MenuItem.registerClass('Sys.UI.Controls.MenuItem',Sys.UI.Controls.MenuItemBase);Sys.UI.Controls.MenuItem._getEventTargetMenuItemElement=function(e){var elt=e.target;if(elt.tagName=="IMG"||elt.tagName=="B"){elt=elt.parentNode;} if(elt.tagName=="TD"){elt=elt.parentNode;} if(elt.tagName=="TR"){return elt.className!="MenuSeperator"?elt:null;} else{return null;}}
Sys.UI.Controls.MenuItem._getEventTargetMenuItem=function(e){var element=Sys.UI.Controls.MenuItem._getEventTargetMenuItemElement(e);if(element){var control=element.control;return control&&Sys.UI.Controls.MenuItem.isInstanceOfType(control)?control:null;}}
Sys.UI.Controls._ClientPanel=function(element){Sys.UI.Controls._ClientPanel.initializeBase(this,[element]);this._showPage=null;this._isShowingStartPage=false;}
Sys.UI.Controls._ClientPanel.prototype={initialize:function(){Sys.UI.Controls._ClientPanel.callBaseMethod(this,'initialize');},dispose:function(){Sys.UI.Controls._ClientPanel.callBaseMethod(this,'dispose');},_internalShowStartPage:function(){var savedShowPage=this._showPage;var startPage=window.location.hash;if(startPage){if(startPage.length>0&&startPage.charAt(0)=='#'){startPage=startPage.substr(1);} startPage=decodeURIComponent(startPage);if(startPage){this._showPage=startPage;}} if(this._showPage){this._isShowingStartPage=this._showPage==savedShowPage;window.asyncCall(Function.createDelegate(this,this.doShowStartPage));}},doShowStartPage:function(){var showPage=this._showPage;if(!this._isShowingStartPage){var cParams="__Params=";var pos=showPage.indexOf(cParams);var params=null;if(pos>0){var paramsStr=showPage.substring(pos+cParams.length);if(paramsStr){var pos=paramsStr.indexOf('&');if(pos>0){paramsStr=paramsStr.substr(0,pos);} paramsStr=unescape(paramsStr);params=Sys.Serialization.JavaScriptSerializer.deserialize(paramsStr,true);}} this.showPage(showPage,null,params);} else{var pages=showPage.split(',');var count=pages.length;if(count==1){this.showPage(showPage);} else{var i=0;var loopFunc=Function.createDelegate(this,function(){var page=pages[i].trim();var form=this.showPage(page);form.add_loaded(function(){i++;if(i<count){loopFunc();}});});loopFunc();}} this._showPage=null;this._isShowingStartPage=false;},_internalShowPage:function(formType,url,contentElement,params,pageTimeout,clientSize){var form=new formType();form._parentForm=this.get_form();form.set_pageTimeout(pageTimeout>0?pageTimeout:Sys.Net.WebRequestManager.get_defaultTimeout());form.set_clientSize(clientSize);form.showPage(url,contentElement,params);return form;},_internalSaveLocation:function(url){var hash=url?encodeURIComponent(url):"#";if(Sys.Browser.isIE&&Sys.Browser.version>=7&&hash.length>2046){return;} window.location.hash=hash;},get_showPage:function(){return this._showPage;},set_showPage:function(value){this._showPage=value;}}
Sys.UI.Controls._ClientPanel.registerClass('Sys.UI.Controls._ClientPanel',Sys.UI.Control);Sys.UI.Controls.SDIPanel=function(element){Sys.UI.Controls.SDIPanel.initializeBase(this,[element]);this._lastForm=null;}
Sys.UI.Controls.SDIPanel.prototype={initialize:function(){Sys.UI.Controls.SDIPanel.callBaseMethod(this,'initialize');this._internalShowStartPage();},dispose:function(){Sys.UI.Controls.SDIPanel.callBaseMethod(this,'dispose');},showPage:function(url,caption,params){if(this._lastForm){this._lastForm.dispose();this._lastForm=null;} this._lastForm=this._internalShowPage(Sys.UI.CustomForm,url,this.get_element(),params);this._internalSaveLocation(url);return this._lastForm;}}
Sys.UI.Controls.SDIPanel.registerClass('Sys.UI.Controls.SDIPanel',Sys.UI.Controls._ClientPanel);Sys.UI.Controls._MDIChild=function(){Sys.UI.Controls._MDIChild.initializeBase(this);}
Sys.UI.Controls._MDIChild.prototype={initialize:function(){Sys.UI.Controls._MDIChild.callBaseMethod(this,'initialize');},dispose:function Sys$UI$Controls$_MDIChild$dispose(){var t0=new Date().getTime();this._tabPage=null;Sys.UI.Controls._MDIChild.callBaseMethod(this,'dispose');$debug.log("表单释放时间: "+(new Date().getTime()-t0));},get_caption:function(){return this._caption;},set_caption:function(value){this._caption=value;if(this._tabPage){this._tabPage.set_caption(value);}},get_element:function(){return this._tabPage.get_element();},canClose:function(){if(this._forceClose){return true;} else{var eventArgs=new Sys.UI.FormCloseEventArgs();this.doClose(eventArgs);return eventArgs.get_canClose();}},get_isActive:function(){var tabPage=this._tabPage;return!Sys.Application.get_hasModalPopup()&&(tabPage?tabPage.get_selected():false);},set_isActive:function(value){var tabPage=this._tabPage;if(value&&tabPage){tabPage.get_pageControl().set_selectedTab(tabPage);}},doCancel:function(){this.close();},close:function(forceClose){this._forceClose=forceClose;if(this._tabPage){this._tabPage.close();}}}
Sys.UI.Controls._MDIChild.registerClass('Sys.UI.Controls._MDIChild',Sys.UI.CustomForm);Sys.UI.Controls.MDIPanel=function(element){Sys.UI.Controls.MDIPanel.initializeBase(this,[element]);this._showPageAllowClose=true;this._childsElement=null;this._barElement=null;this._windowResizeHandler=null;this._pageControl=null;this._tabsRow=null;this._homePage=null;}
Sys.UI.Controls.MDIPanel.prototype={initialize:function(){Sys.UI.Controls.MDIPanel.callBaseMethod(this,'initialize');this._tabCaptionChangedHandler=Function.createDelegate(this,this._tabCaptionChanged);this._initElements();this._internalShowStartPage();},dispose:function(){if(this._windowResizeHandler){$common.removeResizeHandler(this._getResizeElement(),this._windowResizeHandler);this._windowResizeHandler=null;} var pageControl=this._pageControl;if(pageControl){var count=pageControl.get_tabCount();for(var i=count-1;i>=0;i--){var tabPage=pageControl.getTab(i);var form=tabPage._form;if(form){form._tabPage=null;} tabPage._form=null;tabPage.dispose();} pageControl.dispose();this._pageControl=null;} this._tabsBar=null;this._tabsTable=null;this._tabsRow=null;this._tabNav=null;if(this._statusBars){delete this._statusBars;} if(this._tabLeftButton){this._tabLeftButton.dispose();this._tabLeftButton=null;} if(this._tabRightButton){this._tabRightButton.dispose();this._tabRightButton=null;} this._tabCaptionChangedHandler=null;Sys.UI.Controls.MDIPanel.callBaseMethod(this,'dispose');},doFormInit:function(){this._doWindowResize();},addStatusBar:function(statusBar){if(!this._statusBars){this._statusBars=[];} statusBar.set_visible(true);Array.add(this._statusBars,statusBar);this._doWindowResize();},_initElements:function(){var element=this.get_element();var divs=$common.getChildrenByTagName(element,"div");var barElement=this._barElement=divs[0];this._childsElement=divs[1];var tabsBar=this._tabsBar=$common.getLastChildByTagName(barElement,"div");var table=this._tabsTable=$common.getFirstChildByTagName(tabsBar,"table");this._tabsRow=$common.getTableFirstRow(table);var style=Sys.UI.DomElement._getCurrentStyle(this._childsElement);this._childsPaddingTopBottom=parseInt(style.paddingTop)+parseInt(style.paddingBottom);this._childsPaddingLeftRight=parseInt(style.paddingLeft)+parseInt(style.paddingRight);this._windowResizeHandler=$common.addResizeHandler(this._getResizeElement(),this._doWindowResize,this);this._doWindowResize();var pageControl=this._pageControl=$create(Sys.UI.Controls.PageControl,{"showTabCloseButton":true,"autoFocus":false},this._childsElement,null,this.get_form(),true);pageControl.add_selecting(this._doTabSelecting,this);pageControl.add_selected(this._doTabSelected,this);pageControl.add_tabClose(this._doTabClose,this);},_getResizeElement:function(){if(window.parent==window){return window;} else{return document.documentElement;}},_doWindowResize:function Sys$UI$Controls$MDIPanel$_doWindowResize(e){var clientBounds=window.getClientBounds();var clientFullWidth=clientBounds.width;var clientFullHeight=clientBounds.height;var clientHeight=clientFullHeight-this._barElement.offsetHeight-this._childsPaddingTopBottom-this.get_element().offsetTop;var statusBars=this._statusBars;if(statusBars){for(var i=0,count=statusBars.length;i<count;i++){var statusBar=statusBars[i];var element=statusBar.get_element();clientHeight-=element.offsetHeight;statusBar.doAdjustWidth(clientFullWidth);}} if(clientHeight>100){this._childsElement.style.height=clientHeight+"px";} var clientWidth=clientFullWidth-this._childsPaddingLeftRight;if(clientWidth>100){this._childsElement.style.width=clientWidth+"px";} var tabBarWidth=clientWidth;if(clientWidth>100){tabBarWidth-=52;} var tabsBar=this._tabsBar;if(tabsBar.offsetWidth!=tabBarWidth){tabsBar.style.width=tabBarWidth+"px";this._tabsSizeChanged();}},get_showPageAllowClose:function(){return this._showPageAllowClose;},set_showPageAllowClose:function(value){this._showPageAllowClose=value;},doShowStartPage:function(){if(this._isShowingStartPage&&!this.get_showPageAllowClose()){this._disableStartPageClose=true;} try{Sys.UI.Controls.MDIPanel.callBaseMethod(this,'doShowStartPage');} finally{this._disableStartPageClose=false;}},doInitNewTabPage:function(props){if(this._disableStartPageClose){props.allowClose=false;}},_findTabPage:function(url,caption){var name=this.get_form().convertUrl(url);return this._pageControl.findTabByName(name);},_getTabPage:function(url,caption){var tabPage=this._findTabPage(url);if(!tabPage){tabPage=this._createTabPage(url,caption);} else{this._pageControl.set_selectedTab(tabPage);} return tabPage;},get_pageCount:function(){return this._pageControl.get_tabCount();},set_activeForm:function(form){var pageControl=this._pageControl;var count=pageControl.get_tabCount();for(var i=0;i<count;i++){var tabPage=pageControl.getTab(i);if(tabPage._form==form){pageControl.set_selectedTab(tabPage);break;}}},get_forms:function(){var pageControl=this._pageControl;var count=pageControl.get_tabCount();var answer=new Array(count);for(var i=0;i<count;i++){answer[i]=pageControl.getTab(i)._form;} return answer;},_createTabPage:function Sys$UI$Controls$MDIPanel$_createTabPage(url,caption){var pageControl=this._pageControl;var div=$common.createDiv();div.className="MDIChild";this._childsElement.appendChild(div);var td=$common.createTd();td.className="TabTopCaptionClose";td.innerHTML=caption;this._tabsRow.appendChild(td);var tabPageProps={"pageControl":pageControl,"buttonElement":td};this.doInitNewTabPage(tabPageProps);var form=this.get_form();var tabPage=$create(Sys.UI.Controls.TabPage,tabPageProps,div,null,form,true);var name=form.convertUrl(url);tabPage.set_name(name);pageControl.set_selectedTab(tabPage);return tabPage;},showContent:function(name,caption,content){var tabPage=this._getTabPage(name,caption);tabPage.get_element().innerHTML=content;},showPage:function Sys$UI$Controls$MDIPanel$showPage(url,caption,params,pageTimeout){var tabPage=this._findTabPage(url);if(!tabPage){var maxMDIPageCount=$settings.maxMDIPageCount;if(!maxMDIPageCount){maxMDIPageCount=20;} var pageControl=this._pageControl;var tabCount=pageControl.get_tabCount();if(tabCount>=maxMDIPageCount){$common.alert("窗口数量不能超过"+maxMDIPageCount+"个，请关掉部分再新开！");throw Error.abort();} var clientSize="ClientHeight="+(this._childsElement.offsetHeight-10-18);clientSize+=",ClientWidth="+(this._childsElement.offsetWidth-10-18);if(!caption){caption="&nbsp;……&nbsp;";} tabPage=this._createTabPage(url,caption);var form=this._internalShowPage(Sys.UI.Controls._MDIChild,url,tabPage.get_element(),params,pageTimeout,clientSize);tabPage._form=form;form._tabPage=tabPage;this._internalSaveLocation(url);tabPage.add_captionChanged(this._tabCaptionChangedHandler);this._scrollNewTabToVisible();return form;} else{this._pageControl.set_selectedTab(tabPage);return null;}},_tabsSizeChanged:function(){var bar=this._tabsBar;var table=this._tabsTable;var tabNavVisible=this._tabNavVisible=table.offsetWidth>bar.offsetWidth;var tabNav=this._tabNav;if(tabNavVisible){if(!tabNav){tabNav=this._tabNav=this._createTabNavButtons();}} if(tabNav){Sys.UI.DomElement.setVisible(tabNav,tabNavVisible);} if(tabNavVisible){this._initNavButtons();}},_createTabNavButtons:function(){var table=$common.createTable();table.style.marginTop="1px";var body=$common.createTBody();var row=$common.createTr();var cell=$common.createTd();cell.width=5;row.appendChild(cell);this._tabLeftButton=this._createTabNavButton(row,"prevPage",this._tabLeft);this._tabRightButton=this._createTabNavButton(row,"nextPage",this._tabRight);body.appendChild(row);table.appendChild(body);this._barElement.appendChild(table);return table;},_createTabNavButton:function(parentRow,elementName,onClick){var skinImage=$skin.getImage("pager",elementName);var bounds=new Sys.UI.Bounds(null,null,skinImage.imageWidth,skinImage.imageHeight);var cell=$common.createTd();var button=new Sys.UI.Controls.CustomSkinButton(cell,skinImage,bounds);button.initialize();button.add_click(onClick,this);parentRow.appendChild(cell);return button;},_tabLeft:function(e){this._tabScroll(-1);},_tabRight:function(e){this._tabScroll(1);},_tabCaptionChanged:function(sender){this._scrollNewTabToVisible();},_scrollNewTabToVisible:function(){this._tabsSizeChanged();if(this._tabNavVisible){var bar=this._tabsBar;var table=this._tabsTable;bar.scrollLeft=table.offsetWidth-bar.offsetWidth;this._initNavButtons();}},_initNavButtons:function(){var pageControl=this._pageControl;var count=pageControl.get_tabCount();var index=pageControl.get_selectedTabIndex();var canTabLeft=index>0;var canTabRight=index<count-1;this._tabLeftButton.set_enabled(canTabLeft);this._tabRightButton.set_enabled(canTabRight);},_calScrollLeft:function(index){var tabWidth=0;var pageControl=this._pageControl;for(var i=0;i<index;i++){var tab=pageControl.getTab(i);var buttonElement=tab.get_buttonElement();tabWidth+=buttonElement.offsetWidth;} return tabWidth;},_tabScroll:function(inc){var pageControl=this._pageControl;var count=pageControl.get_tabCount();var newIndex=pageControl.get_selectedTabIndex()+inc;if(newIndex<0||newIndex>=count){return;} pageControl.set_selectedTabIndex(newIndex);},closePage:function(url){var tabPage=this._findTabPage(url);if(tabPage){tabPage.close();}},_doTabSelecting:function(sender,eventArgs){var tabPage=eventArgs.get_oldTab();var form=tabPage._form;if(form){var caption=form.get_caption();form.blur();}},_doTabSelected:function(sender,eventArgs){var tabPage=eventArgs.get_newTab();var form=tabPage._form;if(form){var caption=form.get_caption();this._internalSaveLocation(form.get_url());form.focus();if(this._tabNavVisible){var bar=this._tabsBar;var index=this._pageControl.get_selectedTabIndex();bar.scrollLeft=this._calScrollLeft(index);this._initNavButtons();}}},_doTabClose:function Sys$UI$Controls$MDIPanel$_doTabClose(sender,tabPage){if(Sys._ScriptLoader.getInstance().get_isLoading()){return;} var canClose=true;var form=tabPage._form;if(form){canClose=form.canClose();if(canClose){form._tabPage=null;form.dispose();tabPage._form=null;}} if(canClose){tabPage.remove_captionChanged(this._tabCaptionChangedHandler);sender.removeTab(tabPage);this._tabsSizeChanged();}}}
Sys.UI.Controls.MDIPanel.registerClass('Sys.UI.Controls.MDIPanel',Sys.UI.Controls._ClientPanel);Sys.UI.Controls.StatusBar=function(element){Sys.UI.Controls.StatusBar.initializeBase(this,[element]);}
Sys.UI.Controls.StatusBar.prototype={doFormInit:function(form){var mainPanel=form.__mainPanel;if(!mainPanel){throw Error.invalidOperation("没有 MDIPanel 的页面不能用 StatusBar");} mainPanel.addStatusBar(this);},doAdjustWidth:function(width){}}
Sys.UI.Controls.StatusBar.registerClass('Sys.UI.Controls.StatusBar',Sys.UI.Controls.Container);Sys.UI.Controls.LayoutDirection=function(){throw Error.notImplemented();}
Sys.UI.Controls.LayoutDirection.prototype={horz:0,vert:1}
Sys.UI.Controls.LayoutDirection.registerEnum("Sys.UI.Controls.LayoutDirection");Sys.UI.Controls._CheckBoxListChangeEventArgs=function(index,target){Sys.UI.Controls._CheckBoxListChangeEventArgs.initializeBase(this);this._index=index;this._target=target;}
Sys.UI.Controls._CheckBoxListChangeEventArgs.prototype={get_index:function(){return this._index;},get_checked:function(){return this._target.checked;},set_checked:function(value){this._target.checked=value;}}
Sys.UI.Controls._CheckBoxListChangeEventArgs.registerClass('Sys.UI.Controls._CheckBoxListChangeEventArgs',Sys.EventArgs);Sys.UI.Controls._CheckBoxList=function(element){Sys.UI.Controls._CheckBoxList.initializeBase(this,[element]);this._elementList=null;this._items=null;this._dataValueField=null;this._dataTextField=null;this._value=null;this._layoutDirection=Sys.UI.Controls.LayoutDirection.vert;this._columnSplit=1;this._hasWidth=false;this._wordWrap=true;}
Sys.UI.Controls._CheckBoxList.prototype={initialize:function(){Sys.UI.Controls._CheckBoxList.callBaseMethod(this,'initialize');if(this._items){this.doInitItems();} else{this._items=new Array();}},dispose:function(){this._clearItemList();delete this._items;Sys.UI.Controls._CheckBoxList.callBaseMethod(this,'dispose');},get_hasWidth:function(){return this._hasWidth;},set_hasWidth:function(value){this._hasWidth=value;},doCreateItems:function(){this._elementList=new Array();var elt=this.get_element();var count=this._items.length;if(this._layoutDirection==Sys.UI.Controls.LayoutDirection.vert){for(var i=0;i<count;i++){this.doAddVertItem(elt,i);}} else{var table=$common.createTable();var tbody=$common.createTBody();var columnSplit=this.get_columnSplit();if(columnSplit<=1){var tr=$common.createTr();for(var i=0;i<count;i++){var td=$common.createTd();this.doAddHorzItem(td,i);tr.appendChild(td);} tbody.appendChild(tr);} else{var width="";if(this.get_hasWidth()){table.width="100%";width=(100/columnSplit).format("n1")+"%";} var tr=null;for(var i=0;i<count;i++){var mod=i%columnSplit;if(mod==0){tr=$common.createTr();} var td=$common.createTd();td.width=width;this.doAddVertItem(td,i);tr.appendChild(td);if(mod==columnSplit-1){tbody.appendChild(tr);}} var left=count%columnSplit;if(left>0){for(var i=0;i<columnSplit-left;i++){var td=$common.createTd();tr.appendChild(td);} tbody.appendChild(tr);}} table.appendChild(tbody);elt.appendChild(table);}},doAddVertItem:function(parentElement,index){},doAddHorzItem:function(parentElement,index){},doItemClick:function(e){var list=this._elementList;var target=e.target;var index=Array.indexOf(list,target);var eventArgs=new Sys.UI.Controls._CheckBoxListChangeEventArgs(index,target);this.doChange(eventArgs);},_clearItemList:function(){if(this._elementList){var count=this.get_itemCount();for(var i=0;i<count;i++){var elt=this._elementList[i];$clearHandlers(elt);} delete this._elementList;}},get_itemCount:function(){return this._items?this._items.length:0;},get_items:function(){return this._items;},set_items:function(value){this._items=value;if(this.get_isInitialized()){this._clearItemList();if(value){this.doInitItems();}}},get_dataValueField:function(){return this._dataValueField;},set_dataValueField:function(value){this._dataValueField=value;},get_dataTextField:function(){return this._dataTextField;},set_dataTextField:function(value){this._dataTextField=value;},get_layoutDirection:function(){return this._layoutDirection;},set_layoutDirection:function(value){this._layoutDirection=value;},get_columnSplit:function(){return this._columnSplit;},set_columnSplit:function(value){this._columnSplit=value;},get_wordWrap:function(){return this._wordWrap;},set_wordWrap:function(value){this._wordWrap=value;},_getItemValue:function(index){var item=this._items[index];if(typeof(item)==="object"){return this._dataValueField?item[this._dataValueField]:index;} else{return index;}},_getItemText:function(index){var item=this._items[index];return typeof(item)==="object"?item[this._dataTextField]:item;},_checkItemIndex:function(index){var count=this.get_itemCount();if(index<0||index>=count){throw Error.invalidOperation(String.format("{0} 值索引范围应为 [0-{1}]，现在是 {2}",this.get_id(),count-1,index));}},getSelected:function(index){this._checkItemIndex(index);var list=this._elementList;if(list){return list[index].checked;}},setSelected:function(index,value){this._checkItemIndex(index);var list=this._elementList;if(list){list[index].checked=value;}},set_value:function(value){this._value=value;}}
Sys.UI.Controls._CheckBoxList.registerClass('Sys.UI.Controls._CheckBoxList',Sys.UI.Controls.CustomEdit);Sys.UI.Controls.CheckBoxList=function(element){Sys.UI.Controls.CheckBoxList.initializeBase(this,[element]);this._selectedField=null;}
Sys.UI.Controls.CheckBoxList.prototype={_addItem:function(parentElement,className,index){var div=$common.createDiv();div.className=className;if(!this.get_wordWrap()){div.style.whiteSpace="nowrap";} var checkBox=$common.createCheckBox();checkBox.style.marginBottom=Sys.Browser.isIE?"-1px":"0px";var id=this.get_id()+"_check"+index;checkBox.id=id;div.appendChild(checkBox);var lbl=document.createElement("label");lbl.innerHTML=this._getItemText(index);lbl.htmlFor=id;div.appendChild(lbl);parentElement.appendChild(div);Array.add(this._elementList,checkBox);$common.addClickHandler(checkBox,this.doItemClick,this);},doAddVertItem:function(parentElement,index){this._addItem(parentElement,"CheckBoxListVertItem",index);},doAddHorzItem:function(parentElement,index){this._addItem(parentElement,"CheckBoxListHorzItem",index);},doInitItems:function(){this.doCreateItems();this._initItemsChecked();},_initItemsChecked:function(){var count=this.get_itemCount();for(var i=0;i<count;i++){var itemValue=this._getItemValue(i);if((this._value&&Array.contains(this._value,itemValue))||(this._selectedField&&this._items[i][this._selectedField])){this._elementList[i].checked=true;}}},get_items:function(){var selectedField=this._selectedField;if(this._elementList&&selectedField){var count=this.get_itemCount();for(var i=0;i<count;i++){var item=this._items[i];if(typeof(item)==="object"){item[selectedField]=this.getSelected(i);}}} return this._items;},get_selectedField:function(){return this._selectedField;},set_selectedField:function(value){this._selectedField=value;},_doSelectAll:function(selected){var count=this.get_itemCount();for(var i=0;i<count;i++){this.setSelected(i,selected);}},selectAll:function(){this._doSelectAll(true);},deselectAll:function(){this._doSelectAll(false);},get_isAllSelected:function(){var count=this.get_itemCount();for(var i=0;i<count;i++){if(!this.getSelected(i)){return false;}} return true;},get_value:function(){var count=this.get_itemCount();var answer=new Array();for(var i=0;i<count;i++){if(this.getSelected(i)){var itemValue=this._getItemValue(i);Array.add(answer,itemValue);}} return answer;},set_value:function(value){this._value=value;if(this._elementList){this._initItemsChecked();}},get_text:function(){var count=this.get_itemCount();var answer=new Array();for(var i=0;i<count;i++){if(this.getSelected(i)){var itemText=this._getItemText(i);Array.add(answer,itemText);}} return answer;}}
Sys.UI.Controls.CheckBoxList.registerClass('Sys.UI.Controls.CheckBoxList',Sys.UI.Controls._CheckBoxList);Sys.UI.Controls.RadioButtonList=function(element){Sys.UI.Controls.RadioButtonList.initializeBase(this,[element]);this._selectedIndex=-1;}
Sys.UI.Controls.RadioButtonList.prototype={_addItem:function(parentElement,className,index){var div=$common.createDiv();div.className=className;if(!this.get_wordWrap()){div.style.whiteSpace="nowrap";} var parentId=this.get_id();var radioButton=$common.createRadioButton(parentId);radioButton.style.marginBottom=Sys.Browser.isIE?"-1px":"0px";var id=parentId+"_radio"+index;radioButton.id=id;div.appendChild(radioButton);var lbl=document.createElement("label");lbl.innerHTML=this._getItemText(index);lbl.htmlFor=id;div.appendChild(lbl);parentElement.appendChild(div);Array.add(this._elementList,radioButton);$common.addClickHandler(radioButton,this.doItemClick,this);},doAddVertItem:function(parentElement,index){this._addItem(parentElement,"RadioButtonListVertItem",index);},doAddHorzItem:function(parentElement,index){this._addItem(parentElement,"RadioButtonListHorzItem",index);},doInitItems:function(){this.doCreateItems();var count=this.get_itemCount();for(var i=0;i<count;i++){var itemValue=this._getItemValue(i);if(this._value==itemValue||this._selectedIndex==i){this._elementList[i].checked=true;break;}}},get_text:function(){var selectedIndex=this.get_selectedIndex();return selectedIndex>=0?this._getItemText(selectedIndex):null;},get_value:function(){var selectedIndex=this.get_selectedIndex();return selectedIndex>=0?this._getItemValue(selectedIndex):null;},set_value:function(value){this._value=value;if(!this._elementList)return;var selectedIndex=-1;var count=this.get_itemCount();for(var i=0;i<count;i++){var itemValue=this._getItemValue(i);if(value==itemValue){selectedIndex=i;break;}} if(count>0&&selectedIndex<0){throw Error.invalidOperation(String.format("{0} 值“{1}”为空或不在给定的范围内",this.get_idPart(),value));} this.set_selectedIndex(selectedIndex);},get_selectedIndex:function(){if(this._elementList){var count=this.get_itemCount();for(var i=0;i<count;i++){if(this.getSelected(i)){return i;}} return-1;} return this._selectedIndex;},set_selectedIndex:function(value){this._selectedIndex=value;if(this._elementList){this.setSelected(value,true);}}}
Sys.UI.Controls.RadioButtonList.registerClass('Sys.UI.Controls.RadioButtonList',Sys.UI.Controls._CheckBoxList);Sys.UI.Controls.ListBox=function(element){Sys.UI.Controls.ListBox.initializeBase(this,[element]);this._requireKeyDown=true;this._items=new Array();this._dataValueField=null;this._dataTextField=null;this._value=null;this._selectedField=null;this._multiSelect=false;this._isSelectedArray=null;this._lastActiveRow=null;this._selectedIndex=-1;this._shiftSelectedIndex=-1;this._tableElement=null;}
Sys.UI.Controls.ListBox.prototype={initialize:function(){Sys.UI.Controls.ListBox.callBaseMethod(this,'initialize');if(this._items){this._initValueBySelectedIndex();this._initItems();}},dispose:function(){this._clear();Sys.UI.Controls.ListBox.callBaseMethod(this,'dispose');},_clear:function(remove){this._lastActiveRow=null;if(this._tableElement){$clearHandlers(this._tableElement);if(remove){this.get_element().removeChild(this._tableElement);} this._tableElement=null;} delete this._rows;},_initValueBySelectedIndex:function(){var selectedIndex=this._selectedIndex;if(selectedIndex>=0){this._value=this._getItemValue(selectedIndex);}},getInputAction:function(){return"选择";},_initItems:function(){var element=this.get_element();var itemCount=this.get_itemCount();this._rows=new Array(itemCount);this._isSelectedArray=new Array(itemCount);var isScroll=itemCount*19>element.offsetHeight-4;var table=this._tableElement=$common.createPopupTable(0,2);var contentWidth=element.offsetWidth-4;if(isScroll){contentWidth-=18;} $common.setWidth(table,contentWidth);var body=$common.createTBody();for(var i=0;i<itemCount;i++){var row=$common.createTr();var td=$common.createTd();var div=$common.createDiv();div.innerHTML=$common.textToHtml(this._getItemText(i));div.unselectable="on";td.appendChild(div);row.appendChild(td);body.appendChild(row);this._rows[i]=row;} table.appendChild(body);element.tabIndex=0;element.appendChild(table);this._refreshSelected();$common.addMouseOverHandler(table,this._rowsMouseOver,this);$common.addMouseOutHandler(table,this._rowsMouseOut,this);$common.addMouseDownHandler(table,this._rowsMouseDown,this);},_refreshSelected:function(){var value=this._value;for(var i=0,count=this.get_itemCount();i<count;i++){var itemValue=this._getItemValue(i);var selected;if(this.get_multiSelect()){selected=(value&&Array.contains(this._value,itemValue))||(this._selectedField&&this._items[i][this._selectedField]);} else{selected=value==itemValue;} this._doSetSelected(i,selected);}},_findRow:function(e){var cell=e.target;if(cell.tagName!="TD"){cell=cell.parentNode;} if(cell.tagName=="TD"){return cell.parentNode;} return null;},_rowsMouseOver:function(e){var row=this._findRow(e);if(row){this._setActiveRow(row);}},_setActiveRow:function(row){if(this._lastActiveRow){this._setRowActive(this._lastActiveRow,false);} if(row){this._setRowActive(row,true);} this._lastActiveRow=row;},_indexOfRow:function(row){return Array.indexOf(this._rows,row);},_setRowActive:function(row,active){var index=this._indexOfRow(row);if(!this.getSelected(index)){row.style.backgroundColor=active?$skin.getHoverBackgroundColor():$skin.getWindowBackgroundColor();}},_rowsMouseOut:function(e){this._setActiveRow(null);},_rowsMouseDown:function(e){var row=this._findRow(e);if(row){var index=this._indexOfRow(row);var multiSelect=this.get_multiSelect();var multiMode=e.shiftKey||e.ctrlKey;if(!multiSelect||!multiMode){if(multiSelect){this._doDeselectAll();} if(this._selectedIndex>=0){this._doSetSelected(this._selectedIndex,false);} this.setSelected(index,true);} else if(e.shiftKey){if(this._shiftSelectedIndex<0){this._shiftSelectedIndex=this._selectedIndex;} this._selectTo(index);} else if(e.ctrlKey){var selected=this.getSelected(index);this.setSelected(index,!selected);}}},get_itemCount:function(){return this._items?this._items.length:0;},get_items:function(){var selectedField=this._selectedField;if(this._elementList&&selectedField){var count=this.get_itemCount();for(var i=0;i<count;i++){var item=this._items[i];if(typeof(item)==="object"){item[selectedField]=this.getSelected(i);}}} return this._items;},set_items:function(value){this._items=value;if(this.get_isInitialized()){this._clear(true);if(value){this._initItems();}}},get_dataValueField:function(){return this._dataValueField;},set_dataValueField:function(value){this._dataValueField=value;},get_dataTextField:function(){return this._dataTextField;},set_dataTextField:function(value){this._dataTextField=value;},_getItemValue:function(index){var item=this._items[index];if(typeof(item)==="object"){return this._dataValueField?item[this._dataValueField]:index;} else{return index;}},_getItemText:function(index){var item=this._items[index];return typeof(item)==="object"?item[this._dataTextField]:item;},_checkItemIndex:function(index){var count=this.get_itemCount();if(index<0||index>=count){throw Error.invalidOperation(String.format("索引范围应为 [0-{0}]",count-1));}},getSelected:function(index){this._checkItemIndex(index);var isSelectedArray=this._isSelectedArray;return isSelectedArray?isSelectedArray[index]:false;},_doSetSelected:function(index,value){this._checkItemIndex(index);this._isSelectedArray[index]=value;var row=this._rows[index];if(value){row.style.backgroundColor=$skin.getHighlightBackgroundColor();row.style.color=$skin.getHighlightTextColor();} else{row.style.backgroundColor=$skin.getWindowBackgroundColor();row.style.color=$skin.getControlTextColor();} if(value){this._selectedIndex=index;}},setSelected:function(index,value){this._doSetSelected(index,value);this.doChange();},get_selectedIndex:function(){return this._selectedIndex;},set_selectedIndex:function(value){this._selectedIndex=value;if(this.get_isInitialized()){this._initValueBySelectedIndex();this._refreshSelected();}},get_selectedField:function(){return this._selectedField;},set_selectedField:function(value){this._selectedField=value;},get_multiSelect:function(){return this._multiSelect;},set_multiSelect:function(value){this._multiSelect=value;},_doSelectAll:function(selected,changed){var count=this.get_itemCount();for(var i=0;i<count;i++){this._doSetSelected(i,selected);} if(changed){this.doChange();}},selectAll:function(){this._doSelectAll(true,true);},_doDeselectAll:function(){this._doSelectAll(false,false);},deselectAll:function(){this._doSelectAll(false,true);},get_isAllSelected:function(){var count=this.get_itemCount();for(var i=0;i<count;i++){if(!this.getSelected(i)){return false;}} return true;},get_value:function(){var count=this.get_itemCount();if(this.get_multiSelect()){var answer=new Array();for(var i=0;i<count;i++){if(this.getSelected(i)){var itemValue=this._getItemValue(i);Array.add(answer,itemValue);}} return answer;} else{for(var i=0;i<count;i++){if(this.getSelected(i)){return this._getItemValue(i);}} return null;}},set_value:function(value){this._value=value;if(this.get_isInitialized()){this._refreshSelected();}},doKeyDown:function(e){var result=false;var k=e.keyCode;var multiMode=this.get_multiSelect()&&e.shiftKey;var itemCount=this.get_itemCount();switch(k){case Sys.UI.Key.up:if(multiMode){this._incSelected(-1);} else{this._incSelectedIndex(-1);} result=true;break;case Sys.UI.Key.down:if(multiMode){this._incSelected(1);} else{this._incSelectedIndex(1);} result=true;break;case Sys.UI.Key.pageUp:if(multiMode){this._incSelected(-5);} else{this._incSelectedIndex(-5);} result=true;break;case Sys.UI.Key.pageDown:if(multiMode){this._incSelected(5);} else{this._incSelectedIndex(5);} result=true;break;case Sys.UI.Key.home:if(itemCount>0){if(multiMode){this._selectTo(0);} else{this._setSelectedIndex(0);} result=true;} break;case Sys.UI.Key.end:if(itemCount>0){if(multiMode){this._selectTo(itemCount-1);} else{this._setSelectedIndex(itemCount-1);} result=true;} break;default:var ch=String.fromCharCode(k);if((ch>='A'&&ch<='Z')||(ch>='0'&&ch<='9')){var index=this._findItemByFirstChar(ch);if(index>=0){if(multiMode){this._selectTo(index);} else{this._setSelectedIndex(index);}} result=true;} break;} if(result){e.cancel();} else{Sys.UI.Controls.ListBox.callBaseMethod(this,'doKeyDown',[e]);}},get_firstSelectedIndex:function(){for(var i=0,count=this.get_itemCount();i<count;i++){if(this.getSelected(i)){return i;}} return-1;},get_lastSelectedIndex:function(){var count=this.get_itemCount();for(var i=count-1;i>=0;i--){if(this.getSelected(i)){return i;}} return-1;},doKeyUp:function(e){if(this._shiftSelectedIndex>=0&&!e.shiftKey){this._shiftSelectedIndex=-1;} Sys.UI.Controls.ListBox.callBaseMethod(this,'doKeyUp',[e]);},_incSelected:function(inc){if(this._shiftSelectedIndex<0){this._shiftSelectedIndex=this._selectedIndex;} if(this._shiftSelectedIndex<0){this._setSelectedIndex(0);} else{this._selectTo(this._selectedIndex+inc);}},_selectTo:function(value){var itemCount=this.get_itemCount();if(itemCount==0)return;if(value<0){value=0;} else if(value>=itemCount){value=itemCount-1;} this._doDeselectAll();var selectedIndex=this._shiftSelectedIndex;var from=Math.min(selectedIndex,value);var to=Math.max(selectedIndex,value);for(var i=from;i<=to;i++){this._doSetSelected(i,true);} this.doChange();},_incSelectedIndex:function(inc){if(this._selectedIndex<0){this._setSelectedIndex(0);} else{this._setSelectedIndex(this._selectedIndex+inc);}},_setSelectedIndex:function(value){var itemCount=this.get_itemCount();if(itemCount==0)return;if(value<0){value=0;} else if(value>=itemCount){value=itemCount-1;} if(this.get_multiSelect()){this._doDeselectAll();} else if(this._selectedIndex>=0){this._doSetSelected(this._selectedIndex,false);} this.setSelected(value,true);},_findItemByFirstChar:function(ch){var items=this.get_items();var count=items.length;ch=ch.toLowerCase();for(var i=0;i<count;i++){var code=Sys.StringUtils.getFirstPinyinCode(this._getItemText(i));if(code.indexOf(ch)>=0){return i;}} return-1;}}
Sys.UI.Controls.ListBox.registerClass('Sys.UI.Controls.ListBox',Sys.UI.Controls.CustomEdit);Sys.UI.Controls.TreeViewGetNodeDisplayTextEventArgs=function(node){Sys.UI.Controls.TreeViewGetNodeDisplayTextEventArgs.initializeBase(this);this._node=node;this._text=node.get_text();}
Sys.UI.Controls.TreeViewGetNodeDisplayTextEventArgs.prototype={get_node:function(){return this._node;},get_text:function(){return this._text;},set_text:function(value){this._text=value;}}
Sys.UI.Controls.TreeViewGetNodeDisplayTextEventArgs.registerClass('Sys.UI.Controls.TreeViewGetNodeDisplayTextEventArgs',Sys.EventArgs);Sys.UI.Controls.TreeView=function(element){Sys.UI.Controls.TreeView.initializeBase(this,[element]);this._requireKeyDown=true;this._showRootNode=false;this._showCheckBoxes=false;this._icon=null;this._dataSource=null;this._skinPoperties=null;this._rootNode=new Sys.UI.Controls.TreeNode("根");this._rootNode._treeView=this;this._selectedNode=null;}
Sys.UI.Controls.TreeView.prototype={initialize:function(){Sys.UI.Controls.TreeView.callBaseMethod(this,'initialize');var skinPoperties=this._skinPoperties=$skin.getElement("tree","properties");var imageSrc=skinPoperties.imageSrc=new Object();imageSrc.minus=this._getSkinImageSrc("minus");imageSrc.minusLine=this._getSkinImageSrc("minusLine");imageSrc.plus=this._getSkinImageSrc("plus");imageSrc.plusLine=this._getSkinImageSrc("plusLine");imageSrc.none=this._getSkinImageSrc("none");imageSrc.noneLine=this._getSkinImageSrc("noneLine");skinPoperties.checkImage=this._getSkinImage("checkShape");this.get_element().tabIndex=0;if(this._dataSource)this._rootNode._bindData(this._dataSource);this._rootNode.initialize();},dispose:function(){if(this._rootNode){this._rootNode.dispose();this._rootNode=null;} Sys.UI.Controls.TreeView.callBaseMethod(this,'dispose');},_getSkinImage:function(elementName){return $skin.getImage("tree",elementName);},_getSkinImageSrc:function(elementName){return this._getSkinImage(elementName).src;},canTabOnEnter:function(){return false;},get_dataSource:function(){return this._dataSource;},set_dataSource:function(value){this._dataSource=value;},get_rootNode:function(){return this._rootNode;},get_showRootNode:function(){return this._showRootNode;},set_showRootNode:function(value){this._showRootNode=value;},get_showCheckBoxes:function(){return this._showCheckBoxes;},set_showCheckBoxes:function(value){this._showCheckBoxes=value;},get_icon:function(){return this._icon;},set_icon:function(value){this._icon=value;},get_showIcon:function(){return this._icon;},get_selectedNode:function(){return this._selectedNode;},set_selectedNode:function(value){if(this._selectedNode!=value){if(this._selectedNode)this._selectedNode.set_selected(false);this._selectedNode=value;if(value){value.set_selected(true);value.focus();} this._doSelectionChanged();}},refresh:function(dataSource){if(typeof(dataSource)!="undefined"){this.set_dataSource(dataSource);} var rootNode=this._rootNode;if(rootNode.hasChildren()){$removeNode(rootNode.getChild(0)._getParentElement());} rootNode.dispose();this._rootNode=new Sys.UI.Controls.TreeNode("root");this._rootNode._treeView=this;this._rootNode._bindData(this._dataSource);this._rootNode.initialize();},locateNode:function(propName,propValue){return this._doLocate(this.get_rootNode(),propName,propValue);},_doLocate:function(node,propName,propValue){var nodeData=node.get_data();if(nodeData&&nodeData[propName]==propValue){this.set_selectedNode(node);return node;} for(var i=0,count=node.get_count();i<count;i++){var child=node.getChild(i);var answer=this._doLocate(child,propName,propValue);if(answer!=null){return answer;}} return null;},hasSelectedNode:function(){return this._selectedNode!=null;},add_selectionChanged:function(handler){this.get_events().addHandler('selectionChanged',handler);},remove_selectionChanged:function(handler){this.get_events().removeHandler('selectionChanged',handler);},_doSelectionChanged:function(){var handler=this.get_events().getHandler('selectionChanged');if(handler){handler(this);}},add_treeNodeClick:function(handler){this.get_events().addHandler('treeNodeClick',handler);},remove_treeNodeClick:function(handler){this.get_events().removeHandler('treeNodeClick',handler);},_internalTreeNodeClick:function(){var selectedNode=this.get_selectedNode();if(!selectedNode)return;this.doTreeNodeClick(selectedNode);var handler=this.get_events().getHandler('treeNodeClick');if(handler){handler(this);}},doTreeNodeClick:function(selectedNode){},add_treeNodeDblClick:function(handler){this.get_events().addHandler('treeNodeDblClick',handler);},remove_treeNodeDblClick:function(handler){this.get_events().removeHandler('treeNodeDblClick',handler);},_internalTreeNodeDblClick:function(){var selectedNode=this.get_selectedNode();if(!selectedNode)return;this.doTreeNodeDblClick(selectedNode);var handler=this.get_events().getHandler('treeNodeDblClick');if(handler){handler(this);}},doTreeNodeDblClick:function(selectedNode){},doKeyDown:function(e){var k=e.keyCode;var result=true;switch(k){case Sys.UI.Key.left:if(this.hasSelectedNode()){var node=this.get_selectedNode();if(!node.get_expanded()){var p=node.get_parent();if(p){if(p.isRoot()&&!this.get_showRootNode())p=null;if(p)this.set_selectedNode(p);};} else{node.collapse();} result=false;} break;case Sys.UI.Key.right:if(this.hasSelectedNode()){var node=this.get_selectedNode();if(node.get_expanded()){var c=node.get_first();if(c){this.set_selectedNode(c);};} else{node.expand();} result=false;} break;case Sys.UI.Key.up:if(this.hasSelectedNode()){var node=this.get_selectedNode();var p=node.get_previousSibling();if(p){this.set_selectedNode(p);result=false;}} break;case Sys.UI.Key.down:if(this.hasSelectedNode()){var node=this.get_selectedNode();var n=node.get_nextSibling();if(n){this.set_selectedNode(n);result=false;}} break;case Sys.UI.Key.home:case Sys.UI.Key.pageUp:break;case Sys.UI.Key.end:case Sys.UI.Key.pageDown:break;case Sys.UI.Key.space:if(this.get_showCheckBoxes()&&this.hasSelectedNode()){this.get_selectedNode().toggleChecked();result=false;} break;case Sys.UI.Key.enter:this._internalTreeNodeClick();break;} if(!result)e.cancel();else Sys.UI.Controls.TreeView.callBaseMethod(this,'doKeyDown',[e]);},add_getNodeDisplayText:function(handler,handlerOwner){this.get_events().addHandler('getNodeDisplayText',handler,handlerOwner);},remove_getNodeDisplayText:function(handler){this.get_events().removeHandler('getNodeDisplayText',handler);},_internalGetNodeDisplayText:function(node){var handler=this.get_events().getHandler('getNodeDisplayText');if(handler){var eventArgs=new Sys.UI.Controls.TreeViewGetNodeDisplayTextEventArgs(node);handler(this,eventArgs);return eventArgs.get_text();} else{return node.get_text();}}}
Sys.UI.Controls.TreeView.registerClass('Sys.UI.Controls.TreeView',Sys.UI.Controls.Container);Sys.UI.Controls.TreeNode=function(value){this._treeView=null;this._parent=null;this._next=null;this._prev=null;this._value=value;this._children=new Array();this._level=0;this._nodeElement=null;this._childrenElement=null;this._expandElement=null;this._textElement=null;this._checkElement=null;this._iconElement=null;this._expanded=true;this._selected=false;this._checkState=0;}
Sys.UI.Controls.TreeNode.prototype={initialize:function(){this.doInit();},dispose:function(){if(this._expandElement){$clearHandlers(this._expandElement);this._expandElement=null;} if(this._checkElement){$clearHandlers(this._checkElement);this._checkElement=null;} if(this._iconElement){$clearHandlers(this._iconElement);this._iconElement=null;} if(this._textElement){$clearHandlers(this._textElement);this._textElement=null;} var count=this.get_count();for(var i=0;i<count;i++){var child=this.getChild(i);child.dispose();} this._childrenElement=null;this._nodeElement=null;this._children=null;},get_treeView:function(){return this._treeView;},get_parent:function(){return this._parent;},get_previousSibling:function(){if(this.isRoot())return null;var p=this.get_parent();var count=p.get_count();for(var i=0;i<count;i++){if(this==p.getChild(i))break;} if(i==0){if(p.isRoot()&&!p._treeView.get_showRootNode())return null;else return p;} else{var child=p.getChild(--i);var node=child.get_lastVisible();return node?node:child;}},get_nextSibling:function(noCheckChild){if(this.isRoot())return this.get_firstVisible();var p=this.get_parent();var count=p.get_count();for(var i=0;i<count;i++){if(this==p.getChild(i))break;} if(++i==count){if(p.isRoot()){return this.get_firstVisible();} else{return p.get_nextSibling(true);}} else{var node=noCheckChild?null:this.get_firstVisible();return node?node:p.getChild(i);}},get_value:function(){return this._value;},get_text:function(){var value=this.get_value();if(typeof(value)=="string"){return value;} else{return value._text;}},get_data:function(){var value=this.get_value();if(typeof(value)=="string"){return null;} else{return value._data;}},set_data:function(valueData){var value=this.get_value();if(typeof(value)!="string"){value._data=valueData;}},get_count:function(){return this._children.length;},getChild:function(index){return this._children[index];},get_first:function(){return this.hasChildren()?this.getChild(0):null;},get_firstVisible:function(){return this.get_expanded()?this.get_first():null;},get_last:function(){return this.hasChildren()?this.getChild(this.get_count()-1):null;},get_lastVisible:function(){return this.get_expanded()?this.get_last():null;},hasChildren:function(){return this._children.length>0;},appendChild:function(childNode){if(this.hasChildren()){var sib=this._children[this._children.length-1];sib._next=childNode;childNode._prev=sib;} this._children[this._children.length]=childNode;childNode.applyParent(this);return childNode;},isRoot:function(){return this._parent==null;},applyParent:function(parentNode){if(!parentNode){return false;} this._treeView=parentNode._treeView;this._parent=parentNode;this._level=parentNode._level+1;for(var i=0,len=this._children.length;i<len;i++){this._children[i].applyParent(this);} return true;},get_level:function(){var level=this._level;if(!this._treeView.get_showRootNode()){level--;} return level;},getAncestor:function(level){if(level>=this.get_level()||level<0){return null;} var p=this.get_parent();while(p.get_level()>level){p=p.get_parent();} return p;},_bindData:function(data){for(var i=0;i<data.length;i++){this._bindOneData(data[i]);}},_bindOneData:function(data){var node=new Sys.UI.Controls.TreeNode(data[0]);this.appendChild(node);for(var i=1;i<data.length;i++){node._bindOneData(data[i]);}},_createTd:function(){var td=$common.createTd();var skinPoperties=this._treeView._skinPoperties;var style=td.style;style.width=skinPoperties.imageWidth+"px";style.height=skinPoperties.imageHeight+"px";return td;},_addTd:function(row){var td=this._createTd();row.appendChild(td);return td;},_addImageTd:function(row,imageSrc){var td=this._createTd();if(imageSrc){td.style.background="url("+imageSrc+") 0 0 no-repeat";} row.appendChild(td);return td;},_getChildrenElement:function(){return this._childrenElement;},_getParentElement:function(){var parent=this.get_parent();if(parent)return parent._getChildrenElement();else return this.get_treeView().get_element();},_getNodeImageSrc:function(){var imageSrc=this._treeView._skinPoperties.imageSrc;var hasNext=(this._next);if(this.hasChildren()){if(this._expanded){return hasNext?imageSrc.minusLine:imageSrc.minus;} else{return hasNext?imageSrc.plusLine:imageSrc.plus;}} else{return hasNext?imageSrc.noneLine:imageSrc.none;}},doInit:function(){if(!this.isRoot()||this._treeView.get_showRootNode())this._initNode();var childrenElement=this._childrenElement=$common.createDiv();for(var i=0,count=this.get_count();i<count;i++){this.getChild(i).initialize();} this._getParentElement().appendChild(childrenElement);},_getIconSize:function(){return 16;},_initNode:function(){var nodeElement=$common.createTable();var body=$common.createTBody();var row=$common.createTr();var lineImageSrc=$skin.getImage("tree","line").src;for(var i=0,level=this.get_level();i<level;i++){this._addImageTd(row,(this.getAncestor(i)._next)?lineImageSrc:null);} this._expandElement=this._addImageTd(row,this._getNodeImageSrc());$common.addMouseDownHandler(this._expandElement,this._onExpandMouseDown,this);if(this._treeView.get_showCheckBoxes()){this._checkElement=this._addTd(row);this._initCheckElement();$common.addClickHandler(this._checkElement,this._onCheckClick,this);} if(this._treeView.get_showIcon()){var td=this._addTd(row);var div=this._iconElement=$common.createDiv();var iconSize=this._getIconSize();$common.setBounds(div,iconSize,iconSize);td.appendChild(div);this._initIconElement();$common.addClickHandler(div,this._onTextClick,this);$common.addDblClickHandler(div,this._onTextDblClick,this);} var td=$common.createTd();var textElement=this._textElement=$common.createDiv();textElement.className="TreeNodeText";textElement.tabIndex=0;this.refreshDisplayText();td.appendChild(textElement);row.appendChild(td);$common.addMouseOverHandler(textElement,this._onTextMouseOver,this);$common.addMouseOutHandler(textElement,this._onTextMouseOut,this);$common.addClickHandler(textElement,this._onTextClick,this);$common.addDblClickHandler(textElement,this._onTextDblClick,this);$common.addSelectStartHandler(textElement,this._onTextSelectStart,this);body.appendChild(row);nodeElement.appendChild(body);this._getParentElement().appendChild(nodeElement);},refreshDisplayText:function(){this._textElement.innerHTML=this._treeView._internalGetNodeDisplayText(this);},get_expanded:function(){return this._expanded;},toggleExpanded:function(){if(this.hasChildren()){if(this._expanded){this.collapse();} else{this.expand();}}},collapse:function(){if(!this._expanded)return;this._showChildren(false);this._expanded=false;this._initExpandElement();},expand:function(){if(this._expanded)return;this._expanded=true;this._initExpandElement();this._showChildren(true);},get_selected:function(){return this._selected;},set_selected:function(value){if(this._selected!=value){this._selected=value;if(this._textElement)this._initTextElement();}},focus:function(){if(this._textElement)this._textElement.focus();},_showChildren:function(visible){Sys.UI.DomElement.setVisible(this._childrenElement,visible);},_initExpandElement:function(hover){this._expandElement.style.backgroundImage="url("+this._getNodeImageSrc()+")";this._initIconElement();},_onExpandMouseOver:function(e){this._initExpandElement(true);},_onExpandMouseOut:function(e){this._initExpandElement(false);},_onExpandMouseDown:function(e){this.toggleExpanded();},_onCheckClick:function(e){this._treeView.set_selectedNode(this);this.toggleChecked();},toggleChecked:function(){if(this._checkState==0){this.check();} else{this.uncheck();}},get_checked:function(){return this._checkState>0;},check:function(){this._checkState=1;for(var i=0,count=this.get_count();i<count;i++){this.getChild(i).check();} this._initCheckElement();this._updateParentCheckState();},uncheck:function(){this._checkState=0;for(var i=0,count=this.get_count();i<count;i++){this.getChild(i).uncheck();} this._initCheckElement();this._updateParentCheckState();},_initCheckElement:function(){if(this._checkElement){var skinImage=this._treeView._skinPoperties.checkImage;var imageIndex=this._checkState;$common.setBackgroundImage(this._checkElement,skinImage,imageIndex);}},_initIconElement:function(){if(this._iconElement){var imageIndex=-1;if(this.hasChildren()){if(this._expanded){imageIndex=1;} else{imageIndex=0;}} else{imageIndex=2;} if(imageIndex>=0){var skinImage=new Object();skinImage.size=this._getIconSize();skinImage.src=this._treeView.get_icon();$common.setBackgroundImage(this._iconElement,skinImage,imageIndex);}}},_updateParentCheckState:function(){var p=this.get_parent();if(!p)return;var somethingChecked=false;var somethingNotChecked=false;for(var i=0,count=p.get_count();i<count;i++){var child=p.getChild(i);if(child.get_checked()){somethingChecked=true;if(child._checkState==2){somethingNotChecked=true;}} else{somethingNotChecked=true;}} if(somethingChecked){p._checkState=somethingNotChecked?2:1;} else{p._checkState=0;} p._initCheckElement();p._updateParentCheckState();},_onTextDblClick:function(e){if(this.hasChildren()){this.toggleExpanded();} else{this._treeView.set_selectedNode(this);this._treeView._internalTreeNodeDblClick();}},_onTextSelectStart:function(e){e.cancel();},_onTextClick:function(e){this._treeView.set_selectedNode(this);this._treeView._internalTreeNodeClick();},_initTextElement:function(hover){var style=this._textElement.style;if(hover){style.backgroundColor=$skin.getHoverBackgroundColor();style.color=$skin.getHoverTextColor();} else if(this._selected){style.backgroundColor=$skin.getHighlightBackgroundColor();style.color=$skin.getHighlightTextColor();} else{style.backgroundColor="";style.color=$skin.getControlTextColor();}},_onTextMouseOver:function(e){this._initTextElement(true);},_onTextMouseOut:function(e){this._initTextElement(false);}}
Sys.UI.Controls.TreeNode.registerClass('Sys.UI.Controls.TreeNode');Sys.UI.Controls.NavTreeView=function(element){Sys.UI.Controls.NavTreeView.initializeBase(this,[element]);this._defaultTarget="__mainPanel";}
Sys.UI.Controls.NavTreeView.prototype={doTreeNodeClick:function(selectedNode){var value=selectedNode.get_value();var target=value.target;if(!target){target=this.get_defaultTarget();} var navUrl=value.navUrl;if(target&&navUrl){if(target=="_top"){var win=window.parent?window.parent:window;win.location=navUrl;} else if(target=="_blank"){window.open(navUrl);} else{var frame=window.parent.frames[target];if(frame){frame.location=navUrl;}}}},get_defaultTarget:function(){return this._defaultTarget;},set_defaultTarget:function(value){this._defaultTarget=value;}}
Sys.UI.Controls.NavTreeView.registerClass('Sys.UI.Controls.NavTreeView',Sys.UI.Controls.TreeView);Sys.UI.Controls.CustomListBox=function(items){var element=$common.createPopupTable(1,0);Sys.UI.Controls.CustomListBox.initializeBase(this,[element]);this._items=items;this._moveItemIndex=-1;this._activeBgColor=null;}
Sys.UI.Controls.CustomListBox.prototype={initialize:function(){Sys.UI.Controls.CustomListBox.callBaseMethod(this,'initialize');this._initList();},dispose:function(){Sys.UI.Controls.CustomListBox.callBaseMethod(this,'dispose');},get_items:function(){return this._items;},set_items:function(value){this._items=value;},getItem:function(index){return this._items[index];},get_selectedItem:function(){return this.getItem(this._moveItemIndex);},get_itemCount:function(){return this.get_items().length;},get_activeBgColor:function(){return this._activeBgColor;},set_activeBgColor:function(value){this._activeBgColor=value;},_initList:function(){var table=this.get_element();var items=this.get_items();var itemCount=this.get_itemCount();var body=$common.createTBody();for(var i=0;i<itemCount;i++){var item=items[i];var tr=$common.createTr();var td=$common.createTd();td.appendChild(item.element);tr.appendChild(td);tr._isRow="true";tr._index=i;body.appendChild(tr);} table.appendChild(body);$common.addMouseOverHandler(table,this._doRowMouseOver,this);$common.addMouseDownHandler(table,this._doRowMouseDown,this);$common.addMouseUpHandler(table,this._doRowMouseUp,this);},_findRow:function Sys$UI$Controls$CustomListBox$_findRow(e){var answer=e.target;while(true){if(answer._isRow){return answer;} else if(answer!=document.body&&answer.parentNode){answer=answer.parentNode;} else{return null;}}},_doRowMouseOver:function(e){var row=this._findRow(e);if(row){this._setMoveItemIndex(row._index);}},add_selected:function(handler){this.get_events().addHandler("selected",handler);},remove_selected:function(handler){this.get_events().removeHandler("selected",handler);},_doRowMouseDown:function(e){var handler=this.get_events().getHandler("selected");if(this._moveItemIndex>=0&&handler){handler(this);} e.cancel();},_doRowMouseUp:function(e){e.cancel();},_setMoveItemIndex:function(value){if(this._moveItemIndex!=value){if(this._moveItemIndex>=0){this._setRowSelected(this._moveItemIndex,false);} this._moveItemIndex=value;this._setRowSelected(this._moveItemIndex,true);}},_setRowSelected:function(itemIndex,selected){var element=this.getItem(itemIndex).element;if(selected){element.style.backgroundColor=this._activeBgColor;} else{element.style.backgroundColor="";}}}
Sys.UI.Controls.CustomListBox.registerClass('Sys.UI.Controls.CustomListBox',Sys.UI.Controls.NoFocusContainer);Sys.UI.Controls.ToolBar=function(element){Sys.UI.Controls.ToolBar.initializeBase(this,[element]);}
Sys.UI.Controls.ToolBar.prototype={}
Sys.UI.Controls.ToolBar.registerClass('Sys.UI.Controls.ToolBar',Sys.UI.Controls.NoFocusContainer);Sys.UI.Controls.LargeToolBar=function(element){Sys.UI.Controls.LargeToolBar.initializeBase(this,[element]);}
Sys.UI.Controls.LargeToolBar.prototype={initialize:function(){Sys.UI.Controls.LargeToolBar.callBaseMethod(this,'initialize');$skin.cacheImage("toolBar","largeButtonBg");}}
Sys.UI.Controls.LargeToolBar.registerClass('Sys.UI.Controls.LargeToolBar',Sys.UI.Controls.ToolBar);Sys.UI.Controls.ToolItem=function(element){Sys.UI.Controls.ToolItem.initializeBase(this,[element]);this._requireClick=true;this._dropDownMenuId=null;this._shortcut=0;this._param=null;this._popupElement=null;this._documentClickHandler=null;this._popupElementMouseOverHandler=null;this._popupElementMouseOutHandler=null;}
Sys.UI.Controls.ToolItem.prototype={dispose:function(){this._documentClickHandler=null;if(this._popupElement){this._unhook();$removeNode(this._popupElement);this._popupElement=null;} Sys.UI.Controls.ToolItem.callBaseMethod(this,'dispose');},doFormInit:function(form){var shortcut=this.get_shortcut();if(shortcut>0){form.addShortcut(shortcut,this.focusThenClick,this);}},focusThenClick:function(){this.focus();this.click();},get_param:function(){return this._param;},set_param:function(value){this._param=value;},get_shortcut:function(){return this._shortcut;},set_shortcut:function(value){this._shortcut=value;},get_popupElement:function(){return this._popupElement;},set_popupElement:function(value){if(this._popupElement){this._unhook();} this._popupElement=value;if(!this._popupElementMouseOverHandler){this._popupElementMouseOverHandler=Function.createDelegate(this,this._popupElementMouseOver);this._popupElementMouseOutHandler=Function.createDelegate(this,this._popupElementMouseOut);} $common.addMouseOverHandler(value,this._popupElementMouseOverHandler);$common.addMouseOutHandler(value,this._popupElementMouseOutHandler);},get_droppedDown:function(){var popupElement=this._popupElement;return popupElement&&popupElement.style.visibility=="visible";},set_droppedDown:function(value){var popupElement=this._popupElement;if(!popupElement)return;if(!this._documentClickHandler){this._documentClickHandler=Function.createDelegate(this,this._documentClick);} if(value){var r=this.get_bounds();var p=$common.calcPopupPosition(r.x,r.y+r.height,popupElement.offsetWidth,popupElement.offsetHeight,r.width,r.height);popupElement.style.left=p.x+"px";popupElement.style.top=p.y+"px";popupElement.style.visibility="visible";$common.addClickHandler(window.document,this._documentClickHandler);} else{popupElement.style.visibility="hidden";$common.removeClickHandler(window.document,this._documentClickHandler);}},_unhook:function(){if(this._popupElementMouseOverHandler){var popupElement=this._popupElement;$clearHandlers(popupElement);this._popupElementMouseOverHandler=null;this._popupElementMouseOutHandler=null;}},dropDown:function(){if(!this.get_droppedDown()){this.set_droppedDown(true);}},closeUp:function(){if(this.get_droppedDown()){this.set_droppedDown(false);}},toggleDroppedDown:function(){this.set_droppedDown(!this.get_droppedDown());},get_dropDownMenuId:function(){return this._dropDownMenuId;},set_dropDownMenuId:function(value){this._dropDownMenuId=value;},doClick:function(e){Sys.UI.Controls.ToolItem.callBaseMethod(this,'doClick',[e]);var dropDownMenuId=this.get_dropDownMenuId();if(dropDownMenuId){var r=this.get_bounds();this.get_form()[dropDownMenuId].popupAt(r.x,r.y+r.height,r.width);e.stopPropagation();}},set_visible:function(value){var element=this.get_element();if(element&&Sys.UI.DomElement.getVisible(element)!=value){var td=element.previousSibling;if(td){var div=td.firstChild;if(div.className=="LargeToolSeperator"||div.className=="ToolSeperator"){Sys.UI.DomElement.setVisible(td,value);}}} Sys.UI.Controls.ToolItem.callBaseMethod(this,'set_visible',[value]);},_documentClick:function(e){this.closeUp();},_popupElementMouseOver:function(e){this.dropDown();},_popupElementMouseOut:function(e){this.closeUp();}}
Sys.UI.Controls.ToolItem.registerClass('Sys.UI.Controls.ToolItem',Sys.UI.Controls.NoFocusContainer);Sys.UI.Controls.ToolButton=function(element){Sys.UI.Controls.ToolButton.initializeBase(this,[element]);this._requireMouseOver=true;this._requireMouseOut=true;this._requireMouseDown=true;this._requireMouseUp=true;this._pushed=false;}
Sys.UI.Controls.ToolButton.prototype={get_pushed:function(){return this._pushed;},set_pushed:function(value){this._pushed=value;if(this.get_isInitialized()){this._initNormal();}},doMouseOver:function(e){this._initState(0);},doMouseOut:function(e){this._initNormal();},doMouseDown:function(e){this._initState(1);},doMouseUp:function(e){this._initState(0);},_initNormal:function(){if(!this._pushed){this.get_element().style.backgroundImage="";} else{this._initState(2);}},_initState:function(state){var skinImage=$skin.getImage("toolBar","buttonBg");$common.setBackgroundImage(this.get_element(),skinImage,state);}}
Sys.UI.Controls.ToolButton.registerClass('Sys.UI.Controls.ToolButton',Sys.UI.Controls.ToolItem);Sys.UI.Controls.ToolSpeedButton=function(element){Sys.UI.Controls.ToolSpeedButton.initializeBase(this,[element]);this._requireMouseOver=true;this._requireMouseOut=true;this._requireMouseDown=true;this._requireMouseUp=true;}
Sys.UI.Controls.ToolSpeedButton.prototype={initialize:function(){Sys.UI.Controls.ToolSpeedButton.callBaseMethod(this,'initialize');this._skinElement=$skin.getElement("menu","menuRootActive");},doMouseOver:function(e){this._setHoverOrDown(false);},doMouseOut:function(e){this._showNormal();},doMouseDown:function(e){this._setHoverOrDown(true);},doMouseUp:function(e){this._setHoverOrDown(false);},_getContent:function(){return this.get_element().firstChild;},_showNormal:function(){var elt=this._getContent();elt.style.backgroundImage="";elt.style.border="";elt.style.margin="";},_setHoverOrDown:function(isDown){var elt=this._getContent();var skinImage=$skin.getElementImage(this._skinElement);$common.setBackgroundImage(elt,skinImage,isDown?1:0,"repeat-x");elt.style.border=this._skinElement.border;elt.style.margin="0px 0px 0px 0px";}}
Sys.UI.Controls.ToolSpeedButton.registerClass('Sys.UI.Controls.ToolSpeedButton',Sys.UI.Controls.ToolItem);Sys.UI.Controls.ToolTextButton=function(element){Sys.UI.Controls.ToolTextButton.initializeBase(this,[element]);this._requireMouseOver=true;this._requireMouseOut=true;this._bgImage=null;this._hoverBgImage=null;this._text=null;this._showPage=null;}
Sys.UI.Controls.ToolTextButton.prototype={get_bgImage:function(){return this._bgImage;},set_bgImage:function(value){this._bgImage=value;},get_hoverBgImage:function(){return this._hoverBgImage;},set_hoverBgImage:function(value){this._hoverBgImage=value;},get_text:function(){return this._text;},set_text:function(value){this._text=value;},get_showPage:function(){return this._showPage;},set_showPage:function(value){this._showPage=value;},doClick:function(e){Sys.UI.Controls.ToolTextButton.callBaseMethod(this,'doClick',[e]);var showPage=this.get_showPage();if(showPage){$common.showPage(this,showPage,this.get_text());}},doMouseOver:function(e){this._initState(true);},doMouseOut:function(e){this._initState(false);},_initState:function(isHover){var bgImage=isHover?this._hoverBgImage:this._bgImage;if(bgImage){bgImage=$common.getResourceUrl(bgImage);var url="url('"+bgImage+"')";var element=this.get_element().firstChild;element.style.backgroundImage=url;}}}
Sys.UI.Controls.ToolTextButton.registerClass('Sys.UI.Controls.ToolTextButton',Sys.UI.Controls.ToolItem);Sys.UI.Controls.LargeToolButton=function(element){Sys.UI.Controls.LargeToolButton.initializeBase(this,[element]);this._requireMouseOver=true;this._requireMouseOut=true;this._requireMouseDown=true;this._requireMouseUp=true;this._pushed=false;this._text=null;this._showPage=null;}
Sys.UI.Controls.LargeToolButton.prototype={initialize:function(){Sys.UI.Controls.LargeToolButton.callBaseMethod(this,'initialize');var style=Sys.UI.DomElement._getCurrentStyle(this.get_element());this._paddingLeft=parseInt(style.paddingLeft);this._paddingRight=parseInt(style.paddingRight);this._paddingTop=parseInt(style.paddingTop);this._paddingBottom=parseInt(style.paddingBottom);},get_text:function(){return this._text;},set_text:function(value){this._text=value;},get_showPage:function(){return this._showPage;},set_showPage:function(value){this._showPage=value;},doClick:function(e){Sys.UI.Controls.LargeToolButton.callBaseMethod(this,'doClick',[e]);var showPage=this.get_showPage();if(showPage){$common.showPage(this,showPage,this.get_text());}},get_icon:function(){return this._icon;},set_icon:function(value){this._icon=value;var element=this.get_element();if(element){var img=element.firstChild;img.src=$common.getResourceUrl(value);}},doMouseOver:function(e){this._initActive(false);},doMouseOut:function(e){this._initNormal();},doMouseDown:function(e){this._initActive(true);},doMouseUp:function(e){this._initActive(false);},_initNormal:function(){var element=this.get_element();element.style.backgroundImage="";this._initPadding(element,0);Sys.UI.DomElement.removeCssClass(element,"SpeedButtonBorder");},_initPadding:function(element,offset){var style=element.style;style.paddingLeft=this._paddingLeft+offset+"px";style.paddingRight=this._paddingRight+offset+"px";style.paddingTop=this._paddingTop+offset+"px";style.paddingBottom=this._paddingBottom+offset+"px";},_initActive:function(down){var element=this.get_element();var skinImage=$skin.getImage("toolBar","largeButtonBg");$common.setBackgroundImage(this.get_element(),skinImage,down?1:0,"repeat-x");if(!down){this._initPadding(element,-1);Sys.UI.DomElement.addCssClass(element,"SpeedButtonBorder");}}}
Sys.UI.Controls.LargeToolButton.registerClass('Sys.UI.Controls.LargeToolButton',Sys.UI.Controls.ToolItem);Sys.UI.Controls.ToolImage=function(element){Sys.UI.Controls.ToolImage.initializeBase(this,[element]);this._navigateUrl=null;}
Sys.UI.Controls.ToolImage.prototype={get_navigateUrl:function(){return this._navigateUrl;},set_navigateUrl:function(value){this._navigateUrl=value;if(value||this.get_isInitialized()){this.get_element().style.cursor=value?"pointer":"";}},get_image:function(){return this._image;},set_image:function(value){this._image=value;var element=this.get_element();if(element){var img=element.firstChild;img.src=$common.getResourceUrl(value);}},doClick:function(e){Sys.UI.Controls.ToolImage.callBaseMethod(this,'doClick',[e]);var navigateUrl=this.get_navigateUrl();if(navigateUrl){window.open(navigateUrl);}}}
Sys.UI.Controls.ToolImage.registerClass('Sys.UI.Controls.ToolImage',Sys.UI.Controls.ToolItem);Sys.UI.Controls.ServerStatus=function Sys$UI$Controls$ServerStatus(element){Sys.UI.Controls.ServerStatus.initializeBase(this,[element]);this._defaultTimeout=5*60;}
Sys.UI.Controls.ServerStatus.prototype={initialize:function Sys$UI$Controls$ServerStatus$initialize(){Sys.UI.Controls.ServerStatus.callBaseMethod(this,'initialize');},dispose:function Sys$UI$Controls$ServerStatus$dispose(){if(this._timer){window.clearTimeout(this._timer);this._timer=null;} Sys.UI.Controls.ServerStatus.callBaseMethod(this,'dispose');},doFormInit:function Sys$UI$Controls$ServerStatus$doFormInit(){this._refresh(this.get_visible()?0:this._defaultTimeout);},_refresh:function(timeout){if(this._timer)return;this._timer=window.setTimeout(Function.createDelegate(this,this._getServerStatus),timeout*1000);},_getServerStatus:function(){$adminService.GetServerStatus(Function.createDelegate(this,this._doOk),Function.createDelegate(this,this._doFailed));},_doOk:function(result){this._showStatus(true,"服务器 "+result);this._refresh(this._defaultTimeout);},_doFailed:function(error){this._showStatus(false,"服务器 离线");this._refresh(5);},_showStatus:function(active,message){this._timer=null;var element=this.get_element();element.innerHTML=active?"<font face=webdings color=green>4</font>":"<font color=red>■</font>";element.title=message;}}
Sys.UI.Controls.ServerStatus.registerClass('Sys.UI.Controls.ServerStatus',Sys.UI.Control);Sys.UI.Controls.NavBar=function(element){Sys.UI.Controls.NavBar.initializeBase(this,[element]);}
Sys.UI.Controls.NavBar.prototype={initialize:function(){Sys.UI.Controls.NavBar.callBaseMethod(this,'initialize');},dispose:function(){Sys.UI.Controls.NavBar.callBaseMethod(this,'dispose');}}
Sys.UI.Controls.NavBar.registerClass('Sys.UI.Controls.NavBar',Sys.UI.Controls.NoFocusContainer);Sys.UI.Controls.NavBarGroup=function(element){Sys.UI.Controls.NavBarGroup.initializeBase(this,[element]);this._headerElement=null;this._iconElement=null;this._contentElement=null;this._expanded=true;this._groupName=null;}
Sys.UI.Controls.NavBarGroup.prototype={initialize:function(){Sys.UI.Controls.NavBarGroup.callBaseMethod(this,'initialize');var element=this.get_element();var tr=$common.getTableFirstRow(element);var td=this._headerElement=$common.getFirstChildByTagName(tr,"td");$common.addClickHandler(td,this._doHeaderClick,this);$common.addMouseOverHandler(td,this._doHeaderMouseOver,this);$common.addMouseOutHandler(td,this._doHeaderMouseOut,this);var tr=$common.getTableRow(element,1);var td=$common.getFirstChildByTagName(tr,"td");var div=$common.getFirstChildByTagName(td,"div");this._contentElement=div;this._expanded=Sys.UI.DomElement.getVisible(this._contentElement);this._iconElement=$get(this.get_id()+"_icon");},dispose:function(){if(this._headerElement){$clearHandlers(this._headerElement);this._headerElement=null;} Sys.UI.Controls.NavBarGroup.callBaseMethod(this,'dispose');},set_expanded:function(value){var groupName=this.get_groupName();if(groupName&&value){this._collapseOther(groupName);} this._iconElement.className="NBGroupHeaderImg "+(value?"NBGroupHeaderImgCollapse":"NBGroupHeaderImgExpand");var contentElement=this._contentElement;var style=contentElement.style;if(style.visibility){style.visibility="";style.position="";style.left="";style.top="";} Sys.UI.DomElement.setVisible(contentElement,value);this._expanded=value;},get_expanded:function(){return this._expanded;},get_groupName:function(){return this._groupName;},set_groupName:function(value){this._groupName=value;},_collapseOther:function(groupName){var element=this.get_element();var barElement=element.parentNode;var groupElements=barElement.childNodes;for(var i=0,count=groupElements.length;i<count;i++){var groupElement=groupElements[i];var group=groupElement.control;if(group&&group!=this&&group.get_groupName()==groupName){group.set_expanded(false);}}},_doHeaderMouseOver:function(e){this._initHeader(true);},_doHeaderMouseOut:function(e){this._initHeader(false);},_initHeader:function(active){var skinImage=$skin.getImage("navBar","headerBg");$common.setBackgroundPosition(this._headerElement,skinImage,active?1:0);},_doHeaderClick:function(e){if(this._enabled==true){this.set_expanded(!this._expanded);}}}
Sys.UI.Controls.NavBarGroup.registerClass('Sys.UI.Controls.NavBarGroup',Sys.UI.Controls.NoFocusContainer);Sys.UI.Controls.NavBarItem=function(element){Sys.UI.Controls.NavBarItem.initializeBase(this,[element]);this._requireMouseOver=true;this._requireMouseOut=true;this._requireClick=true;var td=this._tdElement=$common.getFirstChildByTagName(element,"td");var style=Sys.UI.DomElement._getCurrentStyle(td);this._paddingLeft=parseInt(style.paddingLeft);this._paddingRight=parseInt(style.paddingRight);this._paddingTop=parseInt(style.paddingTop);this._paddingBottom=parseInt(style.paddingBottom);this._param=null;}
Sys.UI.Controls.NavBarItem.prototype={doClick:function(e){Sys.UI.Controls.NavBarItem.callBaseMethod(this,'doClick',[e]);},get_param:function(){return this._param;},set_param:function(value){this._param=value;},doMouseOver:function(e){this._initElement(true);},doMouseOut:function(e){this._initElement(false);},_initElement:function(active){var style=this._tdElement.style;var offset=active?-1:0;style.paddingLeft=this._paddingLeft+offset;style.paddingRight=this._paddingRight+offset;style.paddingTop=this._paddingTop+offset;style.paddingBottom=this._paddingBottom+offset;var skinElement=$skin.getElement("navBar","itemActive");style.backgroundColor=active?skinElement.bgColor:"";style.border=active?skinElement.border:"";}}
Sys.UI.Controls.NavBarItem.registerClass('Sys.UI.Controls.NavBarItem',Sys.UI.Controls.NoFocusContainer);Sys.UI.Controls.HtmlEditor=function(element){Sys.UI.Controls.HtmlEditor.initializeBase(this,[element]);this._isIE=Sys.Browser.isIE;this._isVista=false;if(this._isIE){this._isVista=navigator.userAgent.indexOf("Windows NT 6.0")>-1;} this._html="<p></p>";this._saved=false;this._htmlMode=false;this._buttons=[];this._dropDownButtons=[];this._toggleHtmlButton=null;this._paraFormatList=null;this._fontNameList=null;this._fontSizeList=null;this._commands=null;this._autoSave=false;this._guid=null;this._resizeAllImgInterval=null;}
Sys.UI.Controls.HtmlEditor.prototype={initialize:function(){Sys.UI.Controls.HtmlEditor.callBaseMethod(this,'initialize');var id=this.get_id();this._iframeElement=$get(id+"_iframe");this._colors=$skin.getElement("htmlEditor","colors");var css=__skinBaseURI+"doc/doc.css";var html=this._html?this._html:"";var iframeHtml='<html><head>'+'<link href="'+css+'" type="text/css" rel="stylesheet" />'+'</head><body>'+html+'</body></html>';var iframeDoc=this._getIframeDoc();iframeDoc.open();iframeDoc.write(iframeHtml);iframeDoc.close();if(this._isIE){iframeDoc.body.contentEditable=true;} else{iframeDoc.designMode="on";}},doFormInit:function(){var commands=this._commands;var form=this.get_form();for(var buttonId in commands){var command=commands[buttonId];var func=eval("this._"+command);if(!func){throw Error.invalidOperation("命令没有实现："+command);} var button=form[buttonId];if(!button){throw Error.invalidOperation("命令按钮不存在："+buttonId);} button.add_click(Function.createDelegate(this,func));if(command=="toggleHtml"){this._toggleHtmlButton=button;} else{switch(command){case"insertFace":this._insertFaceButton=button;Array.add(this._dropDownButtons,button);break;case"fontColor":this._fontColorButton=button;Array.add(this._dropDownButtons,button);break;case"bgColor":this._bgColorButton=button;Array.add(this._dropDownButtons,button);break;case"imgJustify":this._imgJustifyButton=button;Array.add(this._dropDownButtons,button);break;case"paraFormat":this._paraFormatButton=button;Array.add(this._dropDownButtons,button);break;case"fontName":this._fontNameButton=button;Array.add(this._dropDownButtons,button);break;case"fontSize":this._fontSizeButton=button;Array.add(this._dropDownButtons,button);break;} Array.add(this._buttons,button);}} var iframeDoc=this._getIframeDoc();$common.addClickHandler(iframeDoc,this._doIframeClick,this);$common.addMouseDownHandler(iframeDoc,this._doIframeMouseDown,this);this._resizeAllImgInterval=window.setInterval($createDelegate(this,this._doResizeAllImg),2000);this._startAutoSaveDoc();if(this._isIE){this._getIframeBody().onpaste=$createDelegate(this,this._doContentPaste);}},dispose:function(){if(this._resizeAllImgInterval){window.clearInterval(this._resizeAllImgInterval);this._resizeAllImgInterval=null;} $clearHandlers(this._getIframeDoc());delete this._dropDownButtons;delete this._buttons;this._toggleHtmlButton=null;if(this._paraFormatList){this._paraFormatList.dispose();this._paraFormatList=null;} if(this._fontNameList){this._fontNameList.dispose();this._fontNameList=null;} if(this._fontSizeList){this._fontSizeList.dispose();this._fontSizeList=null;} Sys.UI.Controls.HtmlEditor.callBaseMethod(this,'dispose');},_getIdPrefix:function(){return this.get_id()+"_";},get_guid:function(){return this._guid;},set_guid:function(value){this._guid=value;},get_autoSave:function(){return this._autoSave;},set_autoSave:function(value){this._autoSave=value;},get_commands:function(){return this._commands;},set_commands:function(value){this._commands=value;},get_value:function(){return this._getHtml();},set_value:function(value){this._html=value;if(this.get_isInitialized()){this._setHtml(value);}},get_text:function(){return this.get_value();},set_text:function(value){this.set_value(value);},get_saved:function(){return this._saved;},set_saved:function(value){if(value){this._clearAutoSavedDoc();this._saved=true;}},canTabOnEnter:function(){return false;},_getIframeElement:function(){return this._iframeElement;},_getIframeWindow:function(){return this._iframeElement.contentWindow;},_getIframeDoc:function(){return this._iframeElement.contentWindow.document;},_getIframeBody:function(){return this._iframeElement.contentWindow.document.body;},_focusIframeWindow:function(){this._getIframeWindow().focus();},_getHtml:function(){return this._getIframeBody().innerHTML;},_setHtml:function(value){this._getIframeBody().innerHTML=value?value:"";},_getHtmlIsEmpty:function(){return this._doGetHtmlIsEmpty(this._getHtml());},_doGetHtmlIsEmpty:function(html){var html=html.toLowerCase();return html==""||html=="<div>&nbsp;</div>"||html=="<div></div>"||html=="<p>&nbsp;</p>"||html=="<p></p>";},_doExecCmd:function(cmd,param){this._getIframeDoc().execCommand(cmd,false,param);},_execCmd:function(cmd,param){var iframeWindow=this._getIframeWindow();iframeWindow.focus();this._doExecCmd(cmd,param);iframeWindow.focus();},_doInsertHtml:function(html){if(this._isIE){try{var iframeWindow=this._getIframeWindow();iframeWindow.focus();var range=iframeWindow.document.selection.createRange();range.pasteHTML(html);range.collapse(false);range.select();iframeWindow.focus();} catch(e){}} else{this._execCmd('insertHTML',html);}},_execCmdIEOnly:function(cmd,param){if(this._isIE){this._execCmd(cmd,param);} else{alert("该浏览器不支持本功能");}},_getLastUser:function(){return $common.getCookie("_HTED_User");},_setLastUser:function(value){if(value){$common.setCookie("_HTED_User",value,1000);} else{$common.removeCookie("_HTED_User");}},_getLastSaved:function(){return $common.getCookie("_HTED_Saved");},_setLastSaved:function(value){if(value){$common.setCookie("_HTED_Saved","true",1);} else{$common.removeCookie("_HTED_Saved");}},_startAutoSaveDoc:function(){if(this._autoSaveDocStarted||!this._guid||!this._autoSave)return;if(this._isIE){this._getIframeElement().addBehavior("#default#userData");var lastUser=this._getLastUser();if(lastUser&&lastUser!=this._guid){this._clearAutoSavedDoc();} setInterval(Function.createDelegate(this,this._autoSaveDoc),2000);setTimeout(Function.createDelegate(this,this._autoRestoreDoc),500);} else{this._clearAutoSavedDoc=this._autoRestoreDoc=function(){};} this._autoSaveDocStarted=true;},_autoSaveDoc:function(){var html=this._htmlMode?this._htmlElement.value:this._getHtml();if(!html||this._doGetHtmlIsEmpty(html)||html.length>5000)return;var iframe=this._getIframeElement();iframe.setAttribute("_html",html);iframe.save("_htmlStore");this._setLastUser(this._guid);this._setLastSaved(true);},_autoRestoreDoc:function(){try{if(!this._getLastSaved())return;var iframe=this._getIframeElement();iframe.load("_htmlStore");var html=iframe.getAttribute("_html");if(html!=null&&html!=""){if(confirm("您有一篇未完成的内容，是否恢复？")){if(this._htmlMode){this._htmlElement.value=html;} else{this._setHtml(html);}} this._clearAutoSavedDoc();}} catch(e){}},_clearAutoSavedDoc:function(){this._setLastSaved(false);this._setLastUser(null);var iframe=this._getIframeElement();iframe.setAttribute("_html","");iframe.save("_htmlStore");},_doResizeAllImg:function(){var iframeDoc=this._getIframeDoc();var tags=iframeDoc.getElementsByTagName("img");for(var i=0;i<tags.length;i++){var tag=tags[i];var w=tag.width;var h=tag.height;var maxWidth=500;if(w>maxWidth){tag.style.width=maxWidth+"px";tag.style.height=Math.floor(h*(maxWidth/w))+"px";}}},_doIframeMouseDown:function(e){var element=e.target;if(element.tagName.toLowerCase()=="img"){var lastImg=this._lastImg=element;lastImg._width=lastImg._tempWidth=lastImg.offsetWidth;lastImg._height=lastImg._tempHeight=lastImg.offsetHeight;this._lastImgResizeEnd=false;this._lastImgResizeHandler=$common.addResizeHandler(lastImg,this._doImgResizing,this);}},_doImgResizing:function(e){var lastImg=this._lastImg;if((lastImg._tempWidth!=lastImg.offsetWidth||lastImg._tempHeight!=lastImg.offsetHeight)&&!this._lastImgResizeEnd){window.setTimeout($createDelegate(this,this._doResizeImg),10);this._lastImgResizeEnd=true;$common.removeResizeHandler(lastImg,this._lastImgResizeHandler);this._lastImgResizeHandler=null;}},_doResizeImg:function(){var lastImg=this._lastImg;if(Math.abs(lastImg._tempWidth-lastImg.offsetWidth)>0){lastImg.style.height=Math.floor(lastImg._height*(lastImg.offsetWidth/lastImg._width))+"px";} if(Math.abs(lastImg._tempHeight-lastImg.offsetHeight)>0){lastImg.style.width=Math.floor(lastImg._width*(lastImg.offsetHeight/lastImg._height))+"px";} lastImg._tempWidth=lastImg.offsetWidth;lastImg._tempHeight=lastImg.offsetHeight;},_doContentPaste:function(e){var doClearFromWord=function(html){html=html.replace(/<\/?SPAN[^>]*>/gi,"");html=html.replace(/<(\w[^>]*)\sclass=([^\s|>]*)([^>]*)/gi,"<$1$3");html=html.replace(/<(\w[^>]*)\slang=([^\s|>]*)([^>]*)/gi,"<$1$3");html=html.replace(/<\\?\?xml[^>]*>/gi,"");html=html.replace(/<\/?\w+:[^>]*>/gi,"");html=html.replace(/<img+\s[^>]*>/gi,"");return html;};var _this=this;var doPasteData=function(){var cif=_this._cacheIframe;if(!cif){cif=_this._cacheIframe=document.createElement("iframe");cif.style.visibility="hidden";cif.style.position="absolute";document.body.appendChild(cif);} var doc=cif.contentWindow.document;doc.open();doc.write("");doc.close();doc.body.createTextRange().execCommand("Paste");var html=doc.body.innerHTML;if(html.indexOf("&nbsp;")==0){html=html.replace(/\&nbsp;/i,"");} doc.body.innerHTML="";return html;};var pasteData=doPasteData();if(pasteData&&pasteData.length>0){var wordPattern=/<\w[^>]*\sclass="?MsoNormal"?/gi;if(wordPattern.test(pasteData)){if(confirm("文章有多余代码，可能影响顺利发表，是否确认清除？\r\n\r\n提示：您的文字将完整保留。")){pasteData=doClearFromWord(pasteData);} else{pasteData=pasteData.replace(/<img+\s[^>]*>/gi,"");pasteData=pasteData.replace(/<\/?\w+:imagedata[^>]*>/gi,"");pasteData=pasteData.replace(/<\/?\w+:shape[^>]*>/gi,"");}} var range=this._getIframeDoc().selection.createRange();range.pasteHTML(pasteData);} return false;},_bold:function(){this._execCmd("bold");},_italic:function(){this._execCmd("italic");},_underline:function(){this._execCmd("underline");},_undo:function(){this._execCmdIEOnly("undo");},_redo:function(){this._execCmdIEOnly("redo");},_cut:function(){this._execCmdIEOnly("cut");},_copy:function(){this._execCmdIEOnly("copy");},_paste:function(){this._execCmdIEOnly("paste");},_justifyLeft:function(){this._execCmd("justifyleft");},_justifyCenter:function(){this._execCmd("justifycenter");},_justifyRight:function(){this._execCmd("justifyright");},_justifyFull:function(){this._execCmd("justifyfull");},_outdent:function(){this._execCmd("outdent");},_indent:function(){this._execCmd("indent");},_orderedList:function(){this._execCmd("insertorderedlist");},_unorderedList:function(){this._execCmd("insertunorderedlist");},_doSetFont:function(what,value){if(this._isIE){if(value=="楷体"&&!this._isVista){value="楷体_GB2312";} this._doExecCmd("fontname","__TempFontName");var iframeDoc=this._getIframeDoc();if(!iframeDoc.body._lastFont){iframeDoc.body._lastFont=new Object();} if(iframeDoc.selection.type!="Text"){iframeDoc.body._lastFont[what]=value;if(!iframeDoc.body.onkeyup){iframeDoc.body.onkeyup=Function.createDelegate(this,this._doIframeBodyKeyUp);}} else{this._replaceFontName(what,value);}} else{switch(what){case"fontname":this._doExecCmd("fontname",value);break;case"fontsize":value=parseInt(value)/6;this._doExecCmd("fontsize",value);break;default:break;}}},_doIframeBodyKeyUp:function(e){var lf=this._getIframeBody()._lastFont;if(lf.fontname){this._replaceFontName("fontname",lf.fontname);}},_replaceFontName:function(what,value){var iframeDoc=this._getIframeDoc();var lf=iframeDoc.body._lastFont;var fontTags=iframeDoc.body.getElementsByTagName("font");for(var i=0;i<fontTags.length;i++){var fontTag=fontTags[i];if(fontTag.getAttribute("face")=="__TempFontName"){this._removeInnerFont(fontTag,what);this._setFontStyleValue(fontTag,what,value);lf[what]=null;if(!lf.fontsize&&!lf.fontname){fontTag.removeAttribute("face");}}}},_removeInnerFont:function(obj,what){var children=obj.children;for(var j=0;j<children.length;j++){this._setFontStyleValue(children[j],what,"");this._removeInnerFont(children[j],what);if(children[j].style.cssText==""){if((children[j].tagName=="FONT")||(children[j].tagName=="SPAN")){children[j].outerHTML=children[j].innerHTML;}}}},_setFontStyleValue:function(element,what,value){switch(what){case"fontname":element.style.fontFamily=value;break;case"fontsize":element.style.fontSize=value;break;default:break;}},_doParaFormat:function(type){this._execCmd("formatblock","<"+type+">");},_insertHr:function(){this._execCmd("inserthorizontalrule");},_doInsertImg:function(src){this._execCmd("insertimage",src);},_doInsertLink:function(href,text){var html="<a href='"+href+"' target='_blank'>"+text+"</a>";this._doInsertHtml(html);},_doInsertTable:function(rowCount,columnCount,percentWidth,width,border,cellSpacing,cellPadding){var widthUnit=percentWidth?"%":"";var html='<table width="'+width+widthUnit+'" border="'+border+'" cellspacing="'+cellSpacing+'" cellpadding="'+cellPadding+'">\n';for(var row=0;row<rowCount;row++){html+="<tr>\n";for(var col=0;col<columnCount;col++){html+="<td>&nbsp;</td>\n";} html+="</tr>\n";} html+="</table>\n";this._doInsertHtml(html);},_getSelectionRange:function(){var iframeWindow=this._getIframeWindow();var range={};if(this._isIE){var selection=iframeWindow.document.selection;if(selection){range=selection.createRange();}} else{var selection=iframeWindow.getSelection();range=selection.getRangeAt(selection.rangeCount-1).cloneRange();range.text=range.toString();} return range;},_insertTextArea:function(){var range=this._getSelectionRange();var text=range.text||"请在文本框中输入文字";var html="<table style='border:1px solid #999;width:80%;font-size:12px;' align='center'><tr><td>"+text+"</td></tr></table>";this._doInsertHtml(html);},_insertSearch:function(){var range=this._getSelectionRange();var text=range.text;if(!text){alert("请选择一段文字后操作！");} else{this._doInsertLink("http://www.baidu.com/s?cl=3&wd="+text,text);}},_getSelectionElement:function(){var element=null;var selection;var range;if(this._isIE){selection=this._getIframeDoc().selection;switch(selection.type.toLowerCase()){case"none":case"text":range=selection.createRange();element=range.parentElement();break;case"control":var ranges=selection.createRange();element=ranges.item(0);break;}} else{selection=this._getIframeWindow().getSelection();if(selection.rangeCount>0){range=selection.getRangeAt(0);if(range.startContainer==range.endContainer){if(range.startContainer.nodeType!=3){element=range.startContainer.childNodes[range.startOffset];} else{element=range.startContainer;}} else{element=range.commonAncestorContainer;}} if(element&&element.nodeType==3){element=element.parentNode;}} return element;},_doImgJustify:function(justify){var element=this._getSelectionElement();if(element.tagName.toLowerCase()=="img"){var style=element.style;switch(justify){case"left":style.margin="4px";$common.setStyleFloat(element,"left");style.display="";style.textAlign="";break;case"center":style.margin="4px auto";style.display="block";$common.setStyleFloat(element,"");style.textAlign="center";element.setAttribute("align","");break;case"right":style.margin="4px";$common.setStyleFloat(element,"right");style.display="";style.textAlign="";break;}} else{alert("请选中图片后操作！");}},_togglePara:function(){var body=this._getIframeBody();var childNodes=body.childNodes;for(var i=0,count=childNodes.length;i<count;i++){var childNode=childNodes[i];if(childNode.tagName){childNode.innerHTML=childNode.innerHTML.split('&nbsp;').join('№');childNode.innerHTML=childNode.innerHTML.replace(/(^[\s|　|№]*)|([\s|　|№]*$)/g,"");childNode.innerHTML=childNode.innerHTML.split('№').join('&nbsp;');if(!childNode.style.textIndent){childNode.style.textIndent='2em';} else{childNode.style.textIndent='';}} else{body.innerHTML='<div style="text-indent:2em;">'+body.innerHTML.replace(/(^[\s|　]*)|([\s|　]*$)/g,"");+'</div>';}}},_checkEditor:function(){if(this._getHtmlIsEmpty()){alert("请先输入内容");return false;} else{return true;}},_preview:function(){if(this._checkEditor()){var html=this._getHtml();var win=window.open('',"_blank",'');win.document.open('text/html','replace');win.opener=null;win.document.writeln(html);win.document.close();}},_toggleHtml:function(){var htmlMode=!this._htmlMode;this._htmlMode=htmlMode;if(this._toggleHtmlButton){this._toggleHtmlButton.set_pushed(htmlMode);this._toggleHtmlButton.set_hint(htmlMode?"隐藏源代码":"显示源代码");} var buttons=this._buttons;var buttonsEnabled=!htmlMode;for(var i=0;i<buttons.length;i++){var button=buttons[i];button.set_enabled(buttonsEnabled);} var iframeElement=this._getIframeElement();var htmlElement=this._htmlElement;if(htmlMode){if(!htmlElement){htmlElement=this._htmlElement=document.createElement("textarea");htmlElement.className="HtmlEditorHtml";var r=Sys.UI.DomElement.getBounds(iframeElement);$common.setPosition(htmlElement,r.x,r.y,r.width,r.height);this.get_element().appendChild(htmlElement);} else{Sys.UI.DomElement.setVisible(htmlElement,true);} htmlElement.value=this._getHtml();htmlElement.focus();} else{if(htmlElement){Sys.UI.DomElement.setVisible(htmlElement,false);this._setHtml(htmlElement.value);} this._focusIframeWindow();}},_insertFace:function(sender,e){if(!this._faceTableElement){this._faceTableElement=this._createFaceTable();this._insertFaceButton.set_popupElement(this._faceTableElement);} this._toggleDroppedDown(this._insertFaceButton);e.cancel();},_createFaceTable:function(){var popup=$common.createDiv();$common.initPopupElement(popup,true);var areas={"040":"246,83,272,107","039":"219,83,245,107","038":"192,83,218,107","037":"165,83,191,107","036":"138,83,164,107","035":"111,83,137,107","034":"84,83,110,107","033":"57,83,83,107","032":"30,83,56,107","031":"3,83,29,107","030":"246,56,272,80","029":"219,56,245,80","028":"192,56,218,80","027":"165,56,191,80","026":"138,56,164,80","025":"111,56,137,80","024":"84,56,110,80","023":"57,56,83,80","022":"30,56,56,80","021":"3,56,29,80","020":"246,30,272,54","019":"219,30,245,54","018":"192,30,218,54","017":"165,30,191,54","016":"138,30,164,54","015":"111,30,137,54","014":"84,30,110,54","013":"57,30,83,54","012":"30,30,56,54","011":"3,30,29,54","010":"246,4,272,28","009":"219,4,245,28","008":"192,4,218,28","007":"165,4,191,28","006":"138,4,164,28","005":"111,4,137,28","004":"84,4,110,28","003":"57,4,83,28","002":"30,4,56,28","001":"3,4,29,28"};this._createImgWithAreas(popup,"faceTable",areas,this._doFaceItemClick);document.body.appendChild(popup);return popup;},_createImgWithAreas:function(popup,imageName,areas,onAreaClick){var mapId=this.get_id()+"_"+imageName+"Map";var img=document.createElement("img");img.border=0;img.style.cursor="pointer";img.src=__skinBaseURI+"ui/htmlEditor/editor/"+imageName+".gif";img.useMap="#"+mapId;popup.appendChild(img);var map=document.createElement("map");map.id=mapId;for(var name in areas){var area=document.createElement("area");area.shape="rect";area.coords=areas[name];area.param=name;$common.addClickHandler(area,onAreaClick,this);map.appendChild(area);} popup.appendChild(map);return img;},_doFaceItemClick:function(e){var faceNum=e.target.param;var faceUrl=__skinBaseURI+"ui/htmlEditor/face/"+faceNum+".gif";this._doInsertImg(faceUrl);},_imgJustify:function(sender,e){if(!this._imgJustifyTableElement){this._imgJustifyTableElement=this._createImgJustifyTable();this._imgJustifyButton.set_popupElement(this._imgJustifyTableElement);} this._toggleDroppedDown(this._imgJustifyButton);e.cancel();},_createImgJustifyTable:function(){var popup=$common.createDiv();popup.style.backgroundColor=$skin.getControlBackgroundColor();$common.initPopupElement(popup,true,true);var areas={"left":"0,  0, 63,60","center":"63, 0,126,60","right":"126,0,189,60"};this._createImgWithAreas(popup,"imgJustifyTable",areas,this._doImgJustifyClick);document.body.appendChild(popup);return popup;},_doImgJustifyClick:function(e){var justify=e.target.param;this._doImgJustify(justify);},_fontColor:function(sender,e){if(!this._fontColorTableElement){this._fontColorTableElement=this._createColorTable(this._doFontColorItemClick);this._fontColorButton.set_popupElement(this._fontColorTableElement);} this._toggleDroppedDown(this._fontColorButton);e.cancel();},_bgColor:function(sender,e){if(!this._bgColorTableElement){this._bgColorTableElement=this._createColorTable(this._doBgColorItemClick);this._bgColorButton.set_popupElement(this._bgColorTableElement);} this._toggleDroppedDown(this._bgColorButton);e.cancel();},_createColorTable:function(onColorItemClick){var popup=$common.createTable(1,0);$common.initPopupElement(popup,true,true);var tbody=$common.createTBody();var colors=["#FF9999","#FFFF80","#80FF80","#80FFFF","#0080FF","#FF80C0","#FF0000","#CCCC66","#00FF40","#0099CC","#9999CC","#FF00FF","#CC3333","#FF9933","#009999","#006699","#9999FF","#990033","#990000","#FF9900","#009900","#0000FF","#0000CC","#990099","#660000","#006666","#999900","#660099","#339999","#66CCCC","#000000","#494949","#767676","#A6A6A6","#C7C7C7","#FFFFFF"];for(var i=0,k=0;i<6;i++){var tr=$common.createTr();for(var j=0;j<6;j++){var td=$common.createTd();var item=$common.createGlyphDiv();$common.setBounds(item,14,14);this._initItem(item);var style=item.style;var color=colors[k];style.backgroundColor=color;item.param=color;$common.addClickHandler(item,onColorItemClick,this);td.appendChild(item);tr.appendChild(td);k++;} tbody.appendChild(tr);} popup.appendChild(tbody);document.body.appendChild(popup);return popup;},_doFontColorItemClick:function(e){var color=e.target.param;this._execCmd("forecolor",color);},_doBgColorItemClick:function(e){var color=e.target.param;this._execCmd(this._isIE?"backcolor":"hilitecolor",color);},_initItem:function(element){element.style.border="1px solid "+this._colors.itemBorder;element.style.cursor="pointer";},_createList:function(items,onSelected){var list=new Sys.UI.Controls.CustomListBox(items);list.set_activeBgColor(this._colors.itemActiveBg);list.initialize();list.add_selected(Function.createDelegate(this,onSelected));return list;},_paraFormat:function(sender,e){if(!this._paraFormatList){this._paraFormatList=this._createParaFormatList();var popup=this._paraFormatList.get_element();$common.initPopupElement(popup,true,true);document.body.appendChild(popup);this._paraFormatButton.set_popupElement(popup);} this._toggleDroppedDown(this._paraFormatButton);e.cancel();},_createListElement:function(){var div=$common.createGlyphDiv();this._initItem(div);div.style.textAlign="center";return div;},_createParaFormatList:function(){var records=[{p:"P",t:"取消段落",s:"14"},{p:"H1",t:"段落1",s:"32"},{p:"H2",t:"段落2",s:"24"},{p:"H3",t:"段落3",s:"18"},{p:"H4",t:"段落4",s:"16"},{p:"H5",t:"段落5",s:"12"},{p:"H6",t:"段落6",s:"10"}];var count=records.length;var items=new Array(count);for(var i=0;i<count;i++){var record=records[i];var item=new Object();item.param=record.p;var div=this._createListElement();var style=div.style;style.fontSize=record.s;style.lineHeight="1.0";style.padding="5px 2px 2px 2px";div.innerHTML=record.t;item.element=div;items[i]=item;} return this._createList(items,this._doParaFormatClick);},_doParaFormatClick:function(sender){var item=sender.get_selectedItem();this._doParaFormat(item.param);},_fontName:function(sender,e){if(!this._fontNameList){this._fontNameList=this._createFontNameList();var popup=this._fontNameList.get_element();$common.initPopupElement(popup,true,true);document.body.appendChild(popup);this._fontNameButton.set_popupElement(popup);} this._toggleDroppedDown(this._fontNameButton);e.cancel();},_createFontNameList:function(){var records=["宋体","黑体","隶书","楷体","幼圆","Arial","Impact","Georgia","Verdana","Courier New","Times New Roman"];var count=records.length;var items=new Array(count);for(var i=0;i<count;i++){var record=records[i];var item=new Object();item.param=record;var div=this._createListElement();var style=div.style;style.fontFamily=record;style.padding="3px 2px 2px 2px";div.innerHTML=record;item.element=div;items[i]=item;} return this._createList(items,this._doFontNameClick);},_doFontNameClick:function(sender){var item=sender.get_selectedItem();this._doSetFont("fontname",item.param);},_fontSize:function(sender,e){if(!this._fontSizeList){this._fontSizeList=this._createFontSizeList();var popup=this._fontSizeList.get_element();$common.initPopupElement(popup,true,true);document.body.appendChild(popup);this._fontSizeButton.set_popupElement(popup);} this._toggleDroppedDown(this._fontSizeButton);e.cancel();},_createFontSizeList:function(){var records=[{p:"10px",t:"(六号)"},{p:"12px",t:"(小五)"},{p:"14px",t:"(五号)"},{p:"16px",t:"(小四)"},{p:"18px",t:""},{p:"20px",t:"(小三)"},{p:"22px",t:""},{p:"24px",t:"(小二)"},{p:"32px",t:"(小一)"},{p:"56px",t:"(初号)"}];var count=records.length;var items=new Array(count);for(var i=0;i<count;i++){var record=records[i];var item=new Object();item.param=record.p;var div=this._createListElement();var style=div.style;style.fontSize=record.p;style.lineHeight="1.0";style.padding="5px 2px 2px 2px";div.innerHTML=record.p+"<span style='font-size:12px'>"+record.t+"</span>";item.element=div;items[i]=item;} return this._createList(items,this._doFontSizeClick);},_doFontSizeClick:function(sender){var item=sender.get_selectedItem();this._doSetFont("fontsize",item.param);},_showDialog:function(url,width,height,onOk,onLoaded){var form=new Sys.UI.Form(null,width,height);var url=$common.getSysUIBaseURI()+"HtmlEditor/"+url;if(onLoaded){form.add_loaded(onLoaded);} if(onOk){form.add_ok(onOk);} var _this=this;var range=this._getSelectionRange();form.add_close(function(){_this._focusIframeWindow();range.select();});form.showModal(url);},_insertImg:function(sender,e){var _this=this;var range=this._getSelectionRange();this._showDialog("InsertImg.gspx",450,150,null,function(form){var btnLink=form.btnLink;btnLink.add_click(function(sender){var imageSrc=form.edImgSrc.get_text();form.close();if(imageSrc&&imageSrc.toLowerCase()!="http://"){_this._doInsertImg(imageSrc);} else{_this._focusIframeWindow();range.select();}});var btnUpload=form.btnUpload;btnUpload.add_click(function(sender){var doFileUploadSucceeded=function(sender,result){form.close();_this._doInsertImg(result);};if(form.File1.get_text()){Sys.UI.Controls.FileUpload.submit(sender,doFileUploadSucceeded);} else{form.close();_this._focusIframeWindow();range.select();}});});},_insertLink:function(sender,e){var _this=this;var link=new Object();var range=this._getSelectionRange();link.Text=range.text;var element=this._getSelectionElement();if(element.tagName.toLowerCase()=="a"){link.Href=element.href;} this._showDialog("InsertLink.gspx",300,150,function(form){var link=form.saveData();var href=link.Href;if(href&&href.toLowerCase()!="http://"){if(!link.Text){link.Text=href;} range.text="";_this._doInsertLink(href,link.Text);} else{_this._focusIframeWindow();range.select();}},function(form){form.dataBind(link);});},_insertTable:function(sender,e){var _this=this;this._showDialog("InsertTable.gspx",400,180,function(form){var params=form.saveData();_this._doInsertTable(params.RowCount,params.ColumnCount,params.PercentWidth,params.Width,params.Border,params.CellSpacing,params.CellPadding);});},_insertSwf:function(sender,e){},_toggleDroppedDown:function(button){this._closeUpDropDowns(button);button.toggleDroppedDown();},_closeUpDropDowns:function(except){var dropDownButtons=this._dropDownButtons;if(dropDownButtons){for(var i=0;i<dropDownButtons.length;i++){var button=dropDownButtons[i];if(!except||button!=except){button.closeUp();}}}},_doIframeClick:function(e){this._closeUpDropDowns();}}
Sys.UI.Controls.HtmlEditor.registerClass('Sys.UI.Controls.HtmlEditor',Sys.UI.Controls.CustomEdit);Sys.UI.Controls.CPrintWriteData=function(element){Sys.UI.Controls.CPrintWriteData.initializeBase(this,[element]);}
Sys.UI.Controls.CPrintWriteData.prototype={doFormInit:function(){var writeData=window.__CPrintWriteData;if(writeData)return;writeData=window.__CPrintWriteData=document.createElement("<object name='CPrintWriteData' classid='clsid:340fc08c-5fbf-4f52-9cd7-e50a446a1484' width=0 height=0></object>");$common.setDisplay(writeData,false);document.body.appendChild(writeData);var vbscript="function toVBArray(arr)\n"+"  dim answer()\n"+"  redim answer(arr.length - 1)\n"+"  dim i, value\n"+"  i = 0\n"+"  for each value in arr\n"+"    answer(i) = value\n"+"    i = i + 1\n"+"  next\n"+"  toVBArray = answer\n"+"end function\n"+"\n"+"sub WriteDetailData(colTitles, colWidths, rowData)\n"+"    dim re\n"+"    re = CPrintWriteData.WriteColOption(toVBArray(colWidths), toVBArray(colTitles))\n"+"    re = CPrintWriteData.WriteRowData(toVBArray(rowData))\n"+"end sub";execScript(vbscript,"vbscript");}}
Sys.UI.Controls.CPrintWriteData.registerClass('Sys.UI.Controls.CPrintWriteData',Sys.UI.Control);Sys.UI.Controls.BarcodePrint=function(element){Sys.UI.Controls.BarcodePrint.initializeBase(this,[element]);}
Sys.UI.Controls.BarcodePrint.prototype={config:function(barCodes){if(barCodes){this._writeData(barCodes);} try{this.get_element().BarConfigCds("table_m.cds");} catch(e){this._handleError(e);}},_handleError:function(e){throw Error.abort("不能使用条码。请检查打印管理器是否正确安装");},_writeData:function(barCodes){var colTitles=["条码"];var colWidths=["20"];this.writeData(colTitles,colWidths,barCodes);},writeData:function(colTitles,colWidths,rowData){try{WriteDetailData(colTitles,colWidths,rowData);} catch(e){this._handleError(e);}},print:function(barCodes,copies){if(typeof(barCodes)=="number"){copies=barCodes;barCodes=null;} if(barCodes){this._writeData(barCodes);} try{this.get_element().PrintBarOutEx(copies?copies:1);} catch(e){this._handleError(e);}}}
Sys.UI.Controls.BarcodePrint.registerClass('Sys.UI.Controls.BarcodePrint',Sys.UI.Control);Sys.UI.Controls.PosPrint=function(element){Sys.UI.Controls.PosPrint.initializeBase(this,[element]);}
Sys.UI.Controls.PosPrint.prototype={_getOcx:function(){if(!this.get_element()){alert("正在初始化，点确定继续");} return this.get_element();},_handleError:function(e,showError){if(showError){alert("不能使用POS。请检查打印管理器是否正确安装");}},config:function(){var ocx=this._getOcx();try{ocx.ShowPosCfg();} catch(e){this._handleError(e,true);}},hideConfigPage:function(pageIndex){var ocx=this._getOcx();try{ocx.HidePosCfgPage(pageIndex);} catch(e){this._handleError(e);}},openCashBox:function(){var ocx=this._getOcx();try{ocx.PosOpenCashBox();} catch(e){this._handleError(e);}},screenOut:function(type,money){var ocx=this._getOcx();try{ocx.PosScreenOut(type,money!=null?money.toString():"");} catch(e){this._handleError(e);}}}
Sys.UI.Controls.PosPrint.registerClass('Sys.UI.Controls.PosPrint',Sys.UI.Control);Sys.UI.Controls.Chart=function(element){Sys.UI.Controls.Chart.initializeBase(this,[element]);this._zoomFactor=1.0;}
Sys.UI.Controls.Chart.prototype={get_mode:function(){return this._mode;},set_mode:function(value){this._mode=value;if(this.get_isInitialized()){this.refresh();}},print:function(){this.get_form().printElement(this.get_element());},refresh:function(params){var element=this.get_element();var url=$common.getSysUIBaseURI()+"Chart/Image.gspx?ID="+element.id+"&Mode="+this._mode+"&IsValueVisible="+this._isValueVisible+"&ZoomFactor="+this._zoomFactor;url=$common.encodeUrlParams(url,params);element.src=url;},get_isValueVisible:function(){return this._isValueVisible;},set_isValueVisible:function(value){this._isValueVisible=value;if(this.get_isInitialized()){this.refresh();}},get_zoomFactor:function(){return this._zoomFactor;},set_zoomFactor:function(value){this._zoomFactor=value;if(this.get_isInitialized()){var style=this.get_element().style;if(style.width){style.width="";style.height="";} this.refresh();}}}
Sys.UI.Controls.Chart.registerClass('Sys.UI.Controls.Chart',Sys.UI.Control);Sys.UI.Controls.FlashChart=function(element){Sys.UI.Controls.FlashChart.initializeBase(this,[element]);this._title=null;this._showPieLabel=true;this._zoomFactor=1.0;}
Sys.UI.Controls.FlashChart.prototype={initialize:function(){Sys.UI.Controls.FlashChart.callBaseMethod(this,'initialize');var title=document.title;var pos=title.indexOf('#');if(pos>0){title=title.substr(0,pos);document.title=title;} this._documentTitle=title;var element=this.get_element();this._width=element.offsetWidth;this._height=element.offsetHeight;},dispose:function(){var element=this.get_element();var flash=element.firstChild;if(flash){var savedOnError=window.onerror;try{window.onerror=function(e){return true;};$removeNode(flash);} finally{window.onerror=savedOnError;}} if(document.title!=this._documentTitle){document.title=this._documentTitle;} Sys.UI.Controls.FlashChart.callBaseMethod(this,'dispose');},get_title:function(){return this._title;},set_title:function(value){this._title=value;},get_mode:function(){return this._mode;},set_mode:function(value){this._mode=value;if(this.get_isInitialized()){this.refresh();}},get_barStyle:function(){return this._barStyle;},set_barStyle:function(value){this._barStyle=value;if(this.get_isInitialized()){this.refresh();}},refresh:function(params){var url=$common.getSysUIBaseURI()+"Chart/Data.gspx?ID="+this.get_id()+"&Mode="+this._mode+"&BarStyle="+this._barStyle+"&ShowPieLabel="+this._showPieLabel;url=$common.encodeUrlParams(url,params);var flash=this._getFlash();flash.reload(url);},_getFlash:function(){var element=this.get_element();var flash=element.firstChild;if(!flash){alert("正在初始化，点确定继续");flash=element.firstChild;} if(typeof(flash.reload)!="function"){throw Error.abort("FlashChart在局域网中使用时要刷新请先在Web.config中的“appSettings”中加\n"+"<add key=\"FlashChart.DisableCodeBase\" value=\"true\" />\n\n（当前模式为 "+flash.tagName+")");} return flash;},postImage:function(){var url=$common.getSysUIBaseURI()+"Chart/ToImage.gspx";var title=this.get_title()||this.get_form().get_caption();url=$common.addUrlParam(url,"Title",title);var flash=this._getFlash();flash.post_image(url,null,true);},_dumpFunctions:function(){var flash=this._getFlash();for(var name in flash){var value=flash[name];if(typeof(value)=="function"){$debug.traceDump(name+" "+value);}}},get_version:function(){var flash=this._getFlash();return flash.get_version();},get_showPieLabel:function(){return this._showPieLabel;},set_showPieLabel:function(value){this._showPieLabel=value;if(this.get_isInitialized()){this.refresh();}},get_zoomFactor:function(){return this._zoomFactor;},set_zoomFactor:function(value){this._zoomFactor=value;if(this.get_isInitialized()){var element=this.get_element();var width=this._width*value;var height=this._height*value;$common.setBounds(element,width,height);}}}
Sys.UI.Controls.FlashChart.registerClass('Sys.UI.Controls.FlashChart',Sys.UI.Control);Sys.UI.Controls.Scheduler=function(element){Sys.UI.Controls.Scheduler.initializeBase(this,[element]);this._days=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");this._cellPadding="2";this._cellSpacing="5";this._borderSize=1;this._scheduleMargin=10;this._headerHeight=30;}
Sys.UI.Controls.Scheduler.prototype={dispose:function(){this._clearObjects();Sys.UI.Controls.Scheduler.callBaseMethod(this,'dispose');delete this._days;this._days=null;this._floatHint=null;},doFormInit:function(){var f=$common.createDiv();f.style.position="absolute";f.style.visibility='hidden';f.className="FloatHint";document.body.appendChild(f);this._floatHintDiv=f;var element=this.get_element();var table=$common.createTable(1);this._body=$common.createTBody();var realWidth=this._width-this._scheduleMargin;this._panelMarginSize=new Number(this._cellSpacing)+new Number(this._cellPadding);this._dayTextWidth=realWidth-(this._panelMarginSize+this._borderSize)*2;this._dayElseTextWidth=(realWidth-this._panelMarginSize*14-this._borderSize*8)/7;this._createSchedules(this._body);table.width=realWidth;if(this._height){table.height=this._height-this._scheduleMargin;} table.className="SchedulerTabel";table.appendChild(this._body);element.appendChild(table);},_clearObjects:function(){this._selectedLabel=null;this._selectedPanel=null;delete this._panels;this._panels=null;},updateSchedule:function(schedule){Carpa.Web.Script.UI.SchedulerController._staticInstance.UpdateSchedule(this.get_element().id,schedule,Function.createDelegate(this,function(result){if(result!=null){for(i=0;i<this._dataSource.Schedules.length;i++){if(this._dataSource.Schedules[i][this._dataFieldId]==result[this._dataFieldId]){this._dataSource.Schedules[i]=result;this.refresh();break;}}}}));},addSchedule:function(schedule){Carpa.Web.Script.UI.SchedulerController._staticInstance.AddSchedule(this.get_element().id,schedule,Function.createDelegate(this,function(result){if(result!=null){this._dataSource.Schedules.push(result);this.refresh();}}));},deleteSchedule:function(schedule){Carpa.Web.Script.UI.SchedulerController._staticInstance.DeleteSchedule(this.get_element().id,schedule,Function.createDelegate(this,function(result){if(result){for(i=0;i<this._dataSource.Schedules.length;i++){if(this._dataSource.Schedules[i][this._dataFieldId]==schedule[this._dataFieldId]){this._dataSource.Schedules.splice(i,1);this.refresh();break;}}}}));},_addDays:function(date,days){date.setDate(date.getDate()+days);},_addMonths:function(date,months){date.setMonth(date.getMonth()+months);},_addYears:function(date,years){date.setMonth(date.getMonth()+years*12);},priorPrior:function(){switch(this._mode){case 0:case 1:case 2:this._addYears(this._selectedDate,-1);break;default:throw Error.create("invalid mode");break;} this._currentSelectedDate=this._selectedDate;this._loadSchedules();return false;},prior:function(){switch(this._mode){case 0:this._addDays(this._selectedDate,-1);break;case 1:this._addDays(this._selectedDate,-7);break;case 2:this._addMonths(this._selectedDate,-1);break;default:throw Error.create("invalid mode");break;} this._currentSelectedDate=this._selectedDate;this._loadSchedules();return false;},nextNext:function(){switch(this._mode){case 0:case 1:case 2:this._addYears(this._selectedDate,1);break;default:throw Error.create("invalid mode");} this._currentSelectedDate=this._selectedDate;this._loadSchedules();return false;},next:function(){switch(this._mode){case 0:this._addDays(this._selectedDate,1);break;case 1:this._addDays(this._selectedDate,7);break;case 2:this._addMonths(this._selectedDate,1);break;default:throw Error.create("invalid mode"+this._mode);} this._currentSelectedDate=this._selectedDate;this._loadSchedules();return false;},refreshAll:function(){this._loadSchedules();},refresh:function(){this._clearObjects();this._body.innerText="";this._createSchedules(this._body);},_doSelectDatePanel:function(date){var i=this._compareDate(date,this._dataSource.BeginDateTime);if(i>=0&&i<this._panels.length&&this._panels[i]!=this._selectedPanel){this._doSelectPanel(this._panels[i]);this._doSelectLabel(null);}},_loadSchedules:function(){Carpa.Web.Script.UI.SchedulerController._staticInstance.GetDataSource(this.get_element().id,this._selectedDate,this._mode,Function.createDelegate(this,function(result){if(this._selectedDate<result.BeginDateTime||this._selectedDate>result.EndDateTime){return;} this._dataSource=result;this.refresh();}));},_createWeekHeader:function(tbody){var row=this._createTr(tbody);var td;for(i=0;i<7;i++){td=this._createTd(row);td.height=this._headerHeight;td.width="14%";td.align="center";td.className="schedulerWeekPanel";this._createLabel(td,this._days[i]);} return row;},_date1970:function(){return new Date(1970,1,1,0,0,0).getTime();}(),_compareDate:function(d1,d2){return Math.floor((d1.getTime()-this._date1970)/86400000)-Math.floor((d2.getTime()-this._date1970)/86400000);},_createSchedules:function(body){this._panels=new Array();this._panelHeight=null;this._sortDataSource();this._currentCreatePanelIndex=0;this._createHeader(body);var d=new Date(this._dataSource.BeginDateTime);if(this._mode==0){var tr=this._createTr(body);this._createPanel(tr,d);} else{this._createWeekHeader(body);if(this._mode==1){this._createRow(body,d);} else{var month=this._selectedDate.getMonth();var totalWeek=this._compareDate(this._dataSource.EndDateTime,d)/7;if(this._height){this._panelHeight=(this._height-this._scheduleMargin-this._headerHeight*2-this._panelMarginSize*(totalWeek*2)-this._borderSize*(totalWeek+1))/totalWeek;} while(this._compareDate(d,this._dataSource.EndDateTime)<0){this._createRow(body,d);}}}},_sortDataSource:function(){if(this._dataSource==null){return;} this._dataSource.Schedules.sort(Function.createDelegate(this,function(s1,s2){return s1[this._dataFieldScheduleTime].valueOf()-s2[this._dataFieldScheduleTime].valueOf();}));},_getTextWidth:function(){return this._mode==0?this._dayTextWidth:this._dayElseTextWidth;},_createTr:function(parent){var tr=$common.createTr();parent.appendChild(tr);return tr;},_createCommonTd:function(tr){var td=$common.createTd();tr.appendChild(td);return td;},_createTd:function(tr){var td=this._createCommonTd(tr);td.className="SchedulerPanel";return td;},_getLabelPanelFromEvent:function(event){return(event.target.nodeName.toLowerCase()=="label")?event.target.parentNode:event.target;},_labelMouseHover:function(event){this._floatHintDiv.innerText=event.target.innerText;if(this._floatHint)this._floatHint.show(event);},_labelMouseOut:function(event){if(this._floatHint)this._floatHint.hide();},_getPanelClass:function(p){if(this._mode!=0&&this._compareDate(p._date,this._dataSource.TodayDate)==0){return"SchedulerTodayPanel";} else{return"SchedulerPanel";}},_doAddButtonClick:function(e){var handler=this.get_events().getHandler("addButtonClick");if(handler){handler(this,e.target._date);}},_doDeleteButtonClick:function(e){var handler=this.get_events().getHandler("deleteButtonClick");if(handler){handler(this,this._getSchedule(e.target.scheduleIndex));}},_doSelectPanel:function(p){if(this._selectedPanel==p){return;} this._selectedPanel=p;p.className=this._getPanelClass(p);this._currentSelectedDate=p._date;},_doSelectLabel:function(p){if(this._selectedLabel==p){return;} this._selectedLabel=p;if(p!=null){this._doSelectPanel(this._getContainerPanel(p));}},_doScheduleItemClicked:function(event){var handler=this.get_events().getHandler("scheduleItemClick");if(handler){handler(this,this._getSchedule(event.target.scheduleIndex));} return false;},_doScheduleDbClicked:function(event){var handler=this.get_events().getHandler("scheduleDblClick");if(handler){handler(this,this._getSchedule(event.target.scheduleIndex));}},_getContainerPanel:function(p){while(p._date==null&&p!=null){p=p.parentNode;} return p;},_mouseClickPanelElement:function(p){var n=p.nodeName.toLowerCase();if(n=="label"&&p.parentNode.scheduleIndex){this._doSelectLabel(p.parentNode);} else if(p.scheduleIndex){this._doSelectLabel(p);} else{p=this._getContainerPanel(p);this._doSelectPanel(p);this._doSelectLabel(null);}},_panelMouseClick:function(event){this._mouseClickPanelElement(event.target);var handler=this.get_events().getHandler("scheduleClick");if(handler){handler(this);}},_dayLabelClick:function(event){this._currentSelectedDate=event.target._date;var handler=this.get_events().getHandler("dayLabelClick");if(handler){handler(this);} return false;},_createLabelTd:function(body){return this._createCommonTd(this._createTr(body));},_getSchedule:function(index){return this._dataSource.Schedules[index];},_createDeleteButton:function(parent,scheduleIndex){var schedule=this._getSchedule(scheduleIndex);if(schedule[this._dataFieldReadOnly]){return this._createLabel(parent,"* ");} else{var deleteButton=this._createImageButton(parent,"delete_scheduler.gif");deleteButton.scheduleIndex=scheduleIndex;$common.addClickHandler(deleteButton,this._doDeleteButtonClick,this);return deleteButton;}},_createDivScheduleLabel:function(td,scheduleIndex){var schedule=this._getSchedule(scheduleIndex);var label=$common.createDiv();label.className="SchedulerItemPanel";label.style.width=this._getTextWidth()+"px";this._createDeleteButton(label,scheduleIndex);var t=this._createEmptyLinker(schedule[this._dataFieldTitle]);t.scheduleIndex=scheduleIndex;if(schedule[this._dataFieldCssClass]==null||schedule[this._dataFieldCssClass]==""){t.className="SchedulerItem";} else{t.className=schedule[this._dataFieldCssClass];} if(schedule[this._dataFieldHint]){t.title=schedule[this._dataFieldHint];} $common.addDblClickHandler(t,this._doScheduleDbClicked,this);$common.addClickHandler(t,this._doScheduleItemClicked,this);label.appendChild(t);td.appendChild(label);return t;},_getDayText:function(date){var s=date.getDate().toString();if(this._mode==1)return(date.getMonth()+1)+"/"+s;else return s;},_createDayLabel:function(panel,date){var dayLabel=this._createEmptyLinker(this._getDayText(date));panel.appendChild(dayLabel);$common.addClickHandler(dayLabel,this._dayLabelClick,this);dayLabel.className="SchedulerDayLink";dayLabel._date=date;return dayLabel;},_createImageButton:function(parent,image){var b=document.createElement("img");b.align="absmiddle";b.src=__skinBaseURI+"ui/scheduler/"+image;parent.appendChild(b);return b;},_createDayPanel:function(panel){var dayPanel=$common.createTable();dayPanel.width="100%";dayPanel.style.height="20px";var body=$common.createTBody();var tr=this._createTr(body);tr.style.width="100%";tr.className=(this._mode!=2||this._selectedDate.getMonth()==panel._date.getMonth())?"SchedulerDayPanel":"SchedulerOtherDayPanel";this._createCommonTd(tr).style.width="5px";var dayLabelPanel=this._createCommonTd(tr);this._createDayLabel(dayLabelPanel,panel._date);var imagePanel=this._createCommonTd(tr);imagePanel.style.width="16px";var addButton=this._createImageButton(imagePanel,"add_scheduler.gif");addButton._date=panel._date;$common.addMouseUpHandler(addButton,this._doAddButtonClick,this);this._createCommonTd(tr).style.width="5px";dayPanel.appendChild(body);panel.appendChild(dayPanel);},_createScheduleItems:function(body,date){var schedule,c;var itemsPanel=null;itemsPanel=this._createLabelTd(body);itemsPanel.vAlign="top";while(this._currentCreatePanelIndex<this._dataSource.Schedules.length){schedule=this._dataSource.Schedules[this._currentCreatePanelIndex];c=this._compareDate(schedule[this._dataFieldScheduleTime],date);if(c<0){this._currentCreatePanelIndex++;} else if(c==0){this._createDivScheduleLabel(itemsPanel,this._currentCreatePanelIndex);this._currentCreatePanelIndex++;} else{break;}}},_createPanel:function(row,date){var panel=this._createTd(row);this._panels.push(panel);panel.vAlign="top";if(this._panelHeight&&this._panelHeight>0){panel.height=this._panelHeight;} panel._date=new Date(date);$common.addClickHandler(panel,this._panelMouseClick,this);if(this._compareDate(this._currentSelectedDate,date)==0){this._doSelectPanel(panel);} else{panel.className=this._getPanelClass(panel);} this._createDayPanel(panel);var labelPanel=$common.createTable();var body=$common.createTBody();if(this._dataSource!=null){this._createScheduleItems(body,date);} labelPanel.appendChild(body);labelPanel.cellSpacing=this._cellSpacing;labelPanel.cellPadding=this._cellPadding;panel.appendChild(labelPanel);return panel;},_createRow:function(tbody,beginDate){var row=this._createTr(tbody);for(i=0;i<7;i++){this._createPanel(row,beginDate);beginDate.setDate(beginDate.getDate()+1);} return row;},_getTitleText:function(){var s;var d;if(this._mode==0){d=this._selectedDate;return d.getFullYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日"+this._days[d.getDay()];} else if(this._mode==1){d=this._dataSource.BeginDateTime;var e=new Date(this._dataSource.EndDateTime);this._addDays(e,-1);return d.getFullYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日至"+e.getFullYear()+"年"+(e.getMonth()+1)+"月"+e.getDate()+"日";} else{d=this._selectedDate;return d.getFullYear()+"年"+(d.getMonth()+1)+"月";}},_createLabel:function(p,text){var label=document.createElement("label");label.innerText=text;p.appendChild(label);return label;},_createLinker:function(text,href){var a=document.createElement("a");a.href=href;a.innerText=text;a.className="SchedulerLink";return a;},_createEmptyLinker:function(text){return this._createLinker(text,"javascript:;");},_createHeader:function(thead){var tr=this._createTr(thead);var td=this._createTd(tr);var l=this._createEmptyLinker("<");var r=this._createEmptyLinker(">");$common.addClickHandler(l,this.prior,this);$common.addClickHandler(r,this.next,this);var ll=this._createEmptyLinker("<<");var rr=this._createEmptyLinker(">>");$common.addClickHandler(ll,this.priorPrior,this);$common.addClickHandler(rr,this.nextNext,this);td.colSpan=this._mode==0?1:7;td.width="100%";td.height=this._headerHeight;td.align="center";td.vAlign="center";td.noWrap=true;td.appendChild(ll);this._createLabel(td,"  ");td.appendChild(l);this._createLabel(td," "+this._getTitleText()+" ").className="SchedulerTitle";td.appendChild(r);this._createLabel(td,"  ");td.appendChild(rr);return tr;},add_addButtonClick:function(handler){this.get_events().addHandler("addButtonClick",handler);},remove_addButtonClick:function(handler){this.get_events().removeHandler("addButtonClick",handler);},add_deleteButtonClick:function(handler){this.get_events().addHandler("deleteButtonClick",handler);},remove_deleteButtonClick:function(handler){this.get_events().removeHandler("deleteButtonClick",handler);},add_scheduleItemClick:function(handler){this.get_events().addHandler("scheduleItemClick",handler);},remove_scheduleItemClick:function(handler){this.get_events().removeHandler("scheduleItemClick",handler);},add_scheduleDblClick:function(handler){this.get_events().addHandler("scheduleDblClick",handler);},remove_scheduleDblClick:function(handler){this.get_events().removeHandler("scheduleDblClick",handler);},add_scheduleClick:function(handler){this.get_events().addHandler("scheduleClick",handler);},remove_scheduleClick:function(handler){this.get_events().removeHandler("scheduleClick",handler);},add_dayLabelClick:function(handler){this.get_events().addHandler("dayLabelClick",handler);},remove_dayLabelClick:function(handler){this.get_events().removeHandler("dayLabelClick",handler);},get_selectedDate:function(){return this._currentSelectedDate;},set_selectedDate:function(value){var d=this._selectedDate;var s=this._currentSelectedDate;this._selectedDate=value;this._currentSelectedDate=value;if(this.get_isInitialized()){switch(this._mode){case 0:if(this._compareDate(d,value)!=0){this._loadSchedules();} break;case 1:if(this._compareDate(value,this._dataSource.BeginDateTime)<0||this._compareDate(value,this._dataSource.EndDateTime)>=0){this._loadSchedules();} else if(this._compareDate(value,s)!=0){this._doSelectDatePanel(value);} break;case 2:if(d.getFullYear()!=value.getFullYear()||d.getMonth()!=value.getMonth()){this._loadSchedules();} else if(this._compareDate(value,s)!=0){this._doSelectDatePanel(value);} break;}}},get_dataSource:function(){return this._dataSource;},set_dataSource:function(value){this._dataSource=value;},get_selectedSchedule:function(){return this._selectedLabel==null?null:this._getSchedule(this._selectedLabel.scheduleIndex);},get_width:function(){return this._width;},set_width:function(value){this._width=value;},get_height:function(){return this._height;},set_height:function(value){this._height=value;},get_dataFieldId:function(){return this._dataFieldId;},set_dataFieldId:function(value){this._dataFieldId=value;},get_dataFieldHint:function(){return this._dataFieldHint;},set_dataFieldHint:function(value){this._dataFieldHint=value;},get_dataFieldScheduleTime:function(){return this._dataFieldScheduleTime;},set_dataFieldScheduleTime:function(value){this._dataFieldScheduleTime=value;},get_dataFieldTitle:function(){return this._dataFieldTitle;},set_dataFieldTitle:function(value){this._dataFieldTitle=value;},get_dataFieldCssClass:function(){return this._dataFieldCssClass;},set_dataFieldCssClass:function(value){this._dataFieldCssClass=value;},get_dataFieldReadOnly:function(){return this._dataFieldReadOnly;},set_dataFieldReadOnly:function(value){this._dataFieldReadOnly=value;},get_mode:function(){return this._mode;},set_mode:function(value){this._mode=Number.parse(value);if(this.get_isInitialized()){this._loadSchedules();}}}
Sys.UI.Controls.Scheduler.registerClass('Sys.UI.Controls.Scheduler',Sys.UI.Control);Type.registerNamespace("Sys.UI.Actions");Sys.UI.Actions.ControlAction=function(){Sys.UI.Actions.ControlAction.initializeBase(this);this._event="click";this._controlId=null;this._doExecute=null;this._if=null;}
Sys.UI.Actions.ControlAction.prototype={initialize:function(){Sys.UI.Actions.ControlAction.callBaseMethod(this,'initialize');},dispose:function(){this._doExecute=null;Sys.UI.Actions.ControlAction.callBaseMethod(this,'dispose');},get_parentAction:function(){var action=this.findParentAction();if(!action){throw Error.invalidOperation(Object.getTypeName(this)+" 的父标签必须是一个 Action");} return action;},findParentAction:function(){var control=this.findControl();return control&&Sys.UI.Actions.ControlAction.isInstanceOfType(control)?control:null;},doFormInit:function(){var control=this.get_control();var event=this._event;if(!(control["add_"+event]instanceof Function)){throw new Error.invalidOperation(String.format(Sys.Res.undefinedEvent,this._event));} this._doExecute=Function.createDelegate(this,this._internalExecute);control["add_"+event](this._doExecute);},add_beforeExecute:function(handler,handlerOwner){return this.get_events().addHandler("beforeExecute",handler,handlerOwner);},remove_beforeExecute:function(handler){this.get_events().removeHandler("beforeExecute",handler);},add_afterExecute:function(handler){this.get_events().addHandler("afterExecute",handler);},remove_afterExecute:function(handler){this.get_events().removeHandler("afterExecute",handler);},_internalExecute:function(sender,eventArgs){var cancelEventArgs=new Sys.CancelEventArgs();this.doBeforeExecute(cancelEventArgs);if(!cancelEventArgs.get_cancel()){if(this._event!="execute"){try{this.doExecute(cancelEventArgs);} catch(e){if(e.isAbort){return;} else{throw e;}}} this.execute(sender);this.doAfterExecute();}},doBeforeExecute:function(eventArgs){var handler=this.get_events().getHandler("beforeExecute");if(handler){handler(this,eventArgs);}},doAfterExecute:function(eventArgs){var handler=this.get_events().getHandler("afterExecute");if(handler){handler(this,eventArgs);}},doExecute:function(eventArgs){var handler=this.get_events().getHandler("execute");if(handler){handler(this,eventArgs);}},add_execute:function(handler){this.get_events().addHandler("execute",handler);},remove_execute:function(handler){this.get_events().removeHandler("execute",handler);},execute:function(sender){},get_control:function(){var control=this.findControl();if(!control){throw Error.argumentUndefined('control');} return control;},findControl:function(){var control=null;var controlId=this._controlId;if(controlId){var control=this.get_form()[controlId];if(!control){throw new Error.invalidOperation(String.format(Sys.Res.referenceNotFound,controlId));}} return control;},get_controlId:function(){return this._controlId;},set_controlId:function(value){this._controlId=value;},get_event:function(){return this._event;},set_event:function(value){this._event=value;},get_if:function(value){return this._if;},set_if:function(value){this._if=value;}}
Sys.UI.Actions.ControlAction.registerClass('Sys.UI.Actions.ControlAction',Sys.Component);Sys.UI.Actions.GetReportMasterDataEventArgs=function(masterFields){Sys.UI.Actions.GetReportMasterDataEventArgs.initializeBase(this);this._masterFields=masterFields;this._data=null;}
Sys.UI.Actions.GetReportMasterDataEventArgs.prototype={get_masterFields:function(){return this._masterFields;},clearMasterFields:function(){Array.clear(this._masterFields);},addMasterField:function(name,dataField,visible){var field={name:name,dataField:dataField};if(!visible){field.hidden=true;} Array.add(this._masterFields,field);},get_data:function(){return this._data;},set_data:function(value){this._data=value;}}
Sys.UI.Actions.GetReportMasterDataEventArgs.registerClass('Sys.UI.Actions.GetReportMasterDataEventArgs',Sys.CancelEventArgs);Sys.UI.Actions.Report=function(){Sys.UI.Actions.Report.initializeBase(this);this._formUrl=null;this._formWidth=177+20;this._formHeight=195+40;this._gridId=null;this._showModal=true;this._reportName=null;this._reportNumber=-1;this._masterFields=null;this._detailFields=null;this._cookie=null;this._writeData=null;this._setupUrl=null;this._showMasterFields=true;this._showDetailHeader=true;this._createReport=false;this._directPrint=false;this._ajaxMode=false;this._reportMode=0;this._rowNoExpr=null;this._requiredVersion=$settings.requiredCPrintVersion||"10.2.0.410";}
Sys.UI.Actions.Report.prototype={doFormInit:function(){Sys.UI.Actions.Report.callBaseMethod(this,'doFormInit');if(Sys.Browser.isIE){window.asyncCall(Function.createDelegate(this,this._createOcx));}},dispose:function(){this._writeData=null;Sys.UI.Actions.Report.callBaseMethod(this,'dispose');},_createOcx:function(){var writeData=this._writeData=document.createElement("<object classid='clsid:340fc08c-5fbf-4f52-9cd7-e50a446a1484' width=0 height=0></object>");$common.setDisplay(writeData,false);document.body.appendChild(writeData);},_removeOcx:function(){if(this._writeData){try{$removeNode(this._writeData);} catch(e){} this._writeData=null;}},_internalRefreshOcx:function(){this._removeOcx();this._createOcx();},_internalExportXls:function(){try{$common._internalExportXls(this._getReportData(true));} catch(e){window.handleError(e);}},get_formUrl:function(){return this._formUrl;},set_formUrl:function(value){this._formUrl=value;},get_formWidth:function(){return this._formWidth;},set_formWidth:function(value){this._formWidth=value;},get_formHeight:function(){return this._formHeight;},set_formHeight:function(value){this._formHeight=value;},get_gridId:function(){return this._gridId;},set_gridId:function(value){this._gridId=value;},get_showModal:function(){return this._showModal;},set_showModal:function(value){this._showModal=value;},get_reportName:function(){return this._reportName;},set_reportName:function(value){this._reportName=value;},get_reportNumber:function(){return this._reportNumber;},set_reportNumber:function(value){this._reportNumber=value;},get_masterFields:function(){return this._masterFields;},set_masterFields:function(value){this._masterFields=value;},get_detailFields:function(){return this._detailFields;},set_detailFields:function(value){this._detailFields=value;},get_cookie:function(){return this._cookie;},set_cookie:function(value){this._cookie=value;},get_setupUrl:function(){return this._setupUrl;},set_setupUrl:function(value){this._setupUrl=value;},get_showMasterFields:function(){return this._showMasterFields;},set_showMasterFields:function(value){this._showMasterFields=value;},get_showDetailHeader:function(){return this._showDetailHeader;},set_showDetailHeader:function(value){this._showDetailHeader=value;},get_createReport:function(){return this._createReport;},set_createReport:function(value){this._createReport=value;},get_directPrint:function(){return this._directPrint;},set_directPrint:function(value){this._directPrint=value;},get_ajaxMode:function(){return this._ajaxMode;},set_ajaxMode:function(value){this._ajaxMode=value;},get_reportMode:function(){return this._reportMode;},set_reportMode:function(value){this._reportMode=value;},get_rowNoExpr:function(){return this._rowNoExpr;},set_rowNoExpr:function(value){this._rowNoExpr=value;},add_getMasterData:function(handler){this.get_events().addHandler("getMasterData",handler);},remove_getMasterData:function(handler){this.get_events().removeHandler("getMasterData",handler);},add_initDetailData:function(handler){this.get_events().addHandler("initDetailData",handler);},remove_initDetailData:function(handler){this.get_events().removeHandler("initDetailData",handler);},add_initDetailList:function(handler){this.get_events().addHandler("initDetailList",handler);},remove_initDetailList:function(handler){this.get_events().removeHandler("initDetailList",handler);},get_grids:function(){var grids=[];var gridIds=this._gridId;if(gridIds){var form=this.get_form();var idArray=gridIds.split(',');for(var i=0,count=idArray.length;i<count;i++){var id=idArray[i].trim();if(id){Array.add(grids,form[id]);}}} return grids;},get_grid:function(){var grids=this.get_grids();return grids.length>0?grids[0]:null;},_getWriteData:function(){if(!this._writeData){alert("正在初始化，点确定继续");} return this._writeData;},_setEnabled:function(sender,value){if(sender&&sender.set_enabled){sender.set_enabled(value);}},execute:function(sender){this._execute(sender);},directPrint:function(){this._execute(null,true);},_execute:function(sender,directPrint){if(!this._writeData){return;} var enabled=false;if(sender&&sender.get_enabled){enabled=sender.get_enabled();} if(enabled){this._setEnabled(sender,false);} try{this._executeReport(sender,directPrint);} catch(e){if(e.message){alert(e.message);}} finally{if(!this.get_ajaxMode()&&enabled){this._setEnabled(sender,true);}}},_getVersionInfo:function(version){var strs=version.split('.');var answer=[];for(var i=0,count=strs.length;i<count;i++){Array.add(answer,parseInt(strs[i]));} return answer;},_compareVersion:function(version1,version2){if(!version1||!version2)return-1;var v1=this._getVersionInfo(version1);var v2=this._getVersionInfo(version2);var answer=v1[0]-v2[0];if(answer==0){answer=v1[1]-v2[1];if(answer==0){answer=v1[2]-v2[2];if(answer==0){answer=v1[3]-v2[3];}}} return answer;},_version:"",_isInstalledOk:function(){var writeData=this._getWriteData();try{this._version=writeData.Version;var ok=this._compareVersion(this._version,this._requiredVersion)>=0;return ok;} catch(ex){return false;}},checkInstall:function(){if(!this._isInstalledOk()){var setupUrl=this.get_setupUrl();if(setupUrl){this.get_form().saveData();var returnValue=$common.showModalDialog(setupUrl+(this._version?"?Version="+this._version+"&Required="+this._requiredVersion:""),400,300);if(returnValue==1){this._internalExportXls();} else if(returnValue==2){try{this._internalRefreshOcx();} catch(e){}} return this._isInstalledOk();} else{throw Error.abort("不能打印。请检查打印管理器是否正确安装");}} return true;},_getReportData:function(getDataFormServer){var masterFields0=this.get_masterFields();var masterFields=masterFields0?Array.clone(masterFields0):[];var grid=this.get_grid();if(this.get_showMasterFields()){Sys.UI._Exporter.initMasterFields(this.get_form(),grid,masterFields);if(masterFields0){this._adjustFieldsOrder(masterFields,masterFields0);for(var i=0;i<masterFields.length;i++){var field=masterFields[i];if(field.after&&i>0){var lastField=masterFields[i-1];if(lastField.isFooter){field.isFooter=true;}}}}} var handler=this.get_events().getHandler("getMasterData");if(handler){var eventArgs=new Sys.UI.Actions.GetReportMasterDataEventArgs(masterFields);handler(this,eventArgs);if(eventArgs.get_cancel()){return;} var data=eventArgs.get_data();if(data){for(var i=0;i<masterFields.length;i++){var field=masterFields[i];var dataField=field.dataField;if(dataField){var newValue=data[dataField];if(!field.hasValue&&newValue!=null){field.value=newValue;}}}}} var dataObj=new Object();dataObj.reportName=this.get_reportName();dataObj.reportNumber=this.get_reportNumber();if($settings.CPrintDataDirName){dataObj.dataDirName=$settings.CPrintDataDirName;} dataObj.masterFields=masterFields;var detailFields0=this.get_detailFields();var detailFields=detailFields0?Array.clone(detailFields0):[];dataObj.detailFields=detailFields;dataObj.cookie=this.get_cookie();if(grid){var pager=grid.findPager();dataObj.detailDataUrl=pager?(window.location.protocol+"//"+window.location.host+pager.get_service().get_path()+"/GetPagerData"):"null";var reportMode=this.get_reportMode();if(pager&&getDataFormServer&&pager.get_showAll()&&reportMode!=2){getDataFormServer=false;} var getDataFromClient;var fullDataMode=false;if(!pager||reportMode==1){getDataFromClient=true;} else{if(reportMode==2){getDataFromClient=false;fullDataMode=true;} else{getDataFromClient=pager.get_pageCount()==1;}} var grids=this.get_grids();var gridCount=grids.length;if(gridCount==1){Sys.UI._Exporter.initDetailFields(grids[0],detailFields,true,masterFields);Sys.UI._Exporter.initColumnExpands(grids[0],dataObj);} else{var newGrids=Array.clone(grids);if(gridCount==2){if(newGrids[1].get_visibleColumnCount()>newGrids[0].get_visibleColumnCount()){var grid1=newGrids[1];newGrids[1]=newGrids[0];newGrids[0]=grid1;}} for(var i=0;i<gridCount;i++){Sys.UI._Exporter.initDetailFields(newGrids[i],detailFields,false,masterFields);}} if(grid.get_maxHeaderLevel()>=2){var detailHeaders=dataObj._detailHeaders={};this._initDetailHeader(grid,detailHeaders);} if(getDataFromClient){var onInitDetailData=this.get_events().getHandler("initDetailData");var onInitDetailList=this.get_events().getHandler("initDetailList");dataObj.detailData=Sys.UI._Exporter.getGridsData(grids,onInitDetailData,onInitDetailList,this,detailFields);} if(pager&&!getDataFromClient){if(!getDataFormServer){var detailParams=new Object();detailParams.pagerId=pager.get_id();var queryParams=null;if(fullDataMode){queryParams=pager.get_queryParams();if(!queryParams){queryParams=new Object();} dataObj.fullDataMode=true;} detailParams.queryParams=queryParams;detailParams.orders=null;detailParams.filter=null;detailParams.first=0;detailParams.count=pager.get_itemCount();dataObj.detailParams=detailParams;} else{dataObj.detailPagerId=grid.get_pagerClientId();if(reportMode==2){dataObj.fullDataMode=true;}}}} else{dataObj.detailDataUrl="null";if(detailFields.length==0){var field=new Object();field.name="行号";field.caption=field.name;field.dataField=field.name;field.hidden=true;Array.add(detailFields,field);} var data=new Object();data.itemCount=0;data.itemList=[];dataObj.detailData=data;} if(detailFields0){this._adjustFieldsOrder(detailFields,detailFields0);} dataObj.rowNoExpr=this.get_rowNoExpr()||"";return dataObj;},_adjustFieldsOrder:function(fields,fields0){var lastAfter=null;var lastName=null;var findIndexByAfter=function(fields,after){for(var i=0,count=fields.length;i<count;i++){var field=fields[i];if(field.name==after||field.dataField==after){return i;}} return-1;};for(var i=0,count=fields0.length;i<count;i++){var field0=fields0[i];if(field0.hidden)continue;var after=field0.after;if(after){lastAfter=after;lastName=field0.name;} else if(lastAfter){after=lastName;lastAfter=after;lastName=field0.name;} if(after){Array.remove(fields,field0);var afterIndex=findIndexByAfter(fields,after);if(afterIndex<0){throw Error.invalidOperation("找不到字段："+after);} if(afterIndex==fields.length-1){Array.add(fields,field0);} else{Array.insert(fields,afterIndex+1,field0);}}}},_initDetailHeader:function(grid,detailHeaders){var header=grid._header;if(!header)return;var hasSpacer=grid._headerSpacer!=null;var body=$common.getTableBody(header);var rows=body.childNodes;var rowCount=detailHeaders.rowCount=rows.length;var rowsCells=detailHeaders.rowsCells=[];var colCount=0;for(var i=0;i<rowCount;i++){var row=rows[i];var rowColCount=0;var childNodes=row.childNodes;var cellCount=childNodes.length;if(i==0&&hasSpacer){cellCount--;} for(var j=0;j<cellCount;j++){var cell=childNodes[j];if(Sys.UI.DomElement.getVisible(cell)){var colSpan=1;if(cell.colSpan){colSpan=parseInt(cell.colSpan);} var rowSpan=1;if(cell.rowSpan){rowSpan=parseInt(cell.rowSpan);} var div=cell.firstChild;var text=div.firstChild.tagName?div.firstChild.innerHTML:div.innerHTML;var align=cell.align||"";var width=cell.offsetWidth;this._addDetailHeaderCells(rowsCells,i,rowSpan,colSpan,text,width,align);rowColCount+=colSpan;}} colCount=Math.max(colCount,rowColCount);} detailHeaders.colCount=colCount;},_addDetailHeaderCells:function(rowsCells,rowIndex,rowSpan,colSpan,text,width,align){for(var j=0;j<colSpan;j++){var newRowIndex=rowIndex;var colIndex;for(var i=0;i<rowSpan;i++,newRowIndex++){var rowCells=rowsCells[newRowIndex];if(typeof(rowCells)=="undefined"){rowCells=rowsCells[newRowIndex]=[];} var cell={};if(i==0&&j==0){if(rowSpan>1||colSpan>1){cell.rowSpan=rowSpan;cell.colSpan=colSpan;} cell.text=text;} else{cell.text="";} cell.width=colSpan==1?width:(width-colSpan+1)/colSpan;cell.align=align;cell.rowIndex=rowIndex;if(i==0){colIndex=0;for(var k=0,count=rowCells.length;k<count;k++){if(typeof(rowCells[colIndex])=="undefined"){break;} colIndex++;}} rowCells[colIndex]=cell;cell.colIndex=colIndex;}}},_executeReport:function(sender,directPrint){if(!Sys.Browser.isIE){throw Error.invalidOperation("不支持 "+Sys.Browser.name+" 浏览器下的打印");} if(!this.checkInstall()){return;} var dataObj=this._getReportData();if(!this.get_ajaxMode()){this._showReport(dataObj,directPrint);} else{var grid=this.get_grid();if(grid.findPager()){this._ajaxShowReport(sender,grid,dataObj);}}},_addEmptyLine:function(writeData,pageWidth,lineHeight){writeData.AddLine(1);if(!lineHeight)lineHeight=15;writeData.AddCell("",pageWidth,lineHeight-7,0,1,0,1,0,1,0,1,1,-1,1,1);writeData.EndLine();},_addHeaderFooter:function(writeData,pageWidth,fields,fieldNames){var lineCount=0;var lineEnded=false;var fieldWidth=Math.round(pageWidth/4);var fieldCount=fields.length;if(fieldCount==1){writeData.AddLine(2);this._addHeaderFooterField(writeData,fields[0].name,fields[0].name,fieldWidth*2);writeData.EndLine();return 1;} for(var i=0;i<fieldCount;i++){var field=fields[i];if(i%2==0){lineCount++;writeData.AddLine(4);lineEnded=false;} var fieldName=this._getFieldName(field.name);var sameCount=0;for(var j=0,count=fieldNames.length;j<count;j++){if(fieldNames[j]==fieldName){sameCount++;}} Array.add(fieldNames,fieldName);if(sameCount>=99){throw Error.create('截短后主表重名字段“'+fieldName+'”不能超过99个');} else if(sameCount>0){fieldName+=(sameCount+1);} this._addHeaderFooterField(writeData,field.name,fieldName,fieldWidth);if(i%2==1){writeData.EndLine();lineEnded=true;}} if(!lineEnded){writeData.AddCell("",fieldWidth,9,1,1,1,1,1,1,1,1,1,-1,0,1);writeData.AddCell("",fieldWidth,9,1,1,1,1,1,1,1,1,1,-1,0,1);writeData.EndLine();} return lineCount;},_addHeaderFooterField:function(writeData,caption,name,fieldWidth){writeData.AddCell(caption,fieldWidth,9,1,1,1,1,1,1,1,1,1,-1,0,1);writeData.SetCellFont("宋体",9,1,0,0,0);writeData.AddCell('@'+name,fieldWidth,9,1,1,1,1,1,1,1,1,1,-1,0,1);},_toReportHAlign:function(align){if(align=="center")return 1;else if(align=="right")return 2;else return 0;},_subByteStr:function(s,start,size){var count=s.length;if(start>=count){return"";} var i=start;var readed=0;var r="";while(i<count&&readed<size){var code=s.charCodeAt(i);readed+=code>127?2:1;if(readed>size){break;} i++;} return i==start?"":s.substr(start,i-start);},_getFieldName:function(name){return this._subByteStr(name,0,29);},_doCreateReport:function(writeData,dataObj){var detailFields=dataObj.detailFields;var detailFieldCount=detailFields.length;var detailWidth=0;var visibleFieldCount=0;if(detailFieldCount>0){for(var i=0;i<detailFieldCount;i++){var field=detailFields[i];if(field.hidden)continue;visibleFieldCount++;if(!field.columnWidth){field.columnWidth=field.size?(field.size+1)*12:60;} detailWidth+=field.columnWidth;}} var marginLeftRight=10;var marginTopBottom=10;var ratio=96/25.4;var maxPageWidth=Math.round((210-marginLeftRight*2)*ratio);var maxPageHeight=Math.round((297-marginTopBottom*2)*ratio);var useVertPage=detailWidth<maxPageWidth*2;var reportName=this.get_reportName();writeData.CreateReport(reportName,useVertPage?0:1);writeData.SetReportMargin(marginTopBottom,marginLeftRight,marginLeftRight,marginTopBottom);var pageWidth=useVertPage?maxPageWidth:maxPageHeight;var lineIndex=0;writeData.AddLine(2);var fieldWidth=Math.round(pageWidth/2);writeData.AddCell("`日期",fieldWidth,9,0,1,0,1,0,1,0,1,1,-1,0,1);writeData.AddCell("`总页码",fieldWidth,9,0,1,0,1,0,1,0,1,1,-1,2,1);writeData.EndLine();lineIndex++;writeData.AddLine(1);writeData.AddCell(reportName,pageWidth,20,0,1,0,1,0,1,0,1,1,-1,1,1);writeData.SetCellFont("宋体",20,1,0,0,0);writeData.EndLine();lineIndex++;this._addEmptyLine(writeData,pageWidth);lineIndex++;var masterFields=dataObj.masterFields;var headerFields=[];var footerFields=[];var count=masterFields.length;var masterFieldNames=null;if(count>0){masterFieldNames=new Array(count);for(var i=0;i<count;i++){var field=masterFields[i];if(!field.hidden){if(!field.isFooter){Array.add(headerFields,field);} else{Array.add(footerFields,field);}} else{Array.add(masterFieldNames,field.name);}}} if(headerFields.length>0){var lineCount=this._addHeaderFooter(writeData,pageWidth,headerFields,masterFieldNames);lineIndex+=lineCount;this._addEmptyLine(writeData,pageWidth,18);lineIndex++;} if(visibleFieldCount>0){var widthRatio=pageWidth/(detailWidth>0?detailWidth:1);if(this.get_showDetailHeader()){var _detailHeaders=dataObj._detailHeaders;if(!_detailHeaders){this._addSingleDetailHeader(writeData,widthRatio,detailFieldCount,visibleFieldCount,detailFields,masterFields);} else{this._addMultiDetailHeader(writeData,widthRatio,lineIndex,_detailHeaders);delete dataObj._detailHeaders;}} writeData.AddLine(visibleFieldCount);var fieldNames=new Array();fieldNames.length=detailFieldCount;for(var i=0;i<detailFieldCount;i++){var field=detailFields[i];if(field.hidden)continue;var decimal=-1;if(field.columnType=="Number"&&field.decimalDigits>0){decimal=field.decimalDigits;} var fieldName=this._getFieldName(field.name);fieldNames[i]=fieldName;var sameCount=0;for(var j=0;j<i;j++){if(fieldNames[j]==fieldName){sameCount++;}} if(sameCount>=99){throw Error.create('截短后明细重名字段“'+fieldName+'”不能超过99个');} else if(sameCount>0){fieldName+=(sameCount+1);} field.newName=fieldName;writeData.AddCell('#'+fieldName,Math.round(field.columnWidth*widthRatio),9,1,1,1,1,1,1,1,1,1,decimal,this._toReportHAlign(field.textAlign),1);} writeData.EndLine();var hasFooter=false;for(var i=0;i<detailFieldCount;i++){var field=detailFields[i];if(!field.hidden&&field.footer){hasFooter=true;break;}} if(hasFooter){writeData.AddLine(visibleFieldCount);for(var i=0;i<detailFieldCount;i++){var field=detailFields[i];if(field.hidden)continue;var decimal=-1;var footer=field.footer||"";if(footer&&field.name){var isNumber=!isNaN(parseFloat(footer));if(field.columnType=="Number"||field.columnType=="Percent"){if(isNumber){footer="^"+(field.newName?field.newName:field.name);if(field.decimalDigits>0){decimal=field.decimalDigits;}} else{footer="";}} else if(isNumber){footer="";}} writeData.AddCell(footer,Math.round(field.columnWidth*widthRatio),9,1,1,1,1,1,1,1,1,1,decimal,this._toReportHAlign(field.textAlign),1);} writeData.EndLine();}} if(footerFields.length>0){this._addEmptyLine(writeData,pageWidth,18);this._addHeaderFooter(writeData,pageWidth,footerFields,masterFieldNames);} writeData.EndReport();},_addSingleDetailHeader:function(writeData,widthRatio,detailFieldCount,visibleFieldCount,detailFields,masterFields){writeData.AddLine(visibleFieldCount);for(var i=0;i<detailFieldCount;i++){var field=detailFields[i];if(field.hidden)continue;var fieldCaption=field.caption;if(!fieldCaption){fieldCaption=field.name;} var masterField=Sys.UI._Exporter.findMasterField(masterFields,"_"+field.name);if(masterField&&masterField.value){fieldCaption="@_"+field.name;} var cellWrap=1;writeData.AddCell(fieldCaption,Math.round(field.columnWidth*widthRatio),9,1,1,1,1,1,1,1,1,cellWrap,-1,this._toReportHAlign(field.headerAlign),1);writeData.SetCellFont("宋体",9,1,0,0,0);} writeData.EndLine();},_addMultiDetailHeader:function(writeData,widthRatio,lineIndex,detailHeaders){var rowCount=detailHeaders.rowCount;var colCount=detailHeaders.colCount;var rowsCells=detailHeaders.rowsCells;for(var i=0;i<rowCount;i++){var rowCells=rowsCells[i];writeData.AddLine(colCount);for(var j=0;j<colCount;j++){var cell=rowCells[j];var cellWrap=1;writeData.AddCell(cell.text,Math.round(cell.width*widthRatio),9,1,1,1,1,1,1,1,1,cellWrap,-1,this._toReportHAlign(cell.align),1);writeData.SetCellFont("宋体",9,1,0,0,0);} writeData.EndLine();} for(var i=0;i<rowCount;i++){var rowCells=rowsCells[i];for(var j=0;j<colCount;j++){var cell=rowCells[j];var rowIndex=cell.rowIndex;var colIndex=cell.colIndex;var rowSpan=cell.rowSpan;var colSpan=cell.colSpan;if(rowSpan>1||colSpan>1){var topLeftLine=lineIndex+rowIndex;var topLeftCell=colIndex;var rightBottomLine=lineIndex+rowIndex+rowSpan-1;var rightBottomCell=colIndex+colSpan-1;writeData.MergeCell(topLeftLine,topLeftCell,rightBottomLine,rightBottomCell);}}}},_showReport:function(dataObj,directPrint){var data=Sys.Serialization.JavaScriptSerializer.serialize(dataObj);var writeData=this._getWriteData();var ok=true;try{ok=writeData.LoadDataFromCarpa3(data,0)==0;if(ok&&this.get_createReport()){this._doCreateReport(writeData,dataObj);}} catch(ex){throw Error.abort("不能打印。请检查打印管理器是否正确安装："+(ex.message?ex.message:ex));} if(ok){if(!this.get_directPrint()&&!directPrint){var reportName=this.get_reportName();var url=this.get_formUrl();if(reportName){url=$common.addUrlParam(url,"ReportName",reportName);} $common.showDialog(url,this.get_formWidth(),this.get_formHeight(),this._showModal);} else{writeData.PrintWithoutDialog();}}},_ajaxShowReport:function(sender,grid,dataObj){$common.showLoading(grid.get_element());var pager=grid.get_pager();pager.get_service().GetPagerData(pager.get_id(),null,null,null,0,pager.get_itemCount(),Function.createDelegate(this,function(result){dataObj.detailData=result;$common.hideLoading();this._showReport(dataObj);this._setEnabled(sender,true);}),Function.createDelegate(this,function(error){$common.hideLoading();alert(Sys.Net.WebServiceProxy.formatWebServiceFailedServerError(error.get_message()));this._setEnabled(sender,true);}));}}
Sys.UI.Actions.Report.registerClass('Sys.UI.Actions.Report',Sys.UI.Actions.ControlAction);Sys.UI.Controls.MediaPlayer=function(element){Sys.UI.Controls.MediaPlayer.initializeBase(this,[element]);this._src=null;this._url=null;this._playing=true;}
Sys.UI.Controls.MediaPlayer.prototype={get_src:function(){return this._src;},set_src:function(value){this._src=value;this._changed();},get_url:function(){return this._url;},set_url:function(value){this._url=value;this._src=$common.getResourceUrl(value);this._changed();},_changed:function(){if(this.get_isInitialized()){var html="";if(this._playing){var src=this.get_form().convertUrl(this._src);html='<embed autostart="true" loop="false" width="0" height="0" src="'+src+'" />';} this.get_element().innerHTML=html;}},play:function(){this._playing=true;this._changed();},stop:function(value){this._playing=false;this._changed();}}
Sys.UI.Controls.MediaPlayer.registerClass('Sys.UI.Controls.MediaPlayer',Sys.UI.Controls.NoFocusContainer);
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();