Yes, you would typically do a DB query in prepare_items()
. It depends on what your table is going to display. If the data is not in the DB, then of course there’s no reason to query it. Maybe the data is on a remote server or for shortcodes, maybe all you need is the global $shortcode_tags
.
When display()
is called, several sub-functions are called. You should trace through these just so you understand the process. Eventually a method to display a single row of data is called, which loops through all the columns, calling a specific callback for each column. These callbacks are part of what you need to provide in your class, since the content of each cell is dependent on the nature of your data and the column structure.
Note that to have a sortable column, the column contents need to arrive by way of a DB query where the order can be flipped between ASC or DESC to get the desired column order. Data for non-sortable columns can come from anywhere.
Of course there’s much more than this, like dealing with column headings, action links, view options, etc. Just too much to go into here. There’s several good examples for dealing with list tables in the core code, the terms list table for example. CF7 has a contact forms list table class which may serve as a good example since it is within a plugin. I realize reading through core code or other dev’s code can be mind numbing, but these working examples really are the best way to learn what needs to happen in your own code.