Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
problem with subgrid
26/04/2012
20:56
Avatar
dido
New Member
Members
Forum Posts: 2
Member Since:
26/04/2012
sp_UserOfflineSmall Offline

hi, i need help for a simple subgrid that doesn't work...someone can have look my code please?CryCryCry...

my html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>My First Grid</title>

<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.7.3.custom.css" />

<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />

<style type="text/css">

html, body {

margin: 0;

padding: 0;

font-size: 75%;

}

</style>

<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>

<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>

<script src="js/jquery.jqGrid.src.js" type="text/javascript"></script>Cry

<script type="text/javascript">

$(function(){

$("#list").jqGrid({

url:'montecrestese.php',

datatype: 'xml',

height: 400,

width: 1300,

mtype: 'GET',

colNames:['id_scheda','frazione', 'agglomerato','foglio','mappale','dest_uso1','dest_uso2','dest_uso3','piani','abitato','stato_edificio','ristrutturazione_consolidamenti','materiale_copertura','tipologia_copertura','comignoli','stato_copertura','foto'],

colModel :[

{name:'id_scheda', index:'id_scheda', width:50},

{name:'frazione', index:'frazione', width:50},

{name:'agglomerato', index:'agglomerato', width:50, align:'right'},

{name:'foglio', index:'foglio', width:50, align:'right'},

{name:'mappale', index:'mappale', width:50, align:'right'},

{name:'dest_uso1', index:'dest_uso1', width:50, sortable:false},

{name:'dest_uso2', index:'dest_uso2', width:50, sortable:false},

{name:'dest_uso3', index:'dest_uso3', width:50, sortable:false},

{name:'piani', index:'piani', width:50, sortable:false},

{name:'abitato', index:'abitato', width:50, sortable:false},

{name:'stato_edificio', index:'stato_edificio', width:50, sortable:false},

{name:'ristrutturazioni_consolidamenti', index:'ristrutturazione_consolidamenti', width:50, sortable:false},

{name:'materiale_copertura', index:'materiale_copertura', width:50, sortable:false},

{name:'tipologia_copertura', index:'tipologia_copertura', width:50, sortable:false},

{name:'comignoli', index:'comignoli', width:50, sortable:false},

{name:'stato_copertura', index:'stato_copertura', width:50, sortable:false},

{name:'foto', index:'foto', width:50, sortable:false}

],

pager: '#pager',

rowNum:100,

rowList:[10,20,30],

sortname: 'id_scheda',

sortorder: 'desc',

viewrecords: true,

gridview: true,

caption: 'tabella schede',

shrinkToFit: true,

altRows: true,

subGrid: true,

subGridUrl : "subgrid.php",

subGridModel : [

{

name : ['id_prospetti', 'orientamento', 'muratura', 'cantonali_gerarchizzati', 'elementi_interesse', 'elementi_interesse', 'loggiato', 'balconata','terrazza','ref_scheda'],

width : [80, 80, 80, 80, 80, 80, 80, 80, 80, 80],

align : ['left','left','right','right','right','right','right','right','right','right'],

}

]

}).navGrid('#pager',{view:true, add:false, del:false, edit:false},

{}, // use default settings for edit

{}, // use default settings for add

{}, // delete instead that del:false we need this

{multipleSearch : true}, // enable the advanced searching

{closeOnEscape:true} /* allow the view dialog to be closed when user press ESC key*/

);

/* $("#prospetti").jqGrid({

url:'prospetti.php',

datatype: 'xml',

height: 400,

width: 1300,

mtype: 'GET',

colNames:['id_prospetti', 'orientamento', 'muratura', 'cantonali_gerarchizzati', 'elementi_interesse','loggiato','balconata','terrazza','ref_scheda'],

colModel :[

{name:'id_prospetti', index:'id_prospetti', width:50},

{name:'orientamento', index:'orientamento', width:50},

{name:'muratura', index:'muratura', width:50, align:'right'},

{name:'cantonali_gerarchizzati', index:'cantonali_gerarchizzati', width:50, align:'right'},

{name:'elementi_interesse', index:'elementi_interesse', width:50, align:'right'},

{name:'loggiato', index:'loggiato', width:50, sortable:false},

{name:'balconata', index:'balconata', width:50, sortable:false},

{name:'terrazza', index:'terrazza', width:50, sortable:false},

{name:'ref_scheda', index:'ref_scheda', width:50, sortable:false},

],

pager: '#pager2',

rowNum:100,

rowList:[10,20,30],

sortname: 'id_prospetti',

sortorder: 'desc',

viewrecords: true,

gridview: true,

caption: 'tabella prospetti',

shrinkToFit: true,

altRows: true,

}).navGrid('#pager2',{view:true, add:false, del:false, edit:false},

{}, // use default settings for edit

{}, // use default settings for add

{}, // delete instead that del:false we need this

{multipleSearch : true}, // enable the advanced searching

{closeOnEscape:true} /* allow the view dialog to be closed when user press ESC key

);

*/

});

</script>

</head>

<body>

<table id="list"></table>

<div id="pager"></div>

</body>

</html>

my php main:

<?php

//include the information needed for the connection to MySQL data base server.

