Package org.jboss.hal.ballroom.table
Class DataTable<T>
- java.lang.Object
-
- org.jboss.hal.ballroom.table.DataTable<T>
-
- Type Parameters:
T- the row type
- All Implemented Interfaces:
org.jboss.elemento.IsElement,Attachable,Table<T>
public class DataTable<T> extends Object implements Table<T>
Table element which implements the DataTables plugin for jQuery. Using the data table consists of these steps:- Create an instance passing an id and an options instance
- Call
attach()after the data table element was added to the DOM - Call any of the
Tablemethods
Sample which uses a
FooBaras the row type:class FooBar { final String foo; final String bar; FooBar() { this.foo = "Foo-" + String.valueOf(Random.nextInt(12345)); this.bar = "Bar-" + String.valueOf(Random.nextInt(12345)); } } Options<FooBar> options = new OptionsBuilder<FooBar>() .button("Click Me", (table) -> Window.alert("Hello")) .column("foo", "Foo", (cell, type, row, meta) -> row.foo) .column("bar", "Bar", (cell, type, row, meta) -> row.baz) .options(); DataTable<FooBar> dataTable = new DataTable<>("sample", options);- See Also:
- https://datatables.net/
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.hal.ballroom.table.Table
Table.SelectionChangeHandler<T>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplySecurity(Map<Integer,String> buttonConstraints, org.jboss.hal.meta.security.AuthorisationDecision authorisationDecision)voidattach()Initialized theApiinstance using theOptionsgiven at constructor argument.voidbindForm(Form<T> form)Binds a form to the table and takes care to view or clear the form upon selection changesvoidbindForms(Iterable<Form<T>> forms)voidclear()elemental2.dom.HTMLElementelement()voidenableButton(int index, boolean enable)List<T>getRows()voidhide()voidonSelectionChange(Table.SelectionChangeHandler<T> handler)voidselect(T data)voidselect(T data, Function<T,String> identifier)Selects the row with the specified data.TselectedRow()List<T>selectedRows()voidshow()voidupdate(Iterable<T> data)Replaces the existing data with the new one.voidupdate(Iterable<T> data, Function<T,String> identifier)voidupdate(Iterable<T> data, RefreshMode mode)voidupdate(Iterable<T> data, RefreshMode mode, Function<T,String> identifier)Replaces the existing data with the new one.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.hal.ballroom.Attachable
detach
-
Methods inherited from interface org.jboss.hal.ballroom.table.Table
hasSelection
-
-
-
-
Method Detail
-
element
public elemental2.dom.HTMLElement element()
- Specified by:
elementin interfaceorg.jboss.elemento.IsElement<T>
-
attach
public void attach()
Initialized theApiinstance using theOptionsgiven at constructor argument. Make sure to call this method before using any of the API methods. It's safe to call the methods multiple times (the initialization will happen only once).- Specified by:
attachin interfaceAttachable
-
enableButton
public void enableButton(int index, boolean enable)- Specified by:
enableButtonin interfaceTable<T>
-
bindForm
public void bindForm(Form<T> form)
Binds a form to the table and takes care to view or clear the form upon selection changes
-
onSelectionChange
public void onSelectionChange(Table.SelectionChangeHandler<T> handler)
- Specified by:
onSelectionChangein interfaceTable<T>
-
selectedRow
public T selectedRow()
- Specified by:
selectedRowin interfaceTable<T>
-
selectedRows
public List<T> selectedRows()
- Specified by:
selectedRowsin interfaceTable<T>
-
select
public void select(T data, Function<T,String> identifier)
Selects the row with the specified data.
-
update
public void update(Iterable<T> data, RefreshMode mode)
-
update
public void update(Iterable<T> data, RefreshMode mode, Function<T,String> identifier)
Replaces the existing data with the new one. If necessary, restores the current selection based on the specified function.
-
-