Welcome Guest, Not a member yet? Register   Sign In
HELP: item is null
#1

[eluser]cestaz18[/eluser]
i have joint table sec_company access table where it has user id and company id joint together where the sec company access id is the one i call to show the detail list data of my master jqgrid table which is the sec user table..

the scene where i have an add delete edit operation in my detail list table which the company detail data..when i have to add data in my company table..it succesfully add but if i refresh the table it will hide and said that no record found..

i think the problem is..there is no company id save in my sec_companyaccess table where its id the one i call on to show the company detail data....

heres my code..

script.js
Code:
$(".listFlex").jqGrid({
         url: root + mod + '/listview',
          editurl: root + mod + '/post',        
          sortable: true,
         datatype: "json",
         mtype: 'POST',
         colNames:['','Username','Lastname', 'Firstname','Middle Initial'],
         colModel:[
                       {name:'user_id', index: 'item', hidden: true},
                      {name:'username',index:'username', width:80, align:"left", editable:true},
                    {name:'last_name', index: 'last_name', width:80, editable: true},
                       {name:'first_name',index:'first_name', width:100,align:"left",editable:true},
                    {name:'middle_initial', index: 'middle_initial', width:80, editable: true}
                    
               ],
         rowNum:10,
         rowList:[10,20,30],
         rownumbers: true,
         pager: '#pager',
         sortname: 'username',
         viewrecords: true,
         sortorder: 'asc',
         autowidth: true,
         height: "200",
         caption:"User Role List -Dean",
        
    //cess code added
         ondblClickRow: function(ids) {
                if(ids == null) {
                    ids=0;
                    if(jQuery("#detFlex1").jqGrid('getGridParam','records') >0 )
                    {
                        jQuery("#detFlex1").jqGrid('setGridParam',{url:root + mod + '/detaillistview/' + ids,page:1});
                    
                        jQuery("#detFlex1").jqGrid('setCaption',"Detail: "+ids)
                        .trigger('reloadGrid');
                        $('.toolbar a[title=Header]').trigger('click');                
                        viewdb(ids);
                    }
                } else {
                    jQuery("#detFlex1").jqGrid('setGridParam',{url:root + mod + '/detaillistview/' + ids,page:1});
                    
                    jQuery("#detFlex1").jqGrid('setCaption',"Detail: "+ids)
                    .trigger('reloadGrid');
                    $('.toolbar a[title=Header]').trigger('click');                
                    viewdb(ids);
                    }
                }
            });
    

$("#detFlex1").jqGrid({
         url: root + mod + '/detaillistview',
         editurl: root + mod + '/detailpost',    
         datatype: "json",
         mtype: 'POST',
         colNames:['','Company Code','Company Name', ''],
         colModel:[
                   {name:'company_access_id', index: 'company_access_id', hidden: true},
                      {name:'company_code',index:'company_code', width:250, align:"left", editable:true},
                    {name:'company_name', index: 'company_name', width:250, editable: true},
                   {name:'company_id',index:'company_id', hidden: true}
               ],
         rowNum:10,
         rowList:[10,20,30],
         rownumbers: true,
         pager: '#pager2',
         sortname: 'company_code',
         viewrecords: true,
         sortorder: 'asc',
         autowidth: true,
         height: "100",
         caption:"Details"

        }
);
    jQuery("#detFlex1").jqGrid('navGrid','#pager2',
        {search:false},//search options
        {view:false}, //view options
        {height:150,reloadAfterSubmit:false, jqModal:false, closeOnEscape:true, bottominfo:"Fields marked with (*) are required"}, // edit options
        {height:150,reloadAfterSubmit:false,jqModal:false, closeOnEscape:true, bottominfo:"Fields marked with (*) are required", closeAfterAdd: true}, // add options
        {height:150,reloadAfterSubmit:false,jqModal:false, closeOnEscape:true} // del options
        );
#2

[eluser]cestaz18[/eluser]
controller

