Class 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:
    1. Create an instance passing an id and an options instance
    2. Call attach() after the data table element was added to the DOM
    3. Call any of the Table methods

    Sample which uses a FooBar as 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/
    • Constructor Detail

    • Method Detail

      • element

        public elemental2.dom.HTMLElement element()
        Specified by:
        element in interface org.jboss.elemento.IsElement<T>
      • attach

        public void attach()
        Initialized the Api instance using the Options given 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:
        attach in interface Attachable
      • show

        public void show()
        Specified by:
        show in interface Table<T>
      • hide

        public void hide()
        Specified by:
        hide in interface Table<T>
      • enableButton

        public void enableButton​(int index,
                                 boolean enable)
        Specified by:
        enableButton in interface Table<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
        Specified by:
        bindForm in interface Table<T>
      • clear

        public void clear()
        Specified by:
        clear in interface Table<T>
      • select

        public void select​(T data)
        Specified by:
        select in interface Table<T>
      • select

        public void select​(T data,
                           Function<T,​String> identifier)
        Selects the row with the specified data.
        Specified by:
        select in interface Table<T>
        Parameters:
        data - the data
        identifier - a function which must return an unique identifier for a given row.
      • update

        public void update​(Iterable<T> data)
        Replaces the existing data with the new one.
        Specified by:
        update in interface Table<T>
        Parameters:
        data - the new data
      • 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.
        Specified by:
        update in interface Table<T>
        Parameters:
        data - the new data
        identifier - a function which must return an unique identifier for a given row. Used to restore the selection after replacing the data.
      • applySecurity

        public void applySecurity​(Map<Integer,​String> buttonConstraints,
                                  org.jboss.hal.meta.security.AuthorisationDecision authorisationDecision)