============
create_table
============

.. js:function:: create_table(container, options) 

**domain**: client 

**language**: javascript

Description
===========

Use ``create_table`` method to create a table that displays records of 
the item dataset.

The behavior of the table is determined by the 
:doc:`paginate <at_paginate>`
attribute of the item. 

When
:doc:`paginate <at_paginate>`
is true, a paginator will be created, that will internally update the item 
dataset when the page is changed.

If the value of 
:doc:`paginate <at_paginate>`
is false, all available records of the item dataset will be displayed in the table.

The table, created by this method is data aware, when you change the dataset, 
these changes are immediately reflected in the table. So you can create a table
and then call the
:doc:`open <m_open>`
method.

The following parameters could be passed to the method:

* ``container`` - a JQuery object that will contain the table, if 
  container length is 0 (no container), the method returns. Before creating 
  the table the application empties the container.

* ``options`` - options that specify the way the table will be displayed. 
  By default, the method uses the
  :doc:`table_options <at_table_options>` that are set in the
  :doc:`View Form Dialog </admin/items/view_form_dialog>` in Application
  Builder when creating the table. The ``options`` attributes take precedence over the
  :doc:`table_options <at_table_options>` attributes.

The ``options`` parameter is an object that may have the same attributes as 
:doc:`table_options <at_table_options>`.

Examples
========

.. code-block:: js

    function on_edit_form_created(item) {
        item.edit_options.width = 1050;
        item.invoice_table.create_table(item.edit_form.find(".edit-detail"),
            {
                height: 400,
                editable_fields: ['quantity'],
                column_width: {"track": "60%"}
            });
    }

See also
========

:doc:`Forms </programming/interface/forms>`

:doc:`Data-aware controls </programming/interface/data_controls>`
