【问题标题】:Jquery Jqgrid display image in grid?Jquery Jqgrid在网格中显示图像?
【发布时间】:2011-08-23 22:33:43
【问题描述】:

这是我的代码:

<?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);
// Write the SQL Query
$grid->SelectCommand = 'SELECT p.product_id, p.product_title, p.product_image1_t2, pc.product_cat_name, b.brand_name FROM ' . DB_PRODUCTS .'  p INNER JOIN ' . DB_PRODUCT_CATS . ' pc ON p.product_cat_id=pc.product_cat_id LEFT JOIN ' . DB_BRANDS . ' b ON b.brand_id=pc.product_cat_brand_id';
// set the ouput format to json
$grid->dataType = 'json';
// Let the grid create the model from SQL query
$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,
    "sortname"=>"product_id",
    "rowList"=>array(10,20,50),
    "height"=>'auto',
    "grouping"=>true,
    "groupingView"=>array(
        "groupField" => array('brand_name'),
        "groupColumnShow" => array(true),
        "groupText" =>array('<b>{0}</b>'),
        "groupDataSorted" => true

    ) 
    ));
// Change some property of the field(s)
$grid->setColProperty("product_id", array("label"=>"NO", "width"=>60));
$grid->setColProperty("brand_name", array("label"=>"BRAND"));
$grid->setColProperty("product_title", array("label"=>"PRODUCT NAME"));
$grid->setColProperty("product_cat_name", array("label"=>"CATEGORY"));
$grid->setColProperty("product_image1_t2", array("label"=>"PRODUCT PHOTO"));
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>

所以,我成功获取了全部数据,但是当我调用此文件时,我在“product_image1_t2”(产品照片)网格中看到的只是我的文件名,例如: “image_file.jpg”。我想显示的图像类似于显示的内容

<img src="myfile.jpg" alt="my_file.jpg" />

已经查了手册但是不明白,所以我是 jquery 的新手...

你能帮我看看这个例子怎么做吗? 在这里你可以看到当前的结果:

http://oi55.tinypic.com/11qolsz.jpg

【问题讨论】:

    标签: php jquery mysql jqgrid-php


    【解决方案1】:

    查看the JQGrid forum,有几个线程讨论如何将图像集成到网格中,例如this one 或在SO 上,image column in jqGrid?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-09
      • 1970-01-01
      • 1970-01-01
      • 2011-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多