Page 1 of 1

Datatable column order

Posted: 19 Jul 2023, 04:08
by Dino
Hi guys,

If I create a dynamic table like this one:

Code: Select all

DefineObjectInstance { 

      className          = "DynamicTable", 
      name               = "Empleados",   
      source             = "sql", 
      selectSQLcommand   = "EMPNO,SURNAME,GIVENAME,SALARY from G14RHOLIB.PSLMST", 
      resultColumnNames  = { "ID", "Apellido", "Nombre", "Salario" }, 

    }; 
then add the datatable in a panel, the columns are in a different order.

I notice that if use numbers in the order property it changes the order of the columns, but still
seems random....

Code: Select all

ENV.returnValue = [1,2,3,4];
any idea how to select the order of the columns for a datatable?
I am chasing the right order alternating numbers, but not getting there... a refresh and the order
is gone...
datatableorder.jpg
datatableorder.jpg (338.68 KiB) Viewed 21747 times
datatableorder2.jpg
datatableorder2.jpg (225.62 KiB) Viewed 21746 times

Re: Datatable column order

Posted: 02 Aug 2023, 11:29
by jeanmichel
Hi Raul,

I have been looking into this issue for you.

The purpose of the "order" property is not to define in which order to show the columns. It is used to define the sort of the data inside the column, as per the datatables documentation.

In order to arrange the columns you would need to set the property columnNames as below.
ENV.returnValue = [{title: 'ID'},
{title: 'Apellido'},
{title: 'Nombre'},
{title: 'Salario'}];
By changing the order above you can arrange the columns of the datatable.

Re: Datatable column order

Posted: 02 Aug 2023, 22:53
by Dino
Thank you Jeanmichel! that solves it.