UNPKG

carbon-components-angular

Version:
1,688 lines 65.6 kB
<!doctype html>
<html class="no-js" lang="">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title>carbon-components-angular documentation</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <link rel="icon" type="image/x-icon" href="../images/favicon.ico">
	   <link rel="stylesheet" href="../styles/style.css">
        <link rel="stylesheet" href="../styles/dark.css">
    
	<style>
		footer.carbon {
			position: absolute;
			bottom: 0;
			width: 100%;
			z-index: 9999;
		}
		#root > div {
			/*
			 * Subtracting the height of the footer to prevent
			 * overlaying the footer ontop of content
			 */
			height: calc(100vh - 48px);
		}
	</style>
</head>
    <body>
          <script>
               // Blocking script to avoid flickering dark mode
               // Dark mode toggle button
               var useDark = window.matchMedia('(prefers-color-scheme: dark)');
               var darkModeState = useDark.matches;
               var $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input');
               var $darkModeToggles = document.querySelectorAll('.dark-mode-switch');
               var darkModeStateLocal = localStorage.getItem('compodoc_darkmode-state');

               function checkToggle(check) {
                    for (var i = 0; i < $darkModeToggleSwitchers.length; i++) {
                         $darkModeToggleSwitchers[i].checked = check;
                    }
               }

               function toggleDarkMode(state) {
                    if (window.localStorage) {
                         localStorage.setItem('compodoc_darkmode-state', state);
                    }

                    checkToggle(state);

                    const hasClass = document.body.classList.contains('dark');

                    if (state) {
                         for (var i = 0; i < $darkModeToggles.length; i++) {
                              $darkModeToggles[i].classList.add('dark');
                         }
                         if (!hasClass) {
                              document.body.classList.add('dark');
                         }
                    } else {
                         for (var i = 0; i < $darkModeToggles.length; i++) {
                              $darkModeToggles[i].classList.remove('dark');
                         }
                         if (hasClass) {
                              document.body.classList.remove('dark');
                         }
                    }
               }

               useDark.addEventListener('change', function (evt) {
                    toggleDarkMode(evt.matches);
               });
               if (darkModeStateLocal) {
                    darkModeState = darkModeStateLocal === 'true';
               }
               toggleDarkMode(darkModeState);
          </script>

        <div class="navbar navbar-default navbar-fixed-top d-md-none p-0">
               <div class="d-flex">
                    <a href="../" class="navbar-brand">carbon-components-angular documentation</a>
                    <button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
               </div>
        </div>

        <div class="xs-menu menu" id="mobile-menu">
                <div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div>            <compodoc-menu></compodoc-menu>
        </div>

        <div class="container-fluid main">
           <div class="row main">
               <div class="d-none d-md-block menu">
                   <compodoc-menu mode="normal"></compodoc-menu>
               </div>
               <!-- START CONTENT -->
               <div class="content class">
                   <div class="content-data">












<ol class="breadcrumb">
  <li class="breadcrumb-item">Classes</li>
  <li class="breadcrumb-item" >TableDomAdapter</li>
</ol>

<ul class="nav nav-tabs" role="tablist">
        <li class="nav-item">
            <a href="#info" 
                class="nav-link"
                class="nav-link active"
                role="tab" id="info-tab" data-bs-toggle="tab" data-link="info">Info</a>
        </li>
        <li class="nav-item">
            <a href="#source" 
                class="nav-link"
                
                role="tab" id="source-tab" data-bs-toggle="tab" data-link="source">Source</a>
        </li>
</ul>

<div class="tab-content">
    <div class="tab-pane fade active in" id="info">
        <p class="comment">
            <h3>File</h3>
        </p>
        <p class="comment">
            <code>src/table/table-adapter.class.ts</code>
        </p>


            <p class="comment">
                <h3>Description</h3>
            </p>
            <p class="comment">
                <p>A concrete implementation of <code>TableAdapter</code></p>