Code:
function detailpost()
    {

        $crudColumns =  array(
            'id'=>'company_id'
            ,'company_code'=>'company_code'
            ,'company_name'=>'company_name'
        );
        $crudTableName = 'erp_maint_company';
        $postConfig['id'] = 'company_id';

        $postConfig['search'] = '_search';             /* search */
        $postConfig['searchField'] = 'searchField'; /* searchField */
        $postConfig['searchOper'] = 'searchOper';     /* searchOper */
        $postConfig['searchStr'] = 'searchString';     /* searchString */
        $postConfig['action'] = 'oper';             /* action variable */
        $postConfig['sortColumn'] = 'sidx';         /* sort column */
        $postConfig['sortOrder'] = 'sord';             /* sort order */
        $postConfig['page'] = 'page';                 /* current requested page */
        $postConfig['limit'] = 'rows';                /* restrict number of rows to return */
        $crudConfig['row'] = 'cell';                 /* row data identifier */
        $crudConfig['read'] = 'oper';                 /* action READ keyword *//* set to be the same as action keyword for default */
        $crudConfig['create'] = 'add';                /* action CREATE keyword */
        $crudConfig['update'] = 'edit';                /* action UPDATE keyword */
        $crudConfig['delete'] = 'del';                /* action DELETE keyword */
        $crudConfig['totalPages'] = 'total';        /* total pages */
        $crudConfig['totalRecords'] = 'records';    /* total records */
        $crudConfig['responseSuccess'] = 'success';    /* total records */
        $crudConfig['responseFailure'] = 'fail';    /* total records */
        /* end of jqgrid specific settings */
        //$o=null;

        function fnSearchCondition($searchOperation, $searchString){
            switch($searchOperation){
                case 'eq': $searchCondition = '= "'.$searchString.'"'; break;
                case 'ne': $searchCondition = '!= "'.$searchString.'"'; break;
                case 'bw': $searchCondition = 'LIKE "'.$searchString.'%"'; break;
                case 'ew': $searchCondition = 'LIKE "%'.$searchString.'"'; break;
                case 'cn': $searchCondition = 'LIKE "%'.$searchString.'%"'; break;
                case 'lt': $searchCondition = '< "'.$searchString.'"'; break;
                case 'gt': $searchCondition = '> "'.$searchString.'"'; break;
                case 'le': $searchCondition = '<= "'.$searchString.'"'; break;
                case 'ge': $searchCondition = '>= "'.$searchString.'"'; break;
                
            }
            return $searchCondition;
        }
        function fnCleanInputVar($string){
            return $string;
        }

        foreach ($postConfig as $key => $value){
            if(isset($_REQUEST[$value])){
                $postConfig[$key] = fnCleanInputVar($_REQUEST[$value]);
            }
        }
        foreach ($crudColumns as $key => $value){
            if(isset($_REQUEST[$key])){
                $crudColumnValues[$key] = '"'.fnCleanInputVar($_REQUEST[$key]).'"';
            }
        }

        switch($postConfig['action']){
            case $crudConfig['create']:
                $c = "";
                $dt['company_code'] = $this->input->post('company_code');
                $sec_exist = $this->User->getCompanyDetails($dt);
                
                if ($sec_exist)
                {
                    $c .= 'Company ID already exists.';
                    $data['action'] = 'exist';
                }
                else
                {
                $fields = array(
                        "company_code"
                        ,"company_name"
                        );
                
                foreach ($fields as $field)
                {if (isset($_POST[$field])) $dt[$field] = $this->input->post($field);}

                //$item = $this->input->post('ids');    
                $item = $this->input->post("item");    
                print_r($_POST);
                /*    $dt['ids'] = $this->input->post('ids');
                $item= $this->User->getDetailList($dt);*/
                $data['item'] = $this->User->save_companydetail($dt,$item);
                }
                break;
            case $crudConfig['update']:
                $sql = 'update '.$crudTableName.' set ';
                foreach($crudColumns as $key => $value){ $updateArray[$key] = $value.'='.$crudColumnValues[$key]; };
                $sql .= implode(',',$updateArray);
                $sql .= ' where company_id = '.$crudColumnValues['id'];
                mysql_query( $sql );
                break;
            case $crudConfig['delete']:
                $this->db->where('company_id', $this->input->post('id'));
                $this->db->delete_detail($crudTableName);
                    
                break;
            }
        
        if (isset($data)) echo json_encode($data);
    }
#3

[eluser]cestaz18[/eluser]
model

Code:
function save_companydetail($details,$id)
    {

        $this->db->insert('maint_company', $details);
        $DataId = $this->db->insert_id();
        $data['user_id'] = $id;
        $data['company_id'] = $DataId;    
        $this->db->insert('sec_companyaccess', $data);
    }
#4

[eluser]cestaz18[/eluser]
my firebug show this error....

Quote:Array
(
[company_code] => aaaa
[company_name] => aaaa
[id] => _empty
[oper] => add
)
{"item":null}<br />
<b>Fatal error</b>: ob_start() [&lt;a href='ref.outcontrol'&gt;ref.outcontrol&lt;/a&gt;]: Cannot use output buffering in output buffering display handlers in <b>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\comunion\system\libraries\Exceptions.php</b> on line <b>162</b><br />




Theme © iAndrew 2016 - Forum software by © MyBB