/** * ajax-based serverside processed datatables example action */ public function action_datatables_ajax() { // Column definition $columns = array("test1" => "Testcolumn #1", "test2" => "Testcolumn #2"); // Generate random data $data = Session::instance()->get('dattables_example', array()); if (empty($data)) { for ($i = 0; $i < 5000; $i++) { $data[] = array('test1' => $this->generateRandomString(25), 'test2' => $this->generateRandomString(25)); } } // Create datatable $datatable = new Datatable($columns); // Here you could also pass in a orm model like this: $datatable->add_entries(ORM::factory('Model')); // Then the model needs to have columns named like the keys in the column definition, so in this example // test1 and test2 are needed properties on the model. $datatable->add_entries($data); $datatable->set_serverside(URL::base() . 'UIFWExamples/datatables_ajax'); // Render html code from datatable->render() with the html layout if (Request::$current->is_ajax()) { echo $datatable->ajax_render(); } else { $this->renderHtml($datatable->render()); } }