Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding column to datatables
    primarykey
    data
    text
    <p>im using Zend and Datatables (jQuery Plugin). I have a table like that:</p> <pre><code>&lt;table width="100%" cellpadding="0" cellspacing="0" border="0" class="display" id="customerTable"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;&lt;?php $this-&gt;trans('ID') ?&gt;&lt;/th&gt; &lt;th&gt;&lt;?php $this-&gt;trans('Name') ?&gt;&lt;/th&gt; &lt;th&gt;&lt;?php $this-&gt;trans('Comment') ?&gt;&lt;/th&gt; &lt;th&gt;&lt;?php $this-&gt;trans('Options') ?&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;/tbody&gt; &lt;tfoot&gt; &lt;tr&gt; &lt;th&gt;&lt;?php $this-&gt;trans('ID') ?&gt;&lt;/th&gt; &lt;th&gt;&lt;?php $this-&gt;trans('Name') ?&gt;&lt;/th&gt; &lt;th&gt;&lt;?php $this-&gt;trans('Comment') ?&gt;&lt;/th&gt; &lt;th&gt;&lt;?php $this-&gt;trans('Options') ?&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/tfoot&gt; &lt;/table&gt; </code></pre> <p>I'm creating my array like that:</p> <pre><code>public function jsonAction() { $this-&gt;_helper-&gt;layout-&gt;disableLayout(); $albums = new Application_Model_DbTable_Customers(); $albums = $albums-&gt;fetchAll()-&gt;toArray(); foreach($albums as $entry) { $x[] = array($entry['id'], $entry['name'], $entry['comment'], ''); } $this-&gt;view-&gt;json = json_encode(array("aaData" =&gt; $x)); } </code></pre> <p>As you see, im creating an array which i encode to json afterwards. For the Options field, i just added ''.</p> <p>In the Options field, i want some edit icons etc. How can i get to that easily? Somehow, this solution doesn't seem to be as nice as it could be.</p> <p>I'm thinking of something like, predefined my table without the option fields. So my JSON matches it. Then, do something like:</p> <pre><code>$('#myTable').datatables({ 'optionsColumn' : {path/to/icon.jpg, /url/it/calls, second icon etc} }); </code></pre> <p>Or just something like addColumn(HTML) which gets repeated for every entry. I don't want to put HTML into my action, and adding it afterwards via JS sucks also.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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