Forum


08:03

16/02/2012

Question about dynamic select in JqGrid. In the window when editing or addingentries have two select the choice of the value of the first select list to change the listof the second, data is retrieved from the database. With the first selector figured out,but the second is not clear: how to change the first select call a script for a second?
piece of code
Formation of the table:
colModel: [{name: 'idObjectProject', index: 'idObjectProject', width: 300, editable: true, edittype: "select", editoptions: {dataUrl: 'test.php'}},
{name: 'idWorkProject', index: 'idWorkProject', width: 300, editable: true, edittype: "select", editoptions: {dataUrl: 'test1.php'}}],
Thank you all in advance
08:39

Moderators
30/10/2007

Hello,
You can find here a lot of posts regarding this:
By example you can search with "depend listbox" and etc
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
15:13

16/02/2012

i do like that i find in example from
/blog/?page_id=393/help/dynamically-populate-select-dropdown/&value=dataEvents&type=1&include=1&search=1&ret=all
piece of code from link which i use
colModel:[
...
{name:'select_one',
editable: true,
edittype:"select",
editoptions: {
dataUrl:'test_one.php',
dataEvents :[
{ type: 'change', fn: function(e) {
var thisval = $(e.target).val();
$.get('test_two.php?myid='+thisval, function(data)
{ var res = $(data).html();
$("#select_two").html(res);
}); // end get
}//end func
} // end type
] // dataevents
} // edit option
},
{name:'select_two',editable: true,edittype:"select", editoptions:{dataUrl:'test_two.php?myid=initialid'}}
…
],
Piece my code for initialization table
colModel :[
{name:'place3_id', index:'place3_id', width:30,align:'left',sortable:true},
{name:'place1_id', index:'place1_id', width:64, align:'left', editable:true, edittype:'text',sortable:true,edittype:'select',
editoptions:{dataUrl:'drplace3_ld_place1_short_value.php',dataEvents :[{type: 'change',
fn: function(e)
{
var thisval = $(e.target).val();
$.get('drplace3_ld_place2_value.php?place1_id='+thisval,
function(data)
{var res = $(data).html();
$("#place2_id").html(res);
}); // end get
}//end func
} // end type
],// dataevents
}},
{name:'place2_id', index:'place2_id', width:32, align:'left', editable:true, edittype:'text',sortable:true,
editoptions:{dataUrl:'drplace3_ld_place2_value.php?place1_id=initialid'},edittype:'select'},
{name:'place3_value', index:'place3_value',width:32,align:'left',editable:true,edittype:'text',sortable:true}
],//colModel
drplace3_ld_place1_short_value.php
<?php
$tsql = "SELECT place1_id,place1_short_value From drplace1";
$stmt = sqlsrv_query($conn1, $tsql);
print "<select>";
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC))
{
print "<option value=".$row['place1_id'].">".$row['place1_short_value']."</option>";
}
print "</select>";
sqlsrv_free_stmt( $stmt );
sqlsrv_close( $conn1 );
?>
drplace3_ld_place2_value.php
<?php
$place1_id = $_GET['place1_id'];
$tsql = "SELECT place2_id,place2_value From drplace2 where place1_id=?";
$params = array(&$place1_id);
$stmt = sqlsrv_prepare($conn1,$tsql,$params);
sqlsrv_execute( $stmt);
print "<select>";
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC))
{
print "<option value=".$row['place2_id'].">".$row['place2_value']."</option>";
}
print "</select>";
sqlsrv_free_stmt( $stmt );
sqlsrv_close( $conn1 );
?>
My second drob-down list is empty help please
04:03

16/03/2012

Can anyone help me with the issue that my dropdown list display nothing?
in html:
{name:'obsolete',index:'obsolete',align:'center',edittype:"select",editoptions: {dataUrl:'server.php?q=234'},editable: true}
in server.php:
case 234:
echo "<select>
<option value='4'>3</option><option value='1'>2</option>
</select>";
break;
Why the listbox return nothing? Please help. Thanks
Most Users Ever Online: 715
Currently Online:
60 Guest(s)
Currently Browsing this Page:
2 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66