DataGrid vs Table

Hi,
I am beginner. I can’t understand why there are two components DataGrid and Table, when should I use Table and when DataGrid ?

DataGrid, similarly to the Table component, is designed to display and sort tabular data and provides means to manipulate rows and columns with greater performance due to lazy loading of data while scrolling.

In addition to this, DataGrid has the following features:

  • Inline Editor
  • Details Generator
  • Advanced configuration of Header and Footer
  • Frozen columns

However, there are no GroupDataGrid and TreeDataGrid implementations right now (but Table has).

So, there is no answer what should you use, it all depends on actual needs.

3 Likes

Thanks Gleb,
Grouping is a function much used from us, together all feature of DataGrid , so should be a great feature to add on DataGrid

Unfortunately, the issue I asked to open back in September last year is not planned yet: Add an ability to group columns in DataGrid · Issue #564 · cuba-platform/cuba · GitHub

I think DataGrid won’t see grouping any soon. Maybe after the 7.0 release there will be some major re-working on base components, but we should wait till the end of this year, or the first months of 2019.

My suggestion, for the time being, is to follow one of these approaches:

  • Stick with base Table components, and only use DataGrid sparingly where it is absolutely needed (for example, you need to customise the row details to create a sort of “card view” for some records)
  • Stick with DataGrid pretty much everywhere, and only use TreeTable when you need a tree-like representation of your data (I think tree data support will come much later than grouping for DataGrid). In this case, you postpone grouping-ability until introduction in the next months

Both approaches are valid, but I personally think the second one could prove to be more future-proof (DataGrid has more chances to become THE de-facto component for data browsing).

Paolo

3 Likes

I would also note the FIlter components only works with tables

This is incorrect. The Filter component works both with DataGrid and Table.

Regards,
Gleb

Just an FYI. From the screen designer, when setting the “applyTo” property of the Filter it did not provide the datagrid id as an option. But it did provide a table’s id. I assumed from that the datagrid was not compatible but I did not test. But good to know.

applyTo − optional attribute, contains the identifier of a component associated with the filter. It is used when access to related component presentations is required. For example, when saving the filter as a search folder or as an application folder, the presentation that will be applied when browsing this folder can be specified.

Since DataGrid doesn’t support presentations, it can’t be assigned to the applyTo attribute.

Regards,
Gleb

Hi Gorelov,

I need help in saving data in DataGrid. Would be great if you can share a sample code for saving data on Create and Edit actions. Data gets deleted in the dataGrid with Remove action but why it doesn’t work for Create and Edit.

Thanks in advance.

Regards,
Shahid