2014-02-28 6 views

답변

1

이 코드를 사용해보십시오

public function customers_management() 
{ 

//This process is important to reset the last serial no... 
$page = $this->input->get_post('page'); 
if($page == '') { 
    $page=1; 
} else { 
    $per_page = $this->input->get_post('per_page'); 
    $start = ($page-1) * $per_page; 
    $this->session->set_userdata('lastSerial', $start); 
} 

$this->load->library('grocery_crud_with_tab'); 
$crud = new grocery_crud_with_tab(); 

$crud->set_table('customers'); 
$crud->columns('serial_no', 'customerName','contactLastName','phone','city','country','salesRepEmployeeNumber','creditLimit'); 
$crud->display_as('salesRepEmployeeNumber','from Employeer') 
->display_as('customerName','Name') 
->display_as('contactLastName','Last Name'); 
$crud->set_subject('Customer'); 
$crud->set_relation('salesRepEmployeeNumber','employees','lastName'); 
$crud->callback_column('serial_no', array($this, 'generateSerialNo')); 

$crud->set_tab('default', 'Customer Details', array('customerName', 'salesRepEmployeeNumber', 'creditLimit')); 
$crud->set_tab('contact', 'Customer Contact', array('contactLastName', 'contactFirstName', 'phone')); 
$crud->set_tab('address', 'Customer Address', array('addressLine1', 'addressLine2', 'city', 'state', 'postalCode', 'country')); 

//This is written exclusively because the jquery ui provided with this version of grocery crud dose not posses the tabs function.. hence had to 
//set the same from the cloud. 
$crud->unset_jquery_ui(); 
$crud->unset_jquery(); 
$crud->set_css('//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css', false); 
$crud->set_js('//code.jquery.com/jquery-1.11.0.min.js', false); 
$crud->set_js('//code.jquery.com/ui/1.10.4/jquery-ui.js', false); 

$output = $crud->render(); 
$this->_example_output($output); 
} 

function generateSerialNo() { 
if($this->session->userdata('lastSerial') == '') { 
    $this->session->set_userdata('lastSerial', 0); 
    $this->session->set_userdata('lastPage', 1); 
    $lastSerial = 0; 
} else { 
    $lastSerial = $this->session->userdata('lastSerial'); 
} 
$lastSerial++; 
$page = $this->input->post('page'); 
if($page != '') { 
    $this->session->set_userdata('lastPage', $page); 
} else { 
    $this->session->set_userdata('lastPage', 1); 
} 
$this->session->set_userdata('lastSerial', $lastSerial); 

return $lastSerial; 
}