<p>Provides standard and consistent access to table cells and rows</p>

            </p>


            <p class="comment">
                <h3>Implements</h3>
            </p>
            <p class="comment">
                            <code><a href="../classes/TableAdapter.html" target="_self" >TableAdapter</a></code>
            </p>


            <section data-compodoc="block-index">
    <h3 id="index">Index</h3>
    <table class="table table-sm table-bordered index-table">
        <tbody>
                <tr>
                    <td class="col-md-4">
                        <h6><b>Properties</b></h6>
                    </td>
                </tr>
                <tr>
                    <td class="col-md-4">
                        <ul class="index-list">
                            <li>
                                    <span class="modifier">Public</span>
                                <a href="#tableElement" >tableElement</a>
                            </li>
                        </ul>
                    </td>
                </tr>

                <tr>
                    <td class="col-md-4">
                        <h6><b>Methods</b></h6>
                    </td>
                </tr>
                <tr>
                    <td class="col-md-4">
                        <ul class="index-list">
                            <li>
                                    <span class="modifier">Protected</span>
                                <a href="#findCell" >findCell</a>
                            </li>
                            <li>
                                    <span class="modifier">Protected</span>
                                <a href="#findCellInColumn" >findCellInColumn</a>
                            </li>
                            <li>
                                    <span class="modifier">Protected</span>
                                <a href="#findCellInRow" >findCellInRow</a>
                            </li>
                            <li>
                                <a href="#findColumnIndex" >findColumnIndex</a>
                            </li>
                            <li>
                                <a href="#findIndex" >findIndex</a>
                            </li>
                            <li>
                                <a href="#findRowIndex" >findRowIndex</a>
                            </li>
                            <li>
                                <a href="#getCell" >getCell</a>
                            </li>
                            <li>
                                <a href="#getColumn" >getColumn</a>
                            </li>
                            <li>
                                    <span class="modifier">Protected</span>
                                <a href="#getRealRowLength" >getRealRowLength</a>
                            </li>
                            <li>
                                <a href="#getRow" >getRow</a>
                            </li>
                        </ul>
                    </td>
                </tr>





                    <tr>
                        <td class="col-md-4">
                            <h6><b>Accessors</b></h6>
                        </td>
                    </tr>
                    <tr>
                        <td class="col-md-4">
                            <ul class="index-list">
                                <li>
                                    <a href="#lastColumnIndex" >lastColumnIndex</a>
                                </li>
                                <li>
                                    <a href="#lastRowIndex" >lastRowIndex</a>
                                </li>
                            </ul>
                        </td>
                    </tr>
        </tbody>
    </table>
</section>

            <section data-compodoc="block-constructor">
    <h3 id="constructor">Constructor</h3>
        <table class="table table-sm table-bordered">
            <tbody>
                <tr>
                    <td class="col-md-4">
<code>constructor(tableElement: HTMLTableElement)</code>
                    </td>
                </tr>
                        <tr>
                            <td class="col-md-4">
                                <div class="io-line">Defined in <a href="" data-line="116" class="link-to-prism">src/table/table-adapter.class.ts:116</a></div>
                            </td>
                        </tr>

                <tr>
                    <td class="col-md-4">
                            <div class="io-description"><p><code>TableDomAdapter</code> works on a normal HTML table structure.
Custom tables that don&#39;t follow the standard structure should use a custom implementation of <code>TableAdapter</code>.</p>
<p>The standard structure allows us to directly query rows for cells and indexes - though we do have to handle colspans specially.</p>
</div>
                            <div>
                                    <b>Parameters :</b>
                                    <table class="params">
                                        <thead>
                                            <tr>
                                                <td>Name</td>
                                                    <td>Type</td>
                                                <td>Optional</td>
                                                    <td>Description</td>
                                            </tr>
                                        </thead>
                                        <tbody>
                                                <tr>
                                                        <td>tableElement</td>
                                                  
                                                        <td>
                                                                    <code>HTMLTableElement</code>
                                                        </td>
                                                  
                                                    <td>
                                                            No
                                                    </td>
                                                    
                                                        <td>
                                                                <p>the root HTML table element.</p>

                                                        </td>
                                                </tr>
                                        </tbody>
                                    </table>
                            </div>
                    </td>
                </tr>
            </tbody>
        </table>
