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_TopicIcon
Cascade drop-down lists in the jqgrid
16/02/2012
08:03
Avatar
oruc
Member
Members
Forum Posts: 4
Member Since:
16/02/2012
sp_UserOfflineSmall Offline
Hello!
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

16/02/2012
08:39
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

16/02/2012
08:56
Avatar
oruc
Member
Members
Forum Posts: 4
Member Since:
16/02/2012
sp_UserOfflineSmall Offline

Thanks my brather i find same topics

16/02/2012
15:13
Avatar
oruc
Member
Members
Forum Posts: 4
Member Since:
16/02/2012
sp_UserOfflineSmall Offline

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

16/02/2012
17:38
Avatar
oruc
Member
Members
Forum Posts: 4
Member Since:
16/02/2012
sp_UserOfflineSmall Offline

Resolved the problem

use this

editoptions:{dataUrl:'drplace3_ld_place2_value.php?place1_id=0'}

 php

if($place1_id='0')

{

.....

}

Thanks

16/03/2012
04:03
Avatar
twenjie88
New Member
Members
Forum Posts: 1
Member Since:
16/03/2012
sp_UserOfflineSmall Offline

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

Forum Timezone: Europe/Sofia

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.com

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information