Responsive modal display : adding a class (css) and/or changing the HTML default markup
Responsive modal display : adding a class (css) and/or changing the HTML default markup
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
Hi,
I want to add a class to this render and the default H2 created for the header of the responsive modal display.
I've tried this but, it creates **H2 my returned content /H2* after the default H2
display: DataTable.Responsive.display.modal({
header: function (row) {
var data = row.data();
return '<h2 class="txt-center MT">Projet ' + data['societe'] + '</h2><hr>'; // test
}
})
I know I can change the CSS but the best solution for me is to create all the HTML markup.
For example, not using H2.
Sometimes, I will need to have text and images in the header area of the modal display. If I could have control on everything and delete the default H2, it would be nice.
Thank you
This question has accepted answers - jump to:
Answers
This example states this:
If you don't want the header the responsive adds then don't specify the
header
option. Useresponsive.details.renderer
to display both the header you desire along with the responsive data. Something like this:https://live.datatables.net/xoroluje/1/edit
Kevin
Thanks Kevin.
My problem is that I choose to use the Modal display to create a « fake details page » of my record and I didn't use the automatic renderer for the details infos because I need some adaptations, change the order, etc.
With my JS level, I'm confused with the usage of return, so I don't know how to create multiple returns (maybe the concept is 1 function = 1 return, so I need to create other function).
Here's my WIP modal details return code.
I'm still looking for how to add infos before and after my table inside the return.
For example :
- first a title like the one in the header option (including data infos)
- the table with most of the data
- after the table, a long text (from the data) and a images (from the data)
Can you include the before and after in the return from the rendering function. For example.
Regarding the multiple returns - do you mean the
return
inside themap
function that Kevin used? That's inside another (anonymous) function, which is how that is allowed to work (apologies if that is already clear).Allan
Wow, you just changed my life Allan !
Thank you for the example
I was talking about
return
in general.Strangely, the example with the
map
function was clear for me.I'm reading a lot on this website and on W3C school (or results from search on the web) but I did't find the perfect doc to learn JS / jQuery
W3C School is nice, but i wish, they had more complex examples.
In general, you can have as many
return
statements as you want in a function. Its just that the first one that the browser hits in the execution will be the one that is actually used. So:is valid Javascript, just redundant - that function will only ever return
1
. Multiple returns really come into their own when combined with flow control logic - i.e.if
etc.I like the Khan Academy stuff for learning. Still plenty to learn for me as well!
Allan
Thanks Allan for the explanations and the Khan Academy website, looks like a good source of knowledges.
Sometimes, I think I'm missing things because english is not my first language and I didn't really learn english