Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Methods

Vasiliy Zubach edited this page Sep 21, 2013 · 2 revisions

=====

init()

Initialize tTable: insert table / pages / search to their containers, gett needed data and enable listening of proper table events.

Return: tTable

=====

destroy()

Destroy table - remove events and DOM objects.

Return: tTable

=====

get( what )

Get tTable property value.

  • what - property name;

Return: {*}

=====

set( what )

Update you table properties

  • what - object with properties and their values: { property : new_value, ....};

Return: tTable

=====

countPages()

Method that calculates available pages count for filtered and searched data.

Return: number

=====

dataSize()

Method that calculates and return table data size.

Return: number

=====

getData()

Method for getting table data (filtered, searched and cutted to page size). Or if we have ajax per page driven table - it will run AJAX request and then update table with new data;

Return: array

=====

getPageData()

Method for getting data array with table data related to current page.

Return: array

=====

searchData( data, search )

Method for searching data in table that can be associated with search string.

  • data - data in which we are searching for something;
  • search - search string;

Return: array

=====

getSortKey()

Method for getting sorting key. By default it will be column id in human readable format, but if developer defines key property in titles it will return that key value related to proper column id.

Return: string

=====

getSortType()

Method for getting sort_type string ('asc' or 'desc')

Return: string

=====

getSortDataType()

Method for finding sort data type ('string' or 'number') that defined in titles.

Return: string

=====

sortData( data, sort_by, sort_type )

Method for sorting table rows (data) by defined column and sort_type ('asc', 'desc').

  • data - table data. If not defined - get it from the main table object;
  • sort_by - number of sort column;
  • sort_type - sort type ('asc', 'desc');

Return: array

=====

getTotal( column )

Method that calculate total sum of table data in some defined column.

  • column - column id (starts with 1)

Return: number

=====

addRow( row )

Method for adding row to the table.

  • row - array with row data. It will be concatenated with table data array and table will be automatically updated;

Return: tTable

=====

updateRow( update, where )

Method for updating row(s) data

  • update - object with new update data for row(s). Update structure {col_id: 'value'}, col_id here relates to table column id in human readable format (starts with 1);
  • where - object with data that scripts need to find row that will be updated. Where structure {col_id: 'value'}, col_id here relates to table column id in human readable format (starts with 1);

At first scripts goes to data and searches for all rows that are relative to where config. Than it changes all relative to update data

Return: tTable

=====

delRow( where )

Method for deleting row(s) form table data

  • where - object with data that scripts need to find row(s) that will be updated. where structure is {col_id: 'value'}, col_id here relates to table column id in human readable format (starts with 1);

Return: tTable

=====

goto( page )

Method for updating viewport with table data related to defined page number

  • page - page that should be rendered;

Return: tTable