table_obj.js

来自「proe5.0野火版下载(中文版免费下载)」· JavaScript 代码 · 共 1,808 行 · 第 1/4 页

JS
1,808
字号
\*--------------------------------------------------------------------------*/function isUniqueHeaderName ( headers , name ){  return ( getHeaderIndexByID ( headers , name ) == -1 ) ;}/*--------------------------------------------------------------------------*\| Function: hideTableHeaders| Purpose:  function hids the headers of the current table| Input:    | Output:   | Return:   \*--------------------------------------------------------------------------*/function hideTableHeaders (){  var index = getTableIndexByID (current_table_id) ;  if ( index >= 0 )    tables[index].visibleHeaders = false ;}/*--------------------------------------------------------------------------*\| Function: setTableDefaultColor| Purpose:  function sets the row colors of in a table| Input:    color    - string representing the color| Output:   | Return:   \*--------------------------------------------------------------------------*/function setTableDefaultColor ( color ){  var index = getTableIndexByID (current_table_id) ;  if ( index >= 0 )    tables[index].defaultColor = color ;}/*--------------------------------------------------------------------------*\| Function: addTableHeader| Purpose:  function adds header to a table| Input:    header_name - header row label|           header_unique_name - legal unique string for this table headers|           header_cmp_func - compare function for sorting|           allow_sort      - should sort arrow be visible|           visible    - is this column visible ( default "Yes" )| Output:   | Return:   \*--------------------------------------------------------------------------*/function addTableHeader ( args ){  var index = getTableIndexByID (current_table_id) ;  if ( index >= 0 &&  isUniqueHeaderName ( tables[index].tableHeadersData , 					   addTableHeader.arguments[1] ) )  {    var header = new TableHeader ( addTableHeader.arguments ) ;    appendToArray ( tables[index].tableHeadersData , header ) ;  }  else if ( index >= 0 )  {    debug_error_crash ( 'Error: Header name "' + addTableHeader.arguments[1] + '" is not unique.' , "addTableHeader" ) ;  }}/*--------------------------------------------------------------------------*\| Function: getCurrentHeader| Purpose:  function returns the current heade database| Input:    | Output:   | Return:   current header or null\*--------------------------------------------------------------------------*/function getCurrentHeader (){  var index = getTableIndexByID (current_table_id) ;  if ( index >= 0 )  {    var headers = tables[index].tableHeadersData ;    var len = headers.length ;    if ( len > 0 )    {      return headers[len-1] ;    }    else    {      debug_error_crash ( 'Error: invalid header index"', 'getCurrentHeader' );    }  }  return null ;}/*--------------------------------------------------------------------------*\| Function: setColumnClass| Purpose:  function sets the class with which this column will be showen| Input:    column_class  - class which will be used to display column |                        ( default - "tabledatafont" )| Output:   | Return:   \*--------------------------------------------------------------------------*/function setColumnClass ( column_class ){  var header = getCurrentHeader () ;  if ( header != null )    header.colClass = column_class ;}/*--------------------------------------------------------------------------*\| Function: hideTableHeader| Purpose:  function hides the header ( not the column )| Input:    | Output:   | Return:   \*--------------------------------------------------------------------------*/function hideTableHeader (){  var header = getCurrentHeader () ;  if ( header != null )    header.showHeader = false ;}/*--------------------------------------------------------------------------*\| Function: setColumnAlignment| Purpose:  function sets the alignment with which this column will be showen| Input     column_align  - alignment which will be used to display column |                           ( default - "left" )| Output:   | Return:   \*--------------------------------------------------------------------------*/function setColumnAlignment ( column_align ){  var header = getCurrentHeader () ;  if ( header != null )    header.colAlign = column_align ;}/*--------------------------------------------------------------------------*\| Function: setColumnVerticalAlignment| Purpose:  function sets the vertical alignment with which this column |           will be showen| Input     column_valign  - vertical alignment which will be used to display |           column |                           ( default - "middle" )| Output:   | Return:   \*--------------------------------------------------------------------------*/function setColumnVerticalAlignment ( column_align ){  var header = getCurrentHeader () ;  if ( header != null )    header.colVAlign = column_align ;}/*--------------------------------------------------------------------------*\| Function: setColumnVisibilityOnExport| Purpose:  function sets the visibility of column when in a text format output| Input     val  - "Yes"/"No" visible or not ( default "Yes" )| Output:   | Return:   \*--------------------------------------------------------------------------*/function setColumnVisibilityOnExport ( val ){  var header = getCurrentHeader () ;  if ( header != null )    header.textFormatVisibility = val ;}/*--------------------------------------------------------------------------*\| Function: setColumnCellToTextCallback| Purpose:  function sets the CellToTextCb which should get the cell |               information and return pure text.| Input     func   - func to set| Output:   | Return:   \*--------------------------------------------------------------------------*/function setColumnCellToTextCallback ( func ){  var header = getCurrentHeader () ;  if ( header != null )    header.cellToTextCB = func ;}/*--------------------------------------------------------------------------*\| Function: setColumnSortByColumnIndex| Purpose:  function sets the sortByColumnIndex value which is used to sort|           using other column info.| Input     colId  - id of the column to sort by.| Output:   | Return:   \*--------------------------------------------------------------------------*/function setColumnSortByColumnIndex ( colId ){  var table = null ;  var header = getCurrentHeader () ;  var index = getTableIndexByID (current_table_id) ;      if ( index >= 0 )    table = tables[index] ;  if ( table != null && header != null )    header.sortByColumnIndex = getHeaderIndexByID ( table.tableHeadersData , 						    colId ) ;}/*--------------------------------------------------------------------------*\| Function: getCurrentRow| Purpose:  function returns the current row database| Input:    | Output:   | Return:   current row or null\*--------------------------------------------------------------------------*/function getCurrentRow (){  var index = getTableIndexByID (current_table_id) ;      if ( index >= 0 )  {    var table = tables[index] ;    var rows = table.tableRowsData ;    if ( rows.length > 0 )    {      return rows[rows.length - 1] ;    }    else    {      debug_error_crash ( 'Error: invalid row index"', 'getCurrentRow' );    }  }  return null ;}/*--------------------------------------------------------------------------*\| Function: setRowAsAnchor| Purpose:  function sets the row to be anchor ( not being sorted ).| Input     | Output:   | Return:   \*--------------------------------------------------------------------------*/function setRowAsAnchor (){  var row = getCurrentRow () ;  if ( row != null )    row.anchor = true ;}/*--------------------------------------------------------------------------*\| Function: setRowColor| Purpose:  function sets the row color.| Input     | Output:   | Return:   \*--------------------------------------------------------------------------*/function setRowColor ( color ){  var row = getCurrentRow () ;  if ( row != null )    row.color = color ;}/*--------------------------------------------------------------------------*\| Function: getCurrentCell| Purpose:  function returns the current cell database| Input:    | Output:   | Return:   current cell or null\*--------------------------------------------------------------------------*/function getCurrentCell (){  var index = getTableIndexByID (current_table_id) ;      if ( index >= 0 )  {    var table = tables[index] ;    var rows = table.tableRowsData ;    if ( rows.length > 0 )    {      var row = rows[rows.length - 1] ;      var col_len = row.col.length ;      if ( col_len > 0 )      {	return row.col[col_len-1] ;      }      else      {	debug_error_crash ( 'Error: invalid cell index"', 'getCurrentCell' );      }    }  }  return null ;}/*--------------------------------------------------------------------------*\| Function: setCellColSpan| Purpose:  function sets the colspan with which this cell will be showen| Input:    span  - span which will be used to display column| Output:   | Return:   \*--------------------------------------------------------------------------*/function setCellColSpan ( span ){  var cell = getCurrentCell () ;  if ( cell != null )      cell.colSpan = span ;}/*--------------------------------------------------------------------------*\| Function: setCellRowSpan| Purpose:  function sets the rowspan with which this cell will be showen| Input:    span  - span which will be used to display column| Output:   | Return:   \*--------------------------------------------------------------------------*/function setCellRowSpan ( span ){  var cell = getCurrentCell () ;  if ( cell != null )      cell.rowSpan = span ;}/*--------------------------------------------------------------------------*\| Function: setCellBold| Purpose:  function sets the cell to be bold| Input:    | Output:   | Return:   \*--------------------------------------------------------------------------*/function setCellBold (){  var cell = getCurrentCell () ;  if ( cell != null )      cell.bold = true ;}/*--------------------------------------------------------------------------*\| Function: setCellAlign| Purpose:  function sets the cell alingment attribute| Input:    | Output:   | Return:   \*--------------------------------------------------------------------------*/function setCellAlign ( align ){  var cell = getCurrentCell () ;  if ( cell != null )      cell.align = align ;}/*--------------------------------------------------------------------------*\| Function: setCellVAlign| Purpose:  function sets the cell vertical alingment attribute| Input:    | Output:   | Return:   \*--------------------------------------------------------------------------*/function setCellVAlign ( valign ){  var cell = getCurrentCell () ;  if ( cell != null )      cell.valign = valign ;}/*--------------------------------------------------------------------------*\| Function: setCellFont| Purpose:  function sets the cell font| Input:    | Output:   | Return:   \*--------------------------------------------------------------------------*/function setCellFont ( font ){  var cell = getCurrentCell () ;  if ( cell != null )      cell.font = font ;}/*--------------------------------------------------------------------------*\| Function: addEmptyTableMsg| Purpose:  function adds a message which will be displayed when table empty| Input:    msg    - message to be displayed| Output:   | Return:   \*--------------------------------------------------------------------------*/function addEmptyTableMsg ( msg ){  var index = getTableIndexByID ( current_table_id ) ;  if ( index >= 0 )    appendToArray ( tables[index].emptyMsgs , msg ) ;}/*--------------------------------------------------------------------------*\| Function: addTableRow| Purpose:  function adds a row to a table| Input:    function gets undefined number of arguments|           argument[0..] - table data| Output:   | Return:   \*--------------------------------------------------------------------------*/function addTableRow (row_data){  var index = getTableIndexByID ( current_table_id ) ;  if ( index >= 0 )  {    var rows =  tables[index].tableRowsData ;    var row = new TableRow (addTableRow.arguments , rows.length ) ;    appendToArray ( rows , row ) ;  }}/*--------------------------------------------------------------------------*\| Function: addTableTitle| Purpose:  function adds a title to a table| Input:    title    - table title| Output:   | Return:   \*--------------------------------------------------------------------------*/function addTableTitle ( title ){  var index = getTableIndexByID ( current_table_id ) ;  if ( index >= 0 )  {    tables[index].tableTitle = title ;  }}/*--------------------------------------------------------------------------*\| Function: addShowRowCB| Purpose:  function adds a "IsShowRow" cb function| Input:    cb_func    - callback function which will be called|           data1      - first data of user|           data2      - second data of user

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?