<! Doctype html public "-// w3c // dtd xhtml 1.0 strict // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <Html> <Head> <Title> jqgrid php demo </title> <Meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <Link rel = "stylesheet" type = "text/css tutorial" media = "screen" href = ".../themes/redmond/jquery-ui-1.7.1.custom.css"/> <Link rel = "stylesheet" type = "text/css" media = "screen" href = ".../themes/ui.jqgrid.css"/> <Link rel = "stylesheet" type = "text/css" media = "screen" href = ".../themes/ui.multiselect.css"/> <Style type = "text"> Html, body { Margin: 0;/* remove body margin/padding */ Padding: 0; Overflow: hidden;/* remove scroll bars on browser window */ Font-size: 75%; } </Style> <Script src = ".../webpage effects/jquery. Webpage effects" type = "text/webpage effects"> </script> <Script src = "../js/i18n/grid. Locale-en.js" type = "text/webpage effects"> </script> <Script type = "text/javascript"> $. Jgrid. no_legacy_api = true; $. Jgrid. usejson = true; </Script> <Script src = ".../../js/jquery. jqgrid. min. js" type = "text/javascript"> </script> <Script src = "..././js/jquery-ui-1.7.2.custom.min.js" type = "text/javascript"> </script> </Head> <Body> <Div> <? Php include ("grid. php");?> </Div> <Br/> <? Php tabs (array ("grid. php");?> </Body> </Html> Php code <? 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 orderid, orderdate, customerid, freight, shipname from longorders '; // Set the ouput 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 '); $ Grid-> optimizesearch = true; // Set some grid options $ Grid-> setgridoptions (array ("rownum" => 100, "sortname" => "orderid", "height" => 150 )); // Change some property of the field (s) $ Grid-> setcolproperty ("orderdate", array ( "Formatter" => "date ", "Formatoptions" => array ("srcformat" => "y-m-d h: I: s", "newformat" => "m/d/y "), "Search" => false ) ); // Enable toolbar searching $ Grid-> toolbarfilter = true; $ Grid-> setfilteroptions (array ("stringresult" => true )); // Enjoy $ Grid-> rendergrid ('# grid',' # pager ', true, null, null, true, true ); $ Conn = null; ?> |