How to give pagination for Rest Service data I am using Rest Service and pull the data from another non drupal db.

I wrote custom module with two form elements and render that data (rest service call) and display using theme table. 

I wrote  $form['pager'] = array('#theme' =&gt; 'pager'); for pagination.

Pagination is working only for data which rendered using db query. In my condition it's not working.

How can I add pagination for my table.

 function myForm($form, &amp;$form_state){
 pager_array_splice($final_data, 10);
foreach($final_data as $key =&gt; $value){
     $source=explode('=',$key);
     $options[]=array( 
        'Token_Source'=&gt;$source[0],
        'Tokens'=&gt;$value,           
     );
}


$form['pagerTop'] = array('#theme' =&gt; 'pager');
$form['entities'] = array(
  '#type' =&gt; 'tableselect',
  '#header' =&gt; $header,
  '#options' =&gt; $options,
  '#attributes' =&gt; array('class' =&gt; array('entity-sort-table viewTable tokensTable')),
  '#empty' =&gt; t('There are no Notification ....'),
);
$form['pagerBottom'] = array('#theme' =&gt; 'pager');  
return $form;   
}
function pager_array_splice($data, $limit = 9, $element = 0) {
print_r($data);
global $pager_page_array, $pager_total, $pager_total_items;
$page = isset($_GET['page']) ? $_GET['page'] : '';

// Convert comma-separated $page to an array, used by other functions.
$pager_page_array = explode(',', $page);

// We calculate the total of pages as ceil(items / limit).
 $pager_total_items[$element] = count($data);
$pager_total[$element] = ceil($pager_total_items[$element] / $limit);
 $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element],     ((int)$pager_total[$element]) - 1));
 return array_slice($data, $pager_page_array[$element] * $limit, $limit, TRUE);
}
$row = pager_array_splice($options, 10);


$form['pagerTop'] = array('#theme' =&gt; 'pager');
  $form['entities'] = array(
  '#options' =&gt; $row,
  );


please assign $row value in the theme table