Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>According to <a href="http://api.jquery.com/insertBefore/" rel="nofollow">http://api.jquery.com/insertBefore/</a></p> <p>you want this:</p> <pre><code>$('#example thead tr').each( function () { $(nCloneTh).insertBefore(this.childNodes[0]); }); </code></pre> <p>although maybe the more "jQuery" way to do this would be:</p> <pre><code>$('#example thead tr').prepend(nCloneTh); //untested but should work </code></pre> <p><strong>EDIT</strong>:</p> <p>OK, the only real difference I see in his example vs. yours is that he's appending the "row-expander" td's before initializing dataTables.</p> <p>I'm not sure what your JSON input looks like, but this is how I do mine (I'll try to make it somewhat generic):</p> <pre><code>aoColumns: [{ mDataProp: 'Id', sClass: 'center', bUseRendered: false, fnRender: function (o) { return '&lt;img src="media/open.png" class="row-expander" alt="" /&gt;'; } }, { mDataProp: 'NoteCount', sClass: 'center', bUseRendered: false, fnRender: function (o) { return String.format('&lt;img src="media/blue/{0}.png" alt="" class="notes-count" /&gt;', o.aData.NoteCount); } }, { mDataProp: 'Name', bUseRendered: false, fnRender: function (o) { return String.format('&lt;a href="./MyObjHome.aspx?ID={1}"&gt;{0}&lt;/a&gt;', o.aData.Name, o.aData.Id); } }, // add more columns ] </code></pre> <p>This way you don't need to mess around with adding the extra cells every time the table re-renders... the internals of dataTables will handle your 'fake' column which only exists to hold an image for the expansion state.</p> <p>This gets a bit trickier if you are using a 2D array rather than an array of objects. My data source for the above example looks something like:</p> <pre><code>[{ Id: some-guid, Name: 'My Object Name', NoteCount: 4 }, { Id: some-guid-2, Name: 'My Second Name', NoteCount: 10 }] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload