Customization of column button text
Customization of column button text

Hi,
I have a DataTable which have a Show/Hide button. The columns buttons are displayed 1,2,3,4,5,6,7 .
I wanted to custom text the column button. How to achieve this?
Every button should display a different text.
"buttons" : [
{
extend : 'colvis',
text : '<i class="colvis" style="font-size:09px">Show / Hide</i>',
titleAttr : 'Show/Hide',
columns : [ 1, 2, 3, 4, 5, 6, 7 ]
}
]
Thanks.
This question has accepted answers - jump to:
Answers
This example here should get you going, it's showing how to do that,
Colin
Currently my column button picks up the text from the header columns. I dont want the header to appear in the column button text. It should be entirely different. Should be something like this for ex
{"xxx","hhh","rft", "fgv", "rtee", "tredcm", "gfor"}
Instead of
return (idx+1)+': '+title;
shown in the example Colin linked to you will need to return something that matches your logic for choosing the name.Kevin
ok ..I got it..Thanks
I understood what to do. I wrote the following code.
But the text is still not displayed. What mistake am I making here?
]
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Is it working with your last code snippet?
Kevin
My code snippet works
But ts always the default header text which appears on column button
with or without "columnText".
There are 22 columns in my datatable and only 7 column buttons appear on show/Hide and they function as expected. columns : [ 1, 2, 3, 4, 5, 6, 7 ]
Is any css /js missing in my path?
I'm confused.
Maybe I'm not understanding the problem. I took your code and built this test case:
http://live.datatables.net/welovopu/1/edit
Does the test case work as you want? If not what do you want to change?
Kevin
Thanks Colin and Kthorngren. Your example really helped. I realised specific css and js were missing in my classpath. It's working now. Appreciate your help so much.