Change title of header by clicking on the header?

Change title of header by clicking on the header?

MichaelECMichaelEC Posts: 23Questions: 9Answers: 0

Hi,

Tried searching around for an answer although didn't find anything that answers my question!

Just wondering if it's possible to change the header title by clicking onto it? I've already used the column.api which sets the header title to a hard-coded value - this isn't what I'm trying to achieve.

I want the user to be able to click on the header and change the text to whatever they wish - is this possible?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,320Questions: 26Answers: 4,773
    Answer ✓

    There is nothing built into Datatables for this. You could use jQuery or some other Javascript method to change the column title. Here is a simple example that changes the first column using jQuery.
    http://live.datatables.net/nokenegi/1/edit

    I added button export to see if Datatables picks up the change and it appears to work.

    How you handle the click and input is up to you and your requirements. Keep in mind that by default all the columns are enabled for sorting which might be confusing if both (sort and input to change title) actions occur. There are options to turn off sorting.

    Kevin

  • MichaelECMichaelEC Posts: 23Questions: 9Answers: 0

    Hi Kthorngren,

    Thanks a lot for the idea & explanation - this will give me enough to go on, cheers!

This discussion has been closed.