Datatable: Hassle with hidden columns on empty table(cspan)

jQuery UI Widgets
Post Reply
BuckRogers
Posts: 4
Joined: 23 Sep 2016, 10:42

23 Sep 2016, 11:03

Hi all,

first of all: Thanks for the awesome work on the prime projects. I like it very much and after evaluation of many jquery plugins for our software, we decided to use prime ui.

Sometimes we load data but won't expose it to user. That's why a hidden column is convenient somehow. When you hide columns and the datatable is empty, the td colspan for emptyMessage is calculated with the amount of header columns regardless the hidden state. So it looks a bit weird after that. I have to find a workaround to overwrite a colspan value where hidden columns are subtracted. I don't like to hack around in prime-ui libraries, so I think I will just fire a another function to set the colspan on empty table.

1. Are there already any implementations for that kind of problem?

As it is possible to set styles for columns, rows etc., this is useful to hide something via css. It could be very convenient to have a column property to set a column to hidden. Prime-ui could take this into account and calculates subsequent colspans accordingly.

regards

Buck

BuckRogers
Posts: 4
Joined: 23 Sep 2016, 10:42

29 Sep 2016, 12:23

SOLUTION:

Following works perfect in my case:

Code: Select all

 columns: [
        {field: 'id', headerText: '', headerStyle: 'display:none', bodyStyle: 'display:none'},
        {field: 'name', headerStyle: 'width: 50%' ,headerText: '<fmt:message key="component.attachment.table.header.name"/>'},
        {field: 'type', headerStyle: 'width: 20%' ,headerText: '<fmt:message key="component.attachment.table.header.type"/>'},
        {field: 'created', headerStyle: 'width: 20%', headerText: '<fmt:message key="component.attachment.table.header.created"/>'},
        {field: 'size', headerStyle: 'width: 10%', headerText: '<fmt:message key="component.attachment.table.header.size"/>'}
      ],
Description:
First column is set to both header and body style diplay none, so it is not shown.
The other columns are styled with width percentage. All columns to show have a sum of width 100%.

Post Reply

Return to “PrimeUI”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests