WTUI Docs

WTUI  1.0.0

WTUI Docs > WTUI > WTUI.DataTable
Search:
 
Filters

Class WTUI.DataTable

A Table for displaying data

Tag

<wtui:datatable/>

The tag for WTUI.DataTable

Example:

<wtui:datatable id="exampleid" datasource="?cmd=getdata">
  <wtui:column key="firstname">First Name</wtui:column>
  <wtui:column>Last Name</wtui:column>
  <wtui:column key="view"></wtui:column>
</wtui:datatable>
Parameters:
id <String> (optional) The id of the datatable
fields <String> The column headings for the table
datasource <String> (optional) The url of where to fetch the data for the table from
perpage <Integer> (optional) The number of rows to display per page
canselectrow <String> (optional) set to yes if rows in the table can be selected
rendercell <Function> (optional) An optional function to cell when rendering a cell in the table
onheadingclick <Funtion> (optional) An optional function to call when a heading is clicked

Methods

getQueryData

void getQueryData ( )

Get the query data from the datasource

Returns: void

getSelectedRows

Array getSelectedRows ( )
Get an array of the indexes of the selected rows
Returns: Array
an array of the indexes of the selected rows

loadData

void loadData ( )

Load a DataTable's data from its datasource

Returns: void

reload

void reload ( )

Reload a datatable's data from its datasource

Returns: void

setData

void setData ( data )

Set the data for a datatable

Example:
var data = [{"First Name": "John", "Last Name": "Smith"},
            {"First Name": "Jane", "Last Name": "Doe"}];
WTUIComponent('datatableid').setData(data);
Parameters:
data <object> (Array) the data
Returns: void

setQueryData

void setQueryData ( data )

Set the query data to be passed to the datasource

Example:
WTUI("datasource").setQueryData({ "keywords": "search for this" });
Parameters:
data <object> (Object) the query data
Returns: void

Events

rendercell

rendercell ( key , data , row )
This event is fired just before a cell in the table is rendered, it can be used to put custom content in the cell
Parameters:
key <String> The key for the column to render
data <Object> The data for the row to render
row <Number> The row number to render

WTUI