Map columns with data

Map columns with data

RazorbladeRazorblade Posts: 12Questions: 3Answers: 1

Hi everyone,
it is possible to configure the Datatable to have custom position for columns that doesn't respect the order received from the data?
To do an example, if in my remote data I have the 'name' value that is in position 0 ( ZERO ) and I want to render it in my SECOND column (so not the first), can I do it? Which kind of configuration do I need to pass to Datatable?

I currently tried to add this configuration for the 'columns' config key:

"columns": [
{
"data": 1,
"name": "Position"
},
{
"data": 0,
"name": "Name"
},
{
"data": 2,
"name": "Office"
},
{
"data": 3,
"name": "External"
},
{
"data": 4,
"name": "Start date"
},
{
"data": 5,
"name": "Salary"
}
]

But the table still renders the 'name' data in the first column and 'position' in the second.

Thanks in advance for any advice.

Cheers

This question has an accepted answers - jump to answer

Answers

  • RazorbladeRazorblade Posts: 12Questions: 3Answers: 1

    Nevermind,
    my configuration was fine,
    the issue I had was related to a functionality in my code
    that runs just before rendering
    and transform 'conlumns' config entry.

    Cheers

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
    Answer ✓

    As you have found you absolutely can do that with arrays. You might want to consider using objects as a data source in future as it can make thinks much easier to understand.

    Allan

This discussion has been closed.