Php 增加jqgrid表格的宽度
我是jqgrid的新手,我想增加jqgrid的宽度。 我增加了列宽,但网格宽度没有增加。 我使用的是php jqgrid 是否有任何参数要传递此函数:=Php 增加jqgrid表格的宽度,php,json,jqgrid,jqgrid-php,Php,Json,Jqgrid,Jqgrid Php,我是jqgrid的新手,我想增加jqgrid的宽度。 我增加了列宽,但网格宽度没有增加。 我使用的是php jqgrid 是否有任何参数要传递此函数:= $grid->renderGrid('#grid','#pager',true, null, null, true,true); 或者我该怎么做 非常感谢。您的问题主要是关于jqGrid的商业版,我不知道。jqGrid中也存在主要问题。jqGrid具有可用于定义网格宽度的参数。我想您应该使用(或已经使用)$grid->setGridOp
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
或者我该怎么做
非常感谢。您的问题主要是关于jqGrid的商业版,我不知道。jqGrid中也存在主要问题。jqGrid具有可用于定义网格宽度的参数。我想您应该使用(或已经使用)
$grid->setGridOptions
来定义该选项。另一个可以额外使用的选项是autowidth
,它将覆盖基于网格父级大小计算的width
值。其他重要选项也很重要,您可以选择:shrinkToFit
哪个默认值是true
。这意味着该列的width
属性将不会用作以像素为单位的精确列宽。而不是使用width
属性来定义列宽之间的比例。如果某列的列宽不应更改,则应在colModel
中包含fixed:true
属性,以获得该列的相应定义。如果希望所有列都具有精确的列宽(如colModel
项的width
属性中所定义),则应使用jqGrid设置shrinkToFit:false
。尝试在$grid->setGridOptions
调用中包含该设置。您可以使用以下php代码:
// Set grid with 1000px by php
$grid->setGridOptions(array("width"=>1000));
我也有同样的问题,我的网格默认使用650px。所以,我查看了一些博客,现在以:)
以下是我使用自动网格宽度的完整php代码:
<?php
require_once '../../../jq-config.php';
// include the jqGrid Class
require_once ABSPATH."php/jqGrid.php";
// include the driver class
require_once ABSPATH."php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// SQL query
$sql = <<<SQL
SELECT *,
CASE total_correct_answer
WHEN total_correct_answer=1 THEN 1
WHEN total_correct_answer=2 THEN 3
ELSE 6
END AS points
FROM
(
SELECT COUNT(*) total_correct_answer, v.coupon_code_id, v.coupon_no, v.login_id, v.cc_match_id, v.name, v.contact_no, v.email, v.user_from
FROM (
SELECT p.login_id, ui.name, ui.contact_no,l.email,l.user_from,
p.quiz_id p_quiz_id,p.question_bank_id p_question_bank_id, p.answer_id p_answer_id,
cc.quiz_id cc_quiz_id,cc.question_bank_id cc_question_bank_id, cc.answer_id cc_answer_id,
cc.match_id cc_match_id, p.coupon_code_id, cd.coupon_no
FROM prediction p
INNER JOIN correct_answer cc
INNER JOIN `user_information` ui ON p.`login_id` = ui.`login_id`
INNER JOIN coupon_code cd ON cd.coupon_code_id = p.coupon_code_id
INNER JOIN login l ON l.login_id = p.login_id
WHERE cc.quiz_id=p.quiz_id AND cc.question_bank_id=p.question_bank_id
AND cc.answer_id=p.answer_id AND cc.match_id IN (SELECT match_id FROM `match` WHERE
start_time BETWEEN DATE_ADD(NOW(), INTERVAL -7 DAY) AND NOW())
) v GROUP BY v.coupon_code_id ORDER BY v.login_id DESC
) a
SQL;
// Write the SQL Query
$grid->SelectCommand = $sql;
// Set output format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('grid.php');
// Set alternate background using altRows property
$grid->setGridOptions(array(
"rowNum"=>10,
"sortable"=>true,
"rownumbers"=>true,
"width"=>'auto',
"altRows"=>true,
"multiselect"=>true,
"rowList"=>array(10,20,50),
));
// Change some property of the field(s)
$grid->setColProperty("total_correct_answer", array("label"=>"Answer", "width"=>80));
$grid->setColProperty("coupon_code_id", array("label"=>"Coupon Code", "width"=>80));
$grid->setColProperty("coupon_no", array("label"=>"Coupon Number", "width"=>120));
$grid->setColProperty("login_id", array("label"=>"User ID", "width"=>80));
$grid->setColProperty("cc_match_id", array("label"=>"Match ID", "width"=>80));
$grid->setColProperty("name", array("label"=>"User Name", "width"=>120));
$grid->setColProperty("contact_no", array("label"=>"Contact No", "width"=>120));
$grid->setColProperty("email", array("label"=>"User Email", "width"=>120));
$grid->setColProperty("user_from", array("label"=>"User Mode", "width"=>120));
$grid->setColProperty("points", array("label"=>"User Points", "width"=>120));
// Enable navigator
$grid->navigator = true;
// Enable excel export
$grid->setNavOptions('navigator', array("excel"=>true,"add"=>false,"edit"=>false,"del"=>false,"view"=>false));
// Set different filename
$grid->exportfile = 'Prediction_Report.xls';
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>