Get column name

Get column name

david.papinidavid.papini Posts: 21Questions: 5Answers: 0

Hi, i need to retrieve the column name by index. I use DataTable version 1.10.18

Can you help me?

Answers

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    The column().header() API can be used for this.

    Kevin

  • david.papinidavid.papini Posts: 21Questions: 5Answers: 0

    Thank you, but so i've the title or description of my column.

    I need the name that i wrote into columndef of my datatatable

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    Are you saying you used columns.name? If so the docs show how to refer to it in the Datatables API's.

    Kevin

  • david.papinidavid.papini Posts: 21Questions: 5Answers: 0

    i find it, i used column(index).dataSrc()

  • david.papinidavid.papini Posts: 21Questions: 5Answers: 0
    edited March 2020

    i' ve another question.
    i load datatable with

        var d = JSON.parse(data);
        console.log(d);
    
        var t = d[0].ListinoCollection.filter(function (e) {
            return e.IsOrdinabile;
        }
        );
    
        arrDtOrineFornitore = t.slice();
    
        return d[0].ListinoCollection.filter(function (e) {
            return e.IsOrdinabile;
        }
        );
    

    i hope that arrDtOrineFornitore is indipendent from datatable modify, but when i do

                this.cell(this.index(), col[i]).data(5);
    

    i found the relative column into array modified.

    help

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    I'm not following that, sorry. Please could you create a test case to demonstrate it. 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

This discussion has been closed.