</section>

            <section data-compodoc="block-properties">
    
    <h3 id="inputs">
        Properties
    </h3>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="tableElement"></a>
                    <span class="name">
                            <span class="modifier">Public</span>
                        <span ><b>tableElement</b></span>
                        <a href="#tableElement"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
                <tr>
                    <td class="col-md-4">
                        <i>Type : </i>    <code>HTMLTableElement</code>

                    </td>
                </tr>
                    <tr>
                        <td class="col-md-4">
                                <div class="io-line">Defined in <a href="" data-line="126" class="link-to-prism">src/table/table-adapter.class.ts:126</a></div>
                        </td>
                    </tr>

            <tr>
                <td class="col-md-4">
                    <div class="io-description">the root HTML table element.</div>
                </td>
            </tr>

        </tbody>
    </table>
</section>

            <section data-compodoc="block-methods">
    
    <h3 id="methods">
        Methods
    </h3>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="findCell"></a>
                    <span class="name">
                            <span class="modifier">Protected</span>
                        <span ><b>findCell</b></span>
                        <a href="#findCell"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>findCell(cells: HTMLTableCellElement[], targetIndex: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>, spanDirection: <a href="../undefineds/TableDomSpanDirection.html" target="_self">TableDomSpanDirection</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="295"
                                    class="link-to-prism">src/table/table-adapter.class.ts:295</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">
                        <div class="io-description"><p>Finds a cell and it&#39;s real index given an array of cells, a target index, and the spanning direction</p>
</div>

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>cells</td>
                                            <td>
                                                        <code>HTMLTableCellElement[]</code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>An array of cells to search</p>

                                            </td>
                                        </tr>
                                        <tr>
                                                <td>targetIndex</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>The index we think the cell is located at</p>

                                            </td>
                                        </tr>
                                        <tr>
                                                <td>spanDirection</td>
                                            <td>
                                                            <code><a href="../miscellaneous/enumerations.html#TableDomSpanDirection" target="_self" >TableDomSpanDirection</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>The direction of the cell spans. Should be <code>&quot;colSpan&quot;</code> for a row and <code>&quot;rowSpan&quot;</code> for a column</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>{ cell: any; realIndex: number; }</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="findCellInColumn"></a>
                    <span class="name">
                            <span class="modifier">Protected</span>
                        <span ><b>findCellInColumn</b></span>
                        <a href="#findCellInColumn"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>findCellInColumn(col: HTMLTableCellElement[], index: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="332"
                                    class="link-to-prism">src/table/table-adapter.class.ts:332</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">
                        <div class="io-description"><p>Helper method around <code>findCell</code>, searches based on a column of cells</p>
</div>

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>col</td>
                                            <td>
                                                        <code>HTMLTableCellElement[]</code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>the column of elements to search</p>

                                            </td>
                                        </tr>
                                        <tr>
                                                <td>index</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>the index of the element</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>{ cell: any; realIndex: number; }</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="findCellInRow"></a>
                    <span class="name">
                            <span class="modifier">Protected</span>
                        <span ><b>findCellInRow</b></span>
                        <a href="#findCellInRow"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>findCellInRow(row: HTMLTableCellElement[], index: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="322"
                                    class="link-to-prism">src/table/table-adapter.class.ts:322</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">
                        <div class="io-description"><p>Helper method around <code>findCell</code>, searches based on a row of cells</p>
</div>

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>row</td>
                                            <td>
                                                        <code>HTMLTableCellElement[]</code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>the row of elements to search</p>

                                            </td>
                                        </tr>
                                        <tr>
                                                <td>index</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>the index of the element</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>{ cell: any; realIndex: number; }</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="findColumnIndex"></a>
                    <span class="name">
                        <span ><b>findColumnIndex</b></span>
                        <a href="#findColumnIndex"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
<code>findColumnIndex(cell: HTMLTableCellElement)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="192"
                                    class="link-to-prism">src/table/table-adapter.class.ts:192</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">
                        <div class="io-description"><p>Finds the column index of a given cell</p>
</div>

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>cell</td>
                                            <td>
                                                        <code>HTMLTableCellElement</code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>the cell to search for</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>        <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="findIndex"></a>
                    <span class="name">
                        <span ><b>findIndex</b></span>
                        <a href="#findIndex"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
<code>findIndex(cell: HTMLTableCellElement)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="271"
                                    class="link-to-prism">src/table/table-adapter.class.ts:271</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">
                        <div class="io-description"><p>Finds the row and column index of a given cell</p>
</div>

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>cell</td>
                                            <td>
                                                        <code>HTMLTableCellElement</code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>the cell to search for</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="findRowIndex"></a>
                    <span class="name">
                        <span ><b>findRowIndex</b></span>
                        <a href="#findRowIndex"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
<code>findRowIndex(cell: HTMLTableCellElement)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="257"
                                    class="link-to-prism">src/table/table-adapter.class.ts:257</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">
                        <div class="io-description"><p>Finds the row index of a given cell</p>
</div>

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>cell</td>
                                            <td>
                                                        <code>HTMLTableCellElement</code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>the cell to search for</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>        <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getCell"></a>
                    <span class="name">
                        <span ><b>getCell</b></span>
                        <a href="#getCell"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
<code>getCell(row: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>, column: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="134"
                                    class="link-to-prism">src/table/table-adapter.class.ts:134</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">
                        <div class="io-description"><p>Returns a cell from the table taking colspans in to account.</p>
</div>

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>row</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>index of the row</p>

                                            </td>
                                        </tr>
                                        <tr>
                                                <td>column</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>index of the column</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>HTMLTableCellElement</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getColumn"></a>
                    <span class="name">
                        <span ><b>getColumn</b></span>
                        <a href="#getColumn"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
<code>getColumn(column: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="147"
                                    class="link-to-prism">src/table/table-adapter.class.ts:147</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">
                        <div class="io-description"><p>Returns a column from the table, using the <code>id</code> and <code>headers</code> attributes</p>
<p>See here for more detail these attributes: <a href="https://www.w3.org/TR/WCAG20-TECHS/H43.html">https://www.w3.org/TR/WCAG20-TECHS/H43.html</a></p>
</div>

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>column</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>the index of the column</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>    <code>HTMLTableCellElement[]</code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getRealRowLength"></a>
                    <span class="name">
                            <span class="modifier">Protected</span>
                        <span ><b>getRealRowLength</b></span>
                        <a href="#getRealRowLength"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
                        <span class="modifier-icon icon ion-ios-reset"></span>
                    <code>getRealRowLength(row: <a href="../classes/TableRow.html" target="_self">HTMLTableRowElement</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="283"
                                    class="link-to-prism">src/table/table-adapter.class.ts:283</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">
                        <div class="io-description"><p>Helper function that returns the &quot;real&quot; length of a row.
Only accurate with regard to colspans (though that&#39;s sufficient for it&#39;s uses here)</p>
<p>TODO: Take rowSpan into account</p>
</div>

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>row</td>
                                            <td>
                                                            <code><a href="../classes/TableRow.html" target="_self" >HTMLTableRowElement</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>the row to get the length of</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>        <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="table table-sm table-bordered">
        <tbody>
            <tr>
                <td class="col-md-4">
                    <a name="getRow"></a>
                    <span class="name">
                        <span ><b>getRow</b></span>
                        <a href="#getRow"><span class="icon ion-ios-link"></span></a>
                    </span>
                </td>
            </tr>
            <tr>
                <td class="col-md-4">
<code>getRow(row: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code>
                </td>
            </tr>


                    <tr>
                        <td class="col-md-4">
                            <div class="io-line">Defined in <a href="" data-line="183"
                                    class="link-to-prism">src/table/table-adapter.class.ts:183</a></div>
                        </td>
                    </tr>


            <tr>
                <td class="col-md-4">
                        <div class="io-description"><p>Returns a row from the table</p>
</div>

                            <div class="io-description">
                                <b>Parameters :</b>
                                
                                <table class="params">
                                    <thead>
                                        <tr>
                                            <td>Name</td>
                                                <td>Type</td>
                                            <td>Optional</td>
                                                <td>Description</td>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                                <td>row</td>
                                            <td>
                                                            <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
                                            </td>

                                            <td>
                                                    No
                                            </td>


                                            <td>
                                                    <p>index of the row</p>

                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        <div class="io-description">
                            <b>Returns : </b>        <code><a href="../classes/TableRow.html" target="_self" >HTMLTableRowElement</a></code>

                        </div>
                            <div class="io-description">
                                
                            </div>
                </td>
            </tr>
        </tbody>
    </table>
</section>





            <section data-compodoc="block-accessors">
    <h3 id="accessors">
        Accessors
    </h3>
        <table class="table table-sm table-bordered">
            <tbody>
                <tr>
                    <td class="col-md-4">
                        <a name="lastColumnIndex"></a>
                        <span class="name"><b>lastColumnIndex</b><a href="#lastColumnIndex"><span class="icon ion-ios-link"></span></a></span>
                    </td>
                </tr>

                <tr>
                    <td class="col-md-4">
                        <span class="accessor"><b>get</b><code>lastColumnIndex()</code></span>
                    </td>
                </tr>
                            <tr>
                                <td class="col-md-4">
                                    <div class="io-line">Defined in <a href="" data-line="107" class="link-to-prism">src/table/table-adapter.class.ts:107</a></div>
                                </td>
                            </tr>
                    <tr>
                        <td class="col-md-4">
                                <div class="io-description"><p>The last accessible column in the table</p>
</div>

                        </td>
                    </tr>

            </tbody>
        </table>
        <table class="table table-sm table-bordered">
            <tbody>
                <tr>
                    <td class="col-md-4">
                        <a name="lastRowIndex"></a>
                        <span class="name"><b>lastRowIndex</b><a href="#lastRowIndex"><span class="icon ion-ios-link"></span></a></span>
                    </td>
                </tr>

                <tr>
                    <td class="col-md-4">
                        <span class="accessor"><b>get</b><code>lastRowIndex()</code></span>
                    </td>
                </tr>
                            <tr>
                                <td class="col-md-4">
                                    <div class="io-line">Defined in <a href="" data-line="114" class="link-to-prism">src/table/table-adapter.class.ts:114</a></div>
                                </td>
                            </tr>
                    <tr>
                        <td class="col-md-4">
                                <div class="io-description"><p>The last accessible row in the table</p>
</div>

                        </td>
                    </tr>

            </tbody>
        </table>
</section>
    </div>


    <div class="tab-pane fade  tab-source-code" id="source">
        <pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">export abstract class TableCellAdapter {
	/**
	 * The index of the cell in the table
	 */
	cellIndex: number;
	/**
	 * The number of columns spanned by this cell
	 */
	colSpan: number;
	/**
	 * The number of rows spanned by this cell
	 */
	rowSpan: number;
}

/**
 * An abstract class that represents a row in a table
 */
export abstract class TableRowAdapter {
	/**
	 * The index of the row in the table
	 */
	rowIndex: number;
	/**
	 * An array (or &#x60;HTMLCollection&#x60;) of &#x60;TableCellAdapter&#x60;s
	 */
	cells: HTMLCollection | TableCellAdapter[];
}

/**
 * An abstract representation of a table that provides
 * a standard interface to query 2d tables for cell and row information.
 */
export abstract class TableAdapter {
	/**
	 * The last accessible column in the table
	 */
	public get lastColumnIndex(): number { return; }

	/**
	 * The last accessible row in the table
	 */
	public get lastRowIndex(): number { return; }

	/**
	 * Returns a cell from the table
	 *
	 * @param row index of the row
	 * @param column index of the column
	 */
	getCell(row: number, column: number): TableCellAdapter { return; }

	/**
	 * Returns a row from the table
	 *
	 * @param column index of the column
	 */
	getColumn(column: number): TableCellAdapter[] { return; }

	/**
	 * Returns a row from the table
	 *
	 * @param row index of the row
	 */
	getRow(row: number): TableRowAdapter { return; }

	/**
	 * Finds the column index of a given cell
	 *
	 * @param cell the cell to search for
	 */
	findColumnIndex(cell: TableCellAdapter): number { return; }

	/**
	 * Finds the row index of a given cell
	 *
	 * @param cell the cell to search for
	 */
	findRowIndex(cell: TableCellAdapter): number { return; }

	/**
	 * Finds the row and column index of a given cell
	 *
	 * @param cell the cell to search for
	 * @returns a tuple that follows the &#x60;[row, column]&#x60; convention
	 */
	findIndex(cell: TableCellAdapter): [number, number] { return; }
}

enum TableDomSpanDirection {
	colSpan &#x3D; &quot;colSpan&quot;,
	rowSpan &#x3D; &quot;rowSpan&quot;
}

/**
 * A concrete implementation of &#x60;TableAdapter&#x60;
 *
 * Provides standard and consistent access to table cells and rows
 */
export class TableDomAdapter implements TableAdapter {
	/**
	 * The last accessible column in the table
	 */
	public get lastColumnIndex() {
		return this.getRealRowLength(this.tableElement.rows[0]);
	}

	/**
	 * The last accessible row in the table
	 */
	public get lastRowIndex() {
		return this.tableElement.rows.length - 1;
	}

	/**
	 * &#x60;TableDomAdapter&#x60; works on a normal HTML table structure.
	 * Custom tables that don&#x27;t follow the standard structure should use a custom implementation of &#x60;TableAdapter&#x60;.
	 *
	 * The standard structure allows us to directly query rows for cells and indexes - though we do have to handle colspans specially.
	 *
	 * @param tableElement the root HTML table element.
	 */
	constructor(public tableElement: HTMLTableElement) { }

	/**
	 * Returns a cell from the table taking colspans in to account.
	 *
	 * @param row index of the row
	 * @param column index of the column
	 */
	getCell(row: number, column: number): HTMLTableCellElement {
		const col &#x3D; this.getColumn(column);

		return this.findCellInColumn(col, row).cell;
	}

	/**
	 * Returns a column from the table, using the &#x60;id&#x60; and &#x60;headers&#x60; attributes
	 *
	 * See here for more detail these attributes: https://www.w3.org/TR/WCAG20-TECHS/H43.html
	 *
	 * @param column the index of the column
	 */
	getColumn(column: number): HTMLTableCellElement[] {
		const firstHeader &#x3D; Array.from(this.tableElement.rows[0].cells);

		const { cell: header, realIndex: realColumnIndex } &#x3D; this.findCellInRow(firstHeader, column);

		const linkedCells: HTMLTableCellElement[] &#x3D; [];

		for (let i &#x3D; 1; i &lt; this.tableElement.rows.length; i++) {
			const row &#x3D; this.tableElement.rows[i];
			// query for any cells that are linked to the given header id
			// &#x60;~&#x3D;&#x60; matches values in space separated lists - so &#x60;[headers~&#x3D;&#x27;foo&#x27;]&#x60; would match &#x60;headers&#x3D;&quot;foo bar&quot;&#x60; and &#x60;headers&#x3D;&quot;foo&quot;&#x60;
			// but not &#x60;headers&#x3D;&quot;bar&quot;&#x60; or &#x60;headers&#x3D;&quot;bar baz&quot;&#x60;
			const linkedRowCells: NodeListOf&lt;HTMLTableCellElement&gt; &#x3D; row.querySelectorAll(&#x60;[headers~&#x3D;&#x27;${header.id}&#x27;]&#x60;);
			// if we have more than one cell, get the one that is closest to the column
			if (linkedRowCells.length &gt; 1) {
				const { cell } &#x3D; this.findCellInRow(Array.from(linkedRowCells), column - realColumnIndex);
				linkedCells.push(cell);
			} else if (linkedRowCells[0]) {
				linkedCells.push(linkedRowCells[0]);
			}
		}

		// return an empty array if we can&#x27;t find any linked cells
		// returning anything else would be a lie
		if (!linkedCells) {
			return [];
		}

		return [header, ...linkedCells];
	}

	/**
	 * Returns a row from the table
	 *
	 * @param row index of the row
	 */
	getRow(row: number): HTMLTableRowElement {
		return this.tableElement.rows[row];
	}

	/**
	 * Finds the column index of a given cell
	 *
	 * @param cell the cell to search for
	 */
	findColumnIndex(cell: HTMLTableCellElement): number {
		const row &#x3D; this.getRow(this.findRowIndex(cell));
		if (!row) {
			return;
		}
		// if the cell has linked headers we can do a more accurate lookup
		if (cell &amp;&amp; cell.headers) {
			const ids &#x3D; cell.headers.split(&quot; &quot;);
			const headerRows &#x3D; Array.from(this.tableElement.tHead.rows);
			const indexes &#x3D; [];

			// start from the last row and work up
			for (const headerRow of headerRows.reverse()) {
				const headerCells &#x3D; Array.from(headerRow.cells);
				const header &#x3D; headerCells.find(headerCell &#x3D;&gt; ids.includes(headerCell.id));
				// if we have a matching header, find it&#x27;s index (adjusting for colspans)
				if (header) {
					// this is borrowed from below
					let cellIndex &#x3D; 0;
					for (const c of headerCells) {
						if (c &#x3D;&#x3D;&#x3D; header) { break; }
						cellIndex +&#x3D; c.colSpan;
					}
					indexes.push(cellIndex);
				}
			}

			// sort the indexes largest to smallest to find the closest matching header index
			const firstIndex &#x3D; indexes.sort((a, b) &#x3D;&gt; b - a)[0];

			// search the row for cells that share the header
			let similarCells &#x3D; [];
			for (const id of ids) {
				// there&#x27;s no selector that will match two space separated lists,
				// so we have to iterate through the ids and query the row for each
				const rowCells &#x3D; Array.from(row.querySelectorAll(&#x60;[headers~&#x3D;&#x27;${id}&#x27;]&#x60;));
				for (const rowCell of rowCells) {
					// only keep one set of cells
					if (!similarCells.includes(rowCell)) {
						similarCells.push(rowCell);
					}
				}
			}

			// DOM order is not preserved, so we have to sort the row
			similarCells &#x3D; similarCells.sort((a: HTMLTableCellElement, b: HTMLTableCellElement) &#x3D;&gt; a.cellIndex - b.cellIndex);

			// return the header index plus any adjustment within that headers column
			return firstIndex + similarCells.indexOf(cell);
		}

		// fallback if the cell isn&#x27;t linked to any headers
		let cellIndex &#x3D; 0;
		for (const c of Array.from(row.cells)) {
			if (c &#x3D;&#x3D;&#x3D; cell) { break; }
			cellIndex +&#x3D; c.colSpan;
		}
		return cellIndex;
	}

	/**
	 * Finds the row index of a given cell
	 *
	 * @param cell the cell to search for
	 */
	findRowIndex(cell: HTMLTableCellElement): number {
		for (const row of Array.from(this.tableElement.rows)) {
			if (row.contains(cell)) {
				return row.rowIndex;
			}
		}
	}

	/**
	 * Finds the row and column index of a given cell
	 *
	 * @param cell the cell to search for
	 * @returns a tuple that follows the &#x60;[row, column]&#x60; convention
	 */
	findIndex(cell: HTMLTableCellElement): [number, number] {
		return [this.findRowIndex(cell), this.findColumnIndex(cell)];
	}

	/**
	 * Helper function that returns the &quot;real&quot; length of a row.
	 * Only accurate with regard to colspans (though that&#x27;s sufficient for it&#x27;s uses here)
	 *
	 * TODO: Take rowSpan into account
	 *
	 * @param row the row to get the length of
	 */
	protected getRealRowLength(row: HTMLTableRowElement): number {
		// start at -1 since the colspans will sum to 1 index greater than the total
		return Array.from(row.cells).reduce((count, cell) &#x3D;&gt; count + cell.colSpan, -1);
	}

	/**
	 * Finds a cell and it&#x27;s real index given an array of cells, a target index, and the spanning direction
	 *
	 * @param cells An array of cells to search
	 * @param targetIndex The index we think the cell is located at
	 * @param spanDirection The direction of the cell spans. Should be &#x60;&quot;colSpan&quot;&#x60; for a row and &#x60;&quot;rowSpan&quot;&#x60; for a column
	 */
	protected findCell(cells: HTMLTableCellElement[], targetIndex: number, spanDirection: TableDomSpanDirection) {
		// rows/cols can have fewer total cells than the actual table
		// the model pretends all rows/cols behave the same (with col/row spans &gt; 1 being N cells long)
		// this maps that view to the HTML view (col/row spans &gt; 1 are one element, so the array is shorter)
		let realIndex &#x3D; 0;
		// i is only used for iterating the cells
		for (let i &#x3D; 0; i &lt; targetIndex;) {
			// skip the next N cells
			i +&#x3D; cells[realIndex][spanDirection];
			// don&#x27;t bump realIndex if i now exceeds the cell we&#x27;re shooting for
			if (i &gt; targetIndex) { break; }
			// finally, increment realIndex (to keep it generally in step with i)
			realIndex++;
		}

		return {
			cell: cells[realIndex],
			realIndex
		};
	}

	/**
	 * Helper method around &#x60;findCell&#x60;, searches based on a row of cells
	 *
	 * @param row the row of elements to search
	 * @param index the index of the element
	 */
	protected findCellInRow(row: HTMLTableCellElement[], index: number) {
		return this.findCell(row, index, TableDomSpanDirection.colSpan);
	}

	/**
	 * Helper method around &#x60;findCell&#x60;, searches based on a column of cells
	 *
	 * @param col the column of elements to search
	 * @param index the index of the element
	 */
	protected findCellInColumn(col: HTMLTableCellElement[], index: number) {
		return this.findCell(col, index, TableDomSpanDirection.rowSpan);
	}
}
</code></pre>
    </div>
</div>









                   </div><div class="search-results">
    <div class="has-results">
        <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
        <ul class="search-results-list"></ul>
    </div>
    <div class="no-results">
        <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
    </div>
</div>
</div>
               <!-- END CONTENT -->
           </div>
       </div>

          <label class="dark-mode-switch">
               <input type="checkbox">
               <span class="slider">
                    <svg class="slider-icon" viewBox="0 0 24 24" fill="none" height="20" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" width="20" xmlns="http://www.w3.org/2000/svg">
                    <path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"></path>
                    </svg>
               </span>
          </label>

       <script>
            var COMPODOC_CURRENT_PAGE_DEPTH = 1;
            var COMPODOC_CURRENT_PAGE_CONTEXT = 'class';
            var COMPODOC_CURRENT_PAGE_URL = 'TableDomAdapter.html';
            var MAX_SEARCH_RESULTS = 15;
       </script>

       <script>
               $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input');
               checkToggle(darkModeState);
               if ($darkModeToggleSwitchers.length > 0) {
                    for (var i = 0; i < $darkModeToggleSwitchers.length; i++) {
                         $darkModeToggleSwitchers[i].addEventListener('change', function (event) {
                              darkModeState = !darkModeState;
                              toggleDarkMode(darkModeState);
                         });
                    }
               }
          </script>

       <script src="../js/libs/custom-elements.min.js"></script>
       <script src="../js/libs/lit-html.js"></script>

       <script src="../js/menu-wc.js" defer></script>
       <script nomodule src="../js/menu-wc_es5.js" defer></script>

       <script src="../js/libs/bootstrap-native.js"></script>

       <script src="../js/libs/es6-shim.min.js"></script>
       <script src="../js/libs/EventDispatcher.js"></script>
       <script src="../js/libs/promise.min.js"></script>
       <script src="../js/libs/zepto.min.js"></script>

       <script src="../js/compodoc.js"></script>

       <script src="../js/tabs.js"></script>
       <script src="../js/menu.js"></script>
       <script src="../js/libs/clipboard.min.js"></script>
       <script src="../js/libs/prism.js"></script>
       <script src="../js/sourceCode.js"></script>
          <script src="../js/search/search.js"></script>
          <script src="../js/search/lunr.min.js"></script>
          <script src="../js/search/search-lunr.js"></script>
          <script src="../js/search/search_index.js"></script>
       <script src="../js/lazy-load-graphs.js"></script>


    

	<footer class="carbon">
		<dds-footer-container key="footer" disable-locale-button="true" size="micro" />
	</footer>

	<script
		key="8"
		type="module"
		src="https://1.www.s81c.com/common/carbon-for-ibm-dotcom/tag/v1/latest/footer.min.js">
	</script>

	<!-- Storybook override -->
	<script>
		document.title = "Carbon Components Angular";
	</script>

	<script
		src="//1.www.s81c.com/common/stats/ibm-common.js"
		type="text/javascript"
		async="async">
	</script>
</body>
</html>