Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/cakephp/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cakephp 如何更正jqgrid页脚信息?_Cakephp_Jqgrid - Fatal编程技术网

Cakephp 如何更正jqgrid页脚信息?

Cakephp 如何更正jqgrid页脚信息?,cakephp,jqgrid,Cakephp,Jqgrid,我正在我的一个应用程序中使用jqgrid。 现在我面临一个奇怪的问题,不知道如何纠正它 实际上,在其中一个报告(具有多个链接)中,jqgrid显示了错误的页脚信息,即显示0页(共0页),即使表中有记录 这是运行的代码: if( isset($this->params['named']['ajax']) && $this->params['named']['ajax'] == '1' ) { $this->autoRender = fal

我正在我的一个应用程序中使用jqgrid。 现在我面临一个奇怪的问题,不知道如何纠正它

实际上,在其中一个报告(具有多个链接)中,jqgrid显示了错误的页脚信息,即显示0页(共0页),即使表中有记录

这是运行的代码:

if( isset($this->params['named']['ajax']) && $this->params['named']['ajax'] == '1' )
    {

        $this->autoRender = false;

        // get how many rows we want to have into the grid - rowNum parameter in the grid
        $limit = $this->params['url']['rows'];

        // get index row - i.e. user click to sort. At first time sortname parameter -
        // after that the index from colModel
        $sidx = $this->params['url']['sidx'];

        // sorting order - at first time sortorder
        $sord = $this->params['url']['sord'];

        $page = $this->params['url']['page'];

        // if we not pass at first time index use the first column for the index or what you want
        if( !$sidx ) $sidx = 1;

        // calculate the number of rows for the query. We need this for paging the result
         $findconditions = array();
        if(!empty($this->params['named']['batch']))
            array_push(&$findconditions, array('Batch.id' => $this->params['named']['batch'] ));
          $row = $this->Placement->find('count',array(
                    'link' => array(
                    'Student' => array(
                        'Batch'
                    )
                    ),
                    'conditions'=> $findconditions
          ));
        $count = $row;

        // calculate the total pages for the query
        if( $count > 0 )
        {
            $total_pages = ceil($count / $limit);
        }
        else
        {
            $total_pages = 0;
        }

        // if for some reasons the requested page is greater than the total
        // set the requested page to total page
        if( $page > $total_pages ) $page = $total_pages;

        // calculate the starting position of the rows
        $start = $limit * $page - $limit;

        // if for some reasons start position is negative set it to 0
        // typical case is that the user type 0 for the requested page
        if( $start < 0 ) $start = 0;

        // the actual query for the grid data
        $limit_range = $start . "," . $limit;
        $sort_range = $this->modelClass . '.' . $sidx . " " . $sord;

        $this->Placement->recursive = -1;
         $where='';
        if( $this->params['url']['_search'] == 'true' )
        {
            //pr($this->params);

            $searchconditions = array();

            if( isset($this->params['named']['batch']) && !empty($this->params['named']['batch']) )
            {
              $where.= " Batch.id =".$this->params['named']['batch'];
            }
            if( isset($this->params['url']['isstillworking']) && !empty($this->params['url']['isstillworking']) )
            {
              $where.= " AND Placement.isstillworking ='".$this->params['url']['isstillworking']."'";
            }
            if( isset($this->params['url']['studentname']) && !empty($this->params['url']['studentname']) )
            {
              $where.=" AND Student.fullname LIKE '" .$this->params['url']['studentname'] . "%'";
            }
             if( isset($this->params['url']['companyname']) && !empty($this->params['url']['companyname']) )
            {
                $where.=" AND Company.name LIKE '" .$this->params['url']['companyname'] . "%'";

            }
            if( isset($this->params['url']['salary']) && !empty($this->params['url']['salary']) )
            {
              $where.= " AND Placement.salary =".$this->params['url']['salary'];

            }
            if( isset($this->params['url']['contactnumber1']) && !empty($this->params['url']['contactnumber1']) )
            {
                 $where.= " AND Student.contactnumber1 =".$this->params['url']['contactnumber1'];
            }
             if( isset($this->params['url']['batchname']) && !empty($this->params['url']['batchname']) )
            {
                $where.=" AND Batch.name LIKE '" .$this->params['url']['batchname'] . "%'";
            }



            $sql="SELECT Student.fullname, 
                Placement.isstillworking, 
                Company.id,
                Company.name,
                Placement.id,
                Placement.salary,
                Placement.created, 
                Student.id, 
                Student.contactnumber1, 
                Batch.id,
                Batch.name
            FROM placements Placement
            INNER JOIN (

                    SELECT student_id, isstillworking, max( created ) AS other_col
                        FROM placements
                        GROUP BY student_id
                        ) AS b ON Placement.student_id = b.student_id
                        AND Placement.created = b.other_col
            INNER JOIN students Student ON ( Student.id = Placement.student_id )
            INNER JOIN batches Batch ON ( Student.batch_id = Batch.id )
            INNER JOIN companies Company ON ( Company.id = Placement.company_id )
            WHERE ".$where. 
            "  AND Student.type='student' 
               AND Student.trainingcompleted=1
             ORDER BY ".$sort_range."
             LIMIT ".$limit_range
             ;
            $result=$this->Placement->query($sql);


        }
        else
        {
                $sql="SELECT Student.fullname, 
                Placement.isstillworking, 
                Company.id,
                Company.name,
                Placement.id,
                Placement.salary,
                Placement.created, 
                Student.id, 
                Student.contactnumber1, 
                Batch.id,
                Batch.name
            FROM placements Placement
            INNER JOIN (

                    SELECT student_id, isstillworking, max( created ) AS other_col
                        FROM placements
                        GROUP BY student_id
                        ) AS b ON Placement.student_id = b.student_id
                        AND Placement.created = b.other_col
            INNER JOIN students Student ON ( Student.id = Placement.student_id )
            INNER JOIN batches Batch ON ( Student.batch_id = Batch.id )
            INNER JOIN companies Company ON ( Company.id = Placement.company_id )
            WHERE Batch.id =
            ".$this->params['named']['batch'].
            " AND Student.type='student' 
              AND Student.trainingcompleted=1
             ORDER BY ".$sort_range."
             LIMIT ".$limit_range
             ;
            $result=$this->Placement->query($sql);
        }

        $i = 0;
        $response->page = $page;
        $response->total = $total_pages;
        $response->records = $count;

        //pr($result);

        foreach($result as $result)
        {
            $response->rows[$i]['id'] = $result['Placement']['id'];

            $student = "<a href='" . APP_URL . "placements/report18/studentid:" . $result['Student']['id']."'>" . $result['Student']['fullname'] . "</a>";
            $company = "<a href='" . APP_URL . "companies/view/" . $result['Company']['id'] . "'>" . $result['Company']['name'] . "</a>";
            $batch = "<a href='" . APP_URL . "batches/view/" . $result['Batch']['id'] . "'>" . $result['Batch']['name'] . "</a>";
            $contactnumber1 =$result['Student']['contactnumber1'];
            $response->rows[$i]['cell'] = array($student, $result['Placement']['isstillworking'], $result['Company']['name'], $result['Placement']['salary'], $contactnumber1, $batch);
            $i++;
        }

        echo json_encode($response);

    }
if(isset($this->params['named']['ajax'])&&$this->params['named']['ajax']=='1')
{
$this->autoRender=false;
//获取网格中grid-rowNum参数中要包含的行数
$limit=$this->params['url']['rows'];
//获取索引行-即用户单击进行排序。第一次使用sortname参数-
//之后,从colModel获取索引
$sidx=$this->params['url']['sidx'];
//排序顺序-第一次排序器
$sord=$this->params['url']['sord'];
$page=$this->params['url']['page'];
//如果我们没有在第一时间传递索引,请使用第一列作为索引或您想要的内容
如果(!$sidx)$sidx=1;
//计算查询的行数。我们需要它来分页结果
$findconditions=array();
如果(!empty($this->params['named']['batch']))
数组推送(&$findconditions,数组('Batch.id'=>$this->params['named']['Batch']);
$row=$this->Placement->find('count',数组(
'链接'=>数组(
“学生”=>数组(
“批量”
)
),
“条件”=>$findconditions
));
$count=$row;
//计算查询的总页数
如果($count>0)
{
$total_pages=ceil($count/$limit);
}
其他的
{
$total_pages=0;
}
//如果由于某些原因,请求的页面大于总页面
//将请求的页面设置为总页面
如果($page>$total\u pages)$page=$total\u pages;
//计算行的起始位置
$start=$limit*$page-$limit;
//如果出于某些原因,“开始位置”为负值,则将其设置为0
//典型的情况是,用户为请求的页面键入0
如果($start<0)$start=0;
//网格数据的实际查询
$limit\u range=$start.“,”$limit;
$sort_range=$this->modelClass.'.$sidx.'$sord;
$this->Placement->recursive=-1;
$where='';
如果($this->params['url'][''u search']=='true')
{
//pr($this->params);
$searchconditions=array();
如果(设置($this->params['named']['batch'])和($this->params['named']['batch'])为空($this->params['named']['batch']))
{
$where.=“Batch.id=”..$this->params['named']['Batch'];
}
if(isset($this->params['url']['isstillworking'])和&!empty($this->params['url']['isstillworking']))
{
$where.=“AND Placement.isstillworking=””$this->params['url']['isstillworking'].”;
}
if(设置($this->params['url']['studentname'])&&!empty($this->params['url']['studentname']))
{
$where.=“和Student.fullname类似”.$this->params['url']['studentname'].“%”;
}
if(设置($this->params['url']['companyname'])和&!empty($this->params['url']['companyname']))
{
$where.=“和Company.name类似”.$this->params['url']['companyname'].“%”;
}
如果(设置($this->params['url']['salary'])和($this->params['url']['salary'])为空($this->params['url']['salary']))
{
$where.=“AND Placement.salary=”.$this->params['url']['salary'];
}
if(设置($this->params['url']['contactnumber1'])和&!empty($this->params['url']['contactnumber1']))
{
$where.=”和Student.contactnumber1=“.this->params['url']['contactnumber1'];
}
if(设置($this->params['url']['batchname'])和&!empty($this->params['url']['batchname']))
{
$where.=“和Batch.name类似”.$this->params['url']['batchname'].“%”;
}
$sql=“选择Student.fullname,
安置工作,
Company.id,
公司名称,
地址:,
职位、薪金、,
已创建,
学生证,
学生联系电话1,
Batch.id,
Batch.name
从安置到安置
内连接(
选择学生id、isstillworking、max(已创建)作为其他列
从安置
按学生id分组
)在安置时作为b.student\u id=b.student\u id
和Placement.created=b.other\u col
内部加入学生在线(Student.id=Placement.Student\u id)
内部联接批处理打开(Student.Batch\u id=Batch.id)
内部加入公司(Company.id=Placement.Company\u id)
WHERE.$WHERE。
“还有学生。type='Student'
和学生。培训完成=1
按“$sort\u范围”排序
限制“.$LIMIT\u范围
;
$result=$this->Placement->query($sql);
}
其他的
{
$sql=“选择Student.fullname,
安置工作,
Company.id,
公司名称,
地址:,
职位、薪金、,
已创建,
学生证,
学生联系电话1,
Batch.id,
Batch.name
从安置到安置
内连接(
选择s