Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.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
Jquery 从jqgrid中删除列_Jquery_Jqgrid_Jqgrid Php_Jqgrid Formatter - Fatal编程技术网

Jquery 从jqgrid中删除列

Jquery 从jqgrid中删除列,jquery,jqgrid,jqgrid-php,jqgrid-formatter,Jquery,Jqgrid,Jqgrid Php,Jqgrid Formatter,我想在jqgrid中添加我自己的列名,同时我还想防止phpjqgrid根据sql查询自动添加列名 我使用的是php jqgrid 实际上,jqgrid从mysql表的列名中获取列名,MyDB表有大约55列,但所有列都是进一步计算所必需的。所以我只想打印12个选定列,而不是所有其他rest列 我正在禁用其他类似于此的列:- $grid->setColProperty("lat", array("hidden"=>true)); $grid->setColProperty("lng

我想在jqgrid中添加我自己的列名,同时我还想防止phpjqgrid根据sql查询自动添加列名

我使用的是php jqgrid

实际上,jqgrid从mysql表的列名中获取列名,MyDB表有大约55列,但所有列都是进一步计算所必需的。所以我只想打印12个选定列,而不是所有其他rest列

我正在禁用其他类似于此的列:-

$grid->setColProperty("lat", array("hidden"=>true));
$grid->setColProperty("lng", array("hidden"=>true));
$grid->setColProperty("clinic_id", array("hidden"=>true));
$grid->setColProperty("id", array("hidden"=>true));
.....
.....
.....
但是设置每个列的隐藏/禁用是很复杂的。每个设置为隐藏/禁用的列都需要代码

是否有任何排序方法可以隐藏/禁用网格中的rest列

我正在使用这段代码来实现这一点,但它也获取了我在方法$grid->setColModelnull,null,$mylabels中没有声明的列的名称

谁能告诉我,为了删除jqgrid中额外添加的列,我应该写什么简短的代码

非常感谢

require_once '/var/www/html/zbajtmp/public/jqgrid/jq-config.php';
// include the jqGrid Class
require_once "/var/www/html/zbajtmp/public/jqgrid/php/jqGrid.php";
// include the driver class
require_once "/var/www/html/zbajtmp/public/jqgrid/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);
 // Write the SQL Query
//$grid->SelectCommand = 'SELECT OrderID, OrderDate, CustomerID, Freight, ShipName  FROM orders';
$grid->SelectCommand = 'SELECT *  FROM clinic';
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
//$grid->setColModel();
$mylabels = array(
"clinic_name"=>"Clinic ame",
"clinic_address"=>"Address",
"HomePhone"=>"Home Phone",
"WorkPhone"=>"Work Phone",
"Email_Id"=>"Email",
);
// Let the grid create the model with the desired labels
$grid->setColModel(null, null, $mylabels);

$grid->setColProperty("lat", array("hidden"=>true));
$grid->setColProperty("lng", array("hidden"=>true));
$grid->setColProperty("clinic_id", array("hidden"=>true));
$grid->setColProperty("id", array("hidden"=>true));
.....
.....
.....
// Set the url from where we obtain the data
//$grid->setUrl('/var/www/html/zbajtmp/application/views/scripts/clinic/grid.php');
$grid->setUrl('http://sunlinux/zbajtmp/application/views/scripts/clinic/grid.php');
// Set grid caption using the option caption
$grid->setGridOptions(array(
    "caption"=>"This is my custom Caption...",
    "rowNum"=>50,
    "sortname"=>"id",
    "hoverrows"=>true,
    "rowList"=>array(20,50,100,1000),
    "width"=>"100%",
    "height"=>350,
"footerrow"=>true,
"rownumbers"=>true,
"multiselect"=>true,
"altRows"=>true,
"altclass"=>'clsalt',
"loadtext"=>"<div class='loadingbox'>Please wait. Loading...</div>",

    ));


$grid->renderGrid('#grid','#pager',true, null, null, true,true);


$conn = null;  
非常感谢。

jqGrid使用select命令构建colModel-因此您需要隐藏手动渲染不需要的额外列-我建议您从select语句中删除*并只选择所需的列

require_once '/var/www/html/zbajtmp/public/jqgrid/jq-config.php';
// include the jqGrid Class
require_once "/var/www/html/zbajtmp/public/jqgrid/php/jqGrid.php";
// include the driver class
require_once "/var/www/html/zbajtmp/public/jqgrid/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);
 // Write the SQL Query
//$grid->SelectCommand = 'SELECT OrderID, OrderDate, CustomerID, Freight, ShipName  FROM orders';
$grid->SelectCommand = 'SELECT *  FROM clinic';
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model
//$grid->setColModel();
$mylabels = array(
"clinic_name"=>"Clinic ame",
"clinic_address"=>"Address",
"HomePhone"=>"Home Phone",
"WorkPhone"=>"Work Phone",
"Email_Id"=>"Email",
);
// Let the grid create the model with the desired labels
$grid->setColModel(null, null, $mylabels);

$grid->setColProperty("lat", array("hidden"=>true));
$grid->setColProperty("lng", array("hidden"=>true));
$grid->setColProperty("clinic_id", array("hidden"=>true));
$grid->setColProperty("id", array("hidden"=>true));
.....
.....
.....
// Set the url from where we obtain the data
//$grid->setUrl('/var/www/html/zbajtmp/application/views/scripts/clinic/grid.php');
$grid->setUrl('http://sunlinux/zbajtmp/application/views/scripts/clinic/grid.php');
// Set grid caption using the option caption
$grid->setGridOptions(array(
    "caption"=>"This is my custom Caption...",
    "rowNum"=>50,
    "sortname"=>"id",
    "hoverrows"=>true,
    "rowList"=>array(20,50,100,1000),
    "width"=>"100%",
    "height"=>350,
"footerrow"=>true,
"rownumbers"=>true,
"multiselect"=>true,
"altRows"=>true,
"altclass"=>'clsalt',
"loadtext"=>"<div class='loadingbox'>Please wait. Loading...</div>",

    ));


$grid->renderGrid('#grid','#pager',true, null, null, true,true);


$conn = null;