⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to using CRUD in DataTables



Rio Nying-nying Cmrt
  • profile picture
  • Member

Posted 31 January 2013 - 13:53 PM

[color=#111111][font='Lucida Grande', Verdana, Arial, Helvetica, sans-serif][size=3][left][background=rgb(246, 246, 255)]Hi all,[/background][/left][/size][/font][/color]
[color=#111111][font='Lucida Grande', Verdana, Arial, Helvetica, sans-serif][size=3][left][background=rgb(246, 246, 255)]How to create a CRUD (Create Read Update Delete) in a data table, I find it difficult to make it[/background][/left][/size][/font][/color]
[color=#111111][font='Lucida Grande', Verdana, Arial, Helvetica, sans-serif][size=3][left][background=rgb(246, 246, 255)]Thankyou.. :D[/background][/left][/size][/font][/color]

victor
  • profile picture
  • Member

Posted 31 January 2013 - 15:18 PM

$crud-> set_theme(datatables')

Rio Nying-nying Cmrt
  • profile picture
  • Member

Posted 31 January 2013 - 15:23 PM

i've typing it like this

public function getdatabase()
{
$crud = new grocery_CRUD();
$crud->set_table('tb_lirik');
$crud->columns('id_lirik','nama_band','judul','status','full_lirik');

$output = $crud->render();

$this->_example_output($output);
}

but no change in the appearance of my web

victor
  • profile picture
  • Member

Posted 31 January 2013 - 15:29 PM

the grocery crud contains the datatables theme and flexigrid theme. try my code. Or do you want to use own theme?

victor
  • profile picture
  • Member

Posted 31 January 2013 - 15:33 PM

try this
$crud = new grocery_CRUD();
$crud->set_table('tb_lirik');
$crud-> set_theme('datatables');
$crud->columns
('id_lirik','nama_band','judul','status','full_lirik');
$output = $crud->render();
$this->_example_output($output);

Rio Nying-nying Cmrt
  • profile picture
  • Member

Posted 31 January 2013 - 15:45 PM

[b]Parse error[/b][color=#000000][font='Times New Roman'][size=1]: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in [/size][/font][/color][b]C:\xampp\htdocs\ci\application\controllers\site.php[/b][color=#000000][font='Times New Roman'][size=1] on line [/size][/font][/color][b]20[/b]

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Site extends CI_Controller {

//function __construct(){
// parent::__construct();
//kalo harus login, remarknya dibuka dulu
// $this->sudahlogin();
// }
public function index()
{
$this->load->view('post');
}
public function getdatabase()
{
$crud = new grocery_CRUD();
$crud->set_table('tb_lirik');
$crud-> set_theme(datatables');
$crud->columns
('id_lirik','nama_band','judul','status','full_lirik'); --------> This line 20
$output = $crud->render();
$this->_example_output($output);
}

public function getdatabyajax()
{
$this->load->library('datatables');
$this->datatables
->select('id_lirik,nama_band,judul,status,full_lirik')
->from('tb_lirik');

echo ($this->datatables->generate());
//echo ($this->datatables->fnFormatDetails());
}



// function sudahlogin(){
// $sudah = $this->session->userdata('sudahlogin');
// if (!isset($sudah) || $sudah != true) {
// redirect('login');
//echo 'sorry bro';
//die();
// }
// }
//
// function logout(){
// $this->session->unset_userdata('sudahlogin',false);
// }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

Rio Nying-nying Cmrt
  • profile picture
  • Member

Posted 31 January 2013 - 15:46 PM

sorry i'm beginner :D

victor
  • profile picture
  • Member

Posted 31 January 2013 - 15:51 PM

$crud-> set_theme('datatables');
you forgot to type quote after "(".

your version is $crud-> set_theme(datatables');

Rio Nying-nying Cmrt
  • profile picture
  • Member

Posted 31 January 2013 - 16:05 PM

in here CRUD does not appear




i want to be like this

Rio Nying-nying Cmrt
  • profile picture
  • Member

Posted 31 January 2013 - 16:06 PM

sorry this picture is not displaying in here, how to displayed in this comment post...???

victor
  • profile picture
  • Member

Posted 31 January 2013 - 16:11 PM

more reply options near the button "post"

Rio Nying-nying Cmrt
  • profile picture
  • Member

Posted 31 January 2013 - 16:17 PM

in here CRUD doesn't appear
[attachment=454:Untitled.jpg]


i want to be like this

[attachment=455:Untitled2.jpg]

victor
  • profile picture
  • Member

Posted 31 January 2013 - 16:26 PM

this is not the grocerycrud theme!!! have a look at official documentation. www.grocerycrud.com/documentation

Rio Nying-nying Cmrt
  • profile picture
  • Member

Posted 31 January 2013 - 16:40 PM

almost all my coding is false, I will try it soon. Thankyou for your help. Sorry i've spend your time :)

victor
  • profile picture
  • Member

Posted 31 January 2013 - 17:36 PM

your code is try ) but what url do you use to open that page?

Rio Nying-nying Cmrt
  • profile picture
  • Member

Posted 31 January 2013 - 18:16 PM

my url http://localhost/ci/index.php/site

victor
  • profile picture
  • Member

Posted 31 January 2013 - 18:35 PM

...index.php/site/getdatabase

victor
  • profile picture
  • Member

Posted 31 January 2013 - 19:18 PM

did you solved your problem?

goFrendiAsgard
  • profile picture
  • Member

Posted 01 February 2013 - 01:42 AM

[member="Rio Nying-nying Cmrt"]: JQuery datatable (http://www.datatables.net/) is different from groceryCRUD datatable's theme.
In groceryCRUD, datatable is just a name of a theme. Another possible theme is "flexigrid". I think you've mix them up.

You don't need any datatable library since this function of yours already produce a fully working CRUD:

public function getdatabase()
{
$crud = new grocery_CRUD();
$crud->set_table('tb_lirik');
$crud-> set_theme('datatables');
$crud->columns
('id_lirik','nama_band','judul','status','full_lirik');
$output = $crud->render();
$this->_example_output($output);
}

The problem lied on the last line:
$this->_example_output($output)

You've call the "_example_output" function, but you don't have such a function in that corresponding controller.

Good luck