Hello,
I need to save session user in virtual column of grid controller code:
Var:
$this->session->userdata('biller_id')
Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Segway extends MY_Controller
{
function __construct()
{
parent::__construct();
if (!$this->loggedIn) {
$this->session->set_userdata('requested_page', $this->uri->uri_string());
$this->sma->md('login');
}
if (!$this->Owner && !$this->Admin) {
$this->session->set_flashdata('warning', lang('access_denied'));
redirect($_SERVER["HTTP_REFERER"]);
}
}
public function show_grid()
{
$db_conf = array();
$db_conf["type"] = "mysqli"; // mysql,oci8(for oracle),mssql,postgres,sybase
$db_conf["server"] = "localhost";
$db_conf["user"] = "root";
$db_conf["password"] = "root";
$db_conf["database"] = "griddemo";
require_once("lib/inc/jqgrid_dist.php");
$g = new jqgrid($db_conf);
$grid = array();
// set table for CRUD operations
$grid["caption"] = "Test CI GRID";
$grid["rowNum"] = 10;//10,15 — tinggi grid
$grid["shrinkToFit"] = true;
$grid["autowidth"] = true;
$grid["hidegrid"] = true;
//$grid["width"] = true;
$grid["height"] = 450;
#$grid["sortorder"] = "desc";
$grid["toolbar"] = "top";
$grid["add_options"] = array("recreateForm" => true, "closeAfterEdit"=>true, 'width'=>'750', 'top'=>'150', 'left'=>'200');
$grid["edit_options"] = array("recreateForm" => true, "closeAfterEdit"=>true, 'width'=>'750', 'top'=>'150', 'left'=>'200');
$grid["view_options"] = array("recreateForm" => true, "closeAfterEdit"=>true, 'width'=>'750', 'top'=>'150', 'left'=>'200');
$g->set_options($grid);
$g->set_actions(array(
"add"=>true, // allow/disallow add
"edit"=>true, // allow/disallow edit
"view"=>true, // allow/disallow edit
"delete"=>true, // allow/disallow delete
"rowactions"=>true, // show/hide row wise edit/del/save option
"export_excel"=>true, // show/hide export to excel option
"export_pdf"=>true,
"autofilter" => false, // show/hide autofilter for search – advance, false,true
"search" => false, // show single/multi field search condition (e.g. simple or advance)
"inlineedit" => true
)
);
// render grid
$g->select_command = "select * FROM country";
$g->table = "country";
$g->set_columns($cols);
$data['grid'] = $g->render("list1");
//$this->load->view('grilla',$data);
$this->load->view('default/views/show_grid',$data); // For circle 404 page
}
}
Thank you!
You can define virtual column and set it as default value.
e.g.
$col["name"] = "biller";
$col["title"] = "Biller";
$col["editable"] = "Biller";
$col["editoptions"]["defaultValue"] = $this->session->userdata('biller_id')
….
Hello,
I get error 50 rendering individual column table names:
$col_cli = array();
$col_cli["title"] = "Id";
$col_cli["name"] = "id";
$col_cli["width"] = "20";
$col_cli["hidden"] = true;
$col_cli["show"] = array("add"=>true, "edit"=>true, "list"=>true);
$cols_cli[] = $col_cli;
$col_cli = array();
$col_cli["title"] = "Nombre";
$col_cli["name"] = "name";
$col_cli["width"] = "20";
$col_cli["editable"] = true;
$col_cli["editrules"] = array("required"=>true); // and is required
$col_cli["show"] = array("add"=>true, "edit"=>true, "list"=>true);
$cols_cli[] = $col_cli;
Error 500.
Thanks!
Hi,
Please check error log and message that error details.
There could be many reasons for 500 error.
Debugging error get this:
inject.js – status 200
segway – status 500
Thank you!