// we store here username, database and password

include("dbconfig.php");

// to the url parameter are added 4 parameters as described in colModel

// we should get these parameters to construct the needed query

// Since we specify in the options of the grid that we will use a GET method

// we should use the appropriate command to obtain the parameters.

// In our case this is $_GET. If we specify that we want to use post

// we should use $_POST. Maybe the better way is to use $_REQUEST, which

// contain both the GET and POST variables. For more information refer to php documentation.

// Get the requested page. By default grid sets this to 1.

$page = $_GET['page'];

// get how many rows we want to have into the grid - rowNum parameter in the grid

$limit = $_GET['rows'];

// get index row - i.e. user click to sort. At first time sortname parameter -

// after that the index from colModel

$sidx = $_GET['sidx'];

// sorting order - at first time sortorder

$sord = $_GET['sord'];

// if we not pass at first time index use the first column for the index or what you want

if(!$sidx) $sidx =1;

// connect to the MySQL database server

$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());

// select the database

mysql_select_db($database) or die("Error connecting to db.");

// calculate the number of rows for the query. We need this for paging the result

$result = mysql_query("SELECT COUNT(*) AS count FROM schede");

$row = mysql_fetch_array($result,MYSQL_ASSOC);

$count = $row['count'];

// calculate the total pages for the query

if( $count > 0 && $limit > 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

$SQL = "SELECT * FROM schede ORDER BY $sidx $sord LIMIT $start , $limit";

$result = mysql_query( $SQL ) or die("Couldn't execute query.".mysql_error());

// we should set the appropriate header information. Do not forget this.

header("Content-type: text/xml;charset=utf-8");

$s = "<?xml version='1.0' encoding='utf-8'?>";

$s .= "<rows>";

$s .= "<page>".$page."</page>";

$s .= "<total>".$total_pages."</total>";

$s .= "<records>".$count."</records>";

// be sure to put text data in CDATA

while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {

$s .= "<row id='". $row['id_scheda']."'>";

$s .= "<cell>". $row['id_scheda']."</cell>";

$s .= "<cell>". $row['frazione']."</cell>";

$s .= "<cell>". $row['agglomerato']."</cell>";

$s .= "<cell>". $row['foglio']."</cell>";

$s .= "<cell>". $row['mappale']."</cell>";

$s .= "<cell>". $row['dest_uso1']."</cell>";

$s .= "<cell>". $row['dest_uso2']."</cell>";

$s .= "<cell>". $row['dest_uso3']."</cell>";

$s .= "<cell>". $row['piani']."</cell>";

$s .= "<cell>". $row['abitato']."</cell>";

$s .= "<cell>". $row['stato_edificio']."</cell>";

$s .= "<cell>". $row['ristrutturazioni_consolidamenti']."</cell>";

$s .= "<cell>". $row['materiale_copertura']."</cell>";

$s .= "<cell>". $row['tipologia_copertura']."</cell>";

$s .= "<cell>". $row['comignoli']."</cell>";

$s .= "<cell>". $row['stato_copertura']."</cell>";

$s .= "<cell><![CDATA[". $row['foto']."]]></cell>";

$s .= "</row>";

}

$s .= "</rows>";

echo $s;

?>

my subgrid php:

<?php

// get the id passed automatically to the request

$id = $_GET['id'];

// get the invoice date passed to this request via params array in

//subGridModel. We do not use it here - this is only demostration

//$date_inv = $_GET['id'];

suboptions = {

plusicon : "ui-icon-plus",

minusicon : "ui-icon-minus",

openicon: "ui-icon-carat-1-sw",

expandOnLoad: true,

delayOnLoad : 50,

selectOnExpand : false,

reloadOnExpand : true

};

// connect to the database

$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());

mysql_select_db($database) or die("Error conecting to db.");

// construct the query suboptions = {

plusicon : "ui-icon-plus",

minusicon : "ui-icon-minus",

openicon: "ui-icon-carat-1-sw",

expandOnLoad: false,

delayOnLoad : 50,

selectOnExpand : false,

reloadOnExpand : true

};

$SQL = "SELECT * FROM prospetti WHERE ref_scheda=".$id."";

$result = mysql_query( $SQL ) or die("Couldn?t execute query.".mysql_error());

// set the header information

if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {

header("Content-type: application/xhtml+xml;charset=utf-8");

} else {

header("Content-type: text/xml;charset=utf-8");

}

echo "<?xml version='1.0' encoding='utf-8'?>";

echo "<rows>";

// be sure to put text data in CDATA

while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {

echo "<row>";

echo "<cell>". $row[id_prospetti]."</cell>";

echo "<cell>". $row[orientamento]."</cell>";

echo "<cell>". $row[muratura]]."</cell>";

echo "<cell>". $row[cantonali_gerarchizzati]."</cell>";

echo "<cell>". $row[elementi_interesse]."</cell>";

echo "<cell>". $row[loggiato]."</cell>";

echo "<cell>". $row[balconata]."</cell>";

echo "<cell>". $row[terrazza]."</cell>";

echo "<cell>". $row[ref_scheda]."</cell>";

echo "</row>";

}

echo "</rows>";

?>

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information