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

…
my html:
html, body {
margin: 0;
padding: 0;
font-size: 75%;
}

$(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
);
*/
});
my php main:
//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 = ““;
$s .= “
$s .= “
$s .= “
$s .= “
// be sure to put text data in CDATA
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= “
$s .= ““;
}
$s .= ““;
echo $s;
?>
my subgrid 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 ““;
echo “
// be sure to put text data in CDATA
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo “
echo “
echo “
echo “
echo “
echo “
echo “
echo “
echo “
echo “
echo ““;
}
echo ““;
?>
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top