DataTable column index when table contains hidden columns

DataTable column index when table contains hidden columns

Gabriel23Gabriel23 Posts: 33Questions: 8Answers: 0

I have a column defined in as follows : { "data": "Priority2019", "name": "Priority2019", "visible": false , "autowidth": true },
but I got a small problem, when I am doing filter on columns ( not on the one above obviously cause it is hidden ) data sent to server contains also the hidden columns which messes up my column filters indexes, so for example filter of columns 10 goes to filter columns 11 because of the fact that hidden filter column is also sent in data array . Any workaround about this issue?

Answers

  • Gabriel23Gabriel23 Posts: 33Questions: 8Answers: 0
  • Gabriel23Gabriel23 Posts: 33Questions: 8Answers: 0

    Anyone?

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @gabriel23 ,

    If you have serverSide enabled, then regardless of whether the column is hidden, it will be sent to the server - this needs to happen, as you can still filter on hidden columns.

    If I'm not understanding this and that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • Gabriel23Gabriel23 Posts: 33Questions: 8Answers: 0

    @colin Yes I have serverSide enabled , so disabling it will solve my issue?

  • Gabriel23Gabriel23 Posts: 33Questions: 8Answers: 0

    Is there any way to interact with data object before it goes to server? So I can simply take out the element I do not need ?

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @gabriel23 ,

    Not if you want the server to do your filtering, paging and ordering! If your dataset is small, just set serverSide to false, the client is able to perform these operations efficiently. If you need serverSide, then you just need to ensure your script handles the values being sent - the protocol is discussed here.

    Cheers,

    Colin

  • Gabriel23Gabriel23 Posts: 33Questions: 8Answers: 0

    Well there is a bit of a problem here, because handling filters on serverSide is not a problem , but actually the filters of some columns are offset by 1 because of the column which is hidden, let me give you an example like you have 4 columns and 1 hidden, and they are declared like so :
    {data:column1} {data:column2} {data:column3 is hidden} {data:column4} {data:column5}
    so when you actually send filters you will have a data object with 5 elements but actually, the filter of column 4 will go to filter of column 3 and so on , which is messing up the filters

  • Gabriel23Gabriel23 Posts: 33Questions: 8Answers: 0
  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @Gabriel23 ,

    This here is an example with serverSide and invisible columns - as you can see, the requests are all as expected. Can you modify this example to demonstrate your problem, please.

    Cheers,

    Colin

  • Gabriel23Gabriel23 Posts: 33Questions: 8Answers: 0

    table.ajax.params() is not containing the data object which is sent to server..

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    That's exactly what ajax.params() is showing - it shows the last data sent to the server. You can confirm that by checking the network tab in the developers tools.

  • Gabriel23Gabriel23 Posts: 33Questions: 8Answers: 0

    Ah yes in network tab it shows a little different but yea it's pretty the same but I the table as it is now I think is running well but however my table has a search input below each column name, and I think that data is what messes up but I will pretty delete the column which I don't need as it is permanently hided and will write it back when I will use it

This discussion has been closed.