<p>There is no sources at the left side of your element index picture.</p>
<p>i think you missed <a href="https://craftcms.com/docs/3.x/extend/element-types.html#sources" rel="nofollow noreferrer">source definition</a> at your element type class:</p>
<p>it can be something simple like:</p>
<pre><code>protected static function defineSources(string $context = null): array
{
    return [
        [
            'key' =&gt; '*',
            'label' =&gt; 'All Items',
            'criteria' =&gt; []
        ],
    ];
}
</code></pre>
<p>those requests are not fired because there is no criteria to pass via request without defining sources.</p>

CC BY-SA 4.0
2021-12-03T06:41:19.527Z
Thanks! One more thing I forgot was defining the query class on the `find` method. (https://craftcms.com/docs/3.x/extend/element-types.html#element-query-class). Without it Craft will just load all elements in the system.
Matanya
CC BY-SA 4.0
2021-12-02T20:38:00.153Z
2021-12-02T20:38:00.153Z
user9975
<p>I am writing a data tables plugin and am currently working on the index page in the CP.</p>
<p>I've followed the instructions <a href="https://craftcms.com/docs/3.x/extend/element-types.html#index-page" rel="nofollow noreferrer">here</a>:</p>
<p>index.twig</p>
<pre><code>{% extends '_layouts/elementindex' %}
{% set title = &quot;DataTables&quot;|t('app')  %}
{% set elementType = 'matfish\\DataTables\\elements\\DataTable' %}

{% block actionButton %}
 &lt;div id=&quot;extra-headers&quot;&gt;
    &lt;div class=&quot;buttons right&quot;&gt;
      &lt;a href=&quot;{{ url('datatables/tables/new') }}&quot; class=&quot;btn submit add icon&quot;&gt;
       {{ &quot;New DataTable&quot;|t('datatables')}}
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
{% endblock %}
</code></pre>
<p>Page is rendered but the table area is empty:
<a href="https://i.sstatic.net/A6fZY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/A6fZY.png" alt="enter image description here" /></a></p>
<p>Table Attributes are defined on element class, and are displayed in dropdown:</p>
<pre class="lang-php prettyprint-override"><code> protected static function defineTableAttributes(): array
    {
        return [
            'title' =&gt; \Craft::t('app', 'Title'),
            'elementType' =&gt; \Craft::t('datatables', 'Element Type'),
            'fields' =&gt; \Craft::t('datatables', 'Fields'),
        ];
    }
</code></pre>
<p><a href="https://i.sstatic.net/1lXjI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/1lXjI.png" alt="enter image description here" /></a></p>
<p>When I compared to other index pages I noticed that the ajax calls that are used to get the data and render the table are not fired:</p>
<pre><code>index.php?p=admin/actions/element-indexes/get-elements&amp;v=163847
index.php?p=admin/actions/element-indexes/count-elements&amp;v=1638471423198
</code></pre>
<p>There are no JS errors in the console.</p>
<hr />
<p>Edit 19-11-2022: Plugin ready at <a href="https://plugins.craftcms.com/tablecloth?craft4" rel="nofollow noreferrer">https://plugins.craftcms.com/tablecloth?craft4</a></p>

<plugin-development>
Index table not displayed on new element type
# Index table not displayed on new element type

(Asked by: username_0 on 2021-12-02)

I am writing a data tables plugin and am currently working on the index page in the CP.
I've followed the instructions here:
index.twig
{% extends '_layouts/elementindex' %}
{% set title = "DataTables"|t('app')  %}
{% set elementType = 'matfish\\DataTables\\elements\\DataTable' %}

{% block actionButton %}
 
    
      
       {{ "New DataTable"|t('datatables')}}
      
    
  
{% endblock %}

Page is rendered but the table area is empty:

Table Attributes are defined on element class, and are displayed in dropdown:
 protected static function defineTableAttributes(): array
    {
        return [
            'title' => \Craft::t('app', 'Title'),
            'elementType' => \Craft::t('datatables', 'Element Type'),
            'fields' => \Craft::t('datatables', 'Fields'),
        ];
    }


When I compared to other index pages I noticed that the ajax calls that are used to get the data and render the table are not fired:
index.php?p=admin/actions/element-indexes/get-elements&v=163847
index.php?p=admin/actions/element-indexes/count-elements&v=1638471423198

There are no JS errors in the console.

Edit 19-11-2022: Plugin ready at https://plugins.craftcms.com/tablecloth?craft4

**Tags:** plugin-development


---

## 1 answers

### Answer by username_1 on 2021-12-02. Score: 2 | Accepted answer

There is no sources at the left side of your element index picture.
i think you missed source definition at your element type class:
it can be something simple like:
protected static function defineSources(string $context = null): array
{
    return [
        [
            'key' => '*',
            'label' => 'All Items',
            'criteria' => []
        ],
    ];
}

those requests are not fired because there is no criteria to pass via request without defining sources.

> **Comments:**
> **username_0**: Thanks! One more thing I forgot was defining the query class on the `find` method. (https://craftcms.com/docs/3.x/extend/element-types.html#element-query-class). Without it Craft will just load all elements in the system.  

---

