I have the callback function below that renders a table with a pager. Every page of the table is 20 rows. Below is the code:
function myid_print_all_submitted_id_callback($form, &$form_state){ $table_html = ''; $rows = array(); // Build the sortable table header. $header = array( 'idnumber' => array('data' => t('ID Number'), 'field' => 'idnumber'), 'student' => array('data' => t('Student'), 'field' => 'student'), 'status' => array('data' => t('Lacking ID Information | Status'), 'field' => 'status'), ); $query = db_select('student', 't1',array('target' => 'import')); $result = $query ->fields('t1', array('idnumber','student','status')) ->condition('t1.studid', 1 ,'=') ->extend('TableSort')->extend('PagerDefault')->limit(20) ->execute(); foreach($result as $record){ $rows[] = array( 'idnumber' => $record->idnumber, 'student' => $record->student, 'status' => $record->status, ); } $table_html = theme('table', array('header' => $header, 'rows' => $rows)) . theme("pager"); //Build the table $form['table'] = array( '#type' => 'item', '#markup' => $table_html, '#empty' => t('Table has no row!'), '#prefix' => '<div id="myid_table_wrapper_div">', '#suffix' => '</div>', ); return $form['table'];
}
It looks like the image below:
When I click the next page it shows a blank page:
Where did I go wrong? It was redirected to http://19.46.1.13/myid/system/ajax?page=1
, when it must be redirected to http://19.46.1.13/myid/user/1/myid_print?page=2
.
I was guessing it is because the table pager was not loaded yet because it was rendered by a callback function. Any suggestions/solutions on how to solve it?
Sponsored by SupremePR