Forum
Topic RSS
I´m trying to make a Select Column but with data from a database. Looking at the wiki (http://www.trirand.com/jqgridw.....s#edittype) I found that the dataurl parameter let you load the select from url, so i do :
...
{name:'cdu223',index:'cdu223', editable:true,edittype:'select', editoptions:{dataUrl:'Opc/demo.php'}},
....
where demo.php is very simple:
echo "<select>
<option value='1'>Valor 1</option>
<option value='2'>Valor 2</option>
<option value='3'>Valor 3</option>
</select>";
Nothing happens. ¿someone can help me please?
Thanks
i think that demo.php would have to return the data in an established format.
the format for select is:
{name:'ship',index:'ship', width:90, editable: true,edittype:”select”,
editoptions:{value:”FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX”}},
this will construct:
<select>
<option value='FE'> FedEx </option>
<option value='IN'> InTime </option>
<option value='TN'> TNT </option>
<option value='AR'> ARAMEX </option>
</select>
if u want to populate your select with data from database
you need to:
$sql = “select data from database”;
$result = $mysql_query($sql);
$arr = mysql_fetch_array($result);
echo json_encode($arr);
something like this
Best regards,
Adrian
Sorry but I don't understand your answer.
¿you say that the demo.php file needs to return an json encoder format result? not select?
If you check de "dataUrl" at editoptions on Wiki it says that <select> have to be the return text.
If I use the content like you are saying How I make the call from "colModel" ?
Thanks a lot!
you have to do json_encode if your grid data type is json
if it is xml then i think you can use echo
anyway u didn;t understand what
the wiki learned you 😛
it says there that it constructs <select>blablabla</select>
but in your js file you call for demo.php
that should return an array of type
”FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX”
In your case it will be: 1:valor 1, 2:valor2... etc
read carefully the wiki... it is well written
so you need to do as i wrote upper
make the select
execute it
fetch the result into an array
and echo it to js
good luck
20:55
22/12/2008
OfflineThe way is working is to make a not asyng call to your server and save the value before making your grid something like:
// get your slectfor edit
var dll= $.ajax({
url: 'Opc/demo.php'
, async: false
}).responseText;
then {name:'cdu223',index:'cdu223', editable:true,edittype:'select', editoptions:{ value: dll}},
04:53
Moderators
30/10/2007
OfflineHello,
Tha dataUrl parameter should work. You will need just to check when you edit row if the url is correct and this url return the values.
Regards
Tony
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.
12:14
Moderators
30/10/2007
OfflineHello,
This is not a serious post. No answer.
Regards
Tony
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.
19:05
02/09/2009
OfflineSorry?
Looking at the documentation here I see dataUrl mentioned:
This option is valid only for the elements of type select - i.e stype:'select'. The option represent the url from where we load the select element. When this option is set the element will be filled with values from the ajax request. The data should be a valid html select element with the desired options. By example the request should contain <select><option value=“1”>One</option> <option value=“2”>Two</option></select>. This is called only once.
But dataUrl, as reported by others, isn't working, while surl is. So I was just asking if the docs are out of date, or where I should look to see it documented.
07:30
Hi all! I'm now using dataUrl. It's succ works with XML.
My example here:
CGI scenario (perl)
my $cgi = new CGI;
print $cgi->header("Content-type: text/xml;charset=windows-1251");
print "<?xml version='1.0' encoding='windows-1251'?>";
print '<select>';
print "<option value='2'>alfa romeo</option>";
print "<option value='4'>ferrari</option>";
print "<option value='30017'>fiat</option>";
print '</select>';
JavaScript:
{name:'car_name', index:'car', width:120, align:'center', editable:true, edittype:"select", editoptions:{dataUrl:'cgi-bin/ccs_get_car.pl'}},
03:34
Moderators
30/10/2007
OfflineHello,
Which search module (method) do you use?
Please refer to docs and the important notes here:
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.
Now I´m trying to make dynamic dropdown but I have a problem, it loads only once
here is the code:
{name:'id384',index:'id384',
sortable:true,
editable:true,
edittype:"select",
editoptions:{dataUrl:'Opc/HlpTabla.php?zTabla=st384',
dataEvents: [
{ type: 'change',
fn: function(e) {
alert($("#id384").val());
$("#id195").parent().load('Opc/HlpTabla.php?zTabla=st195&key=id384&val='+$("#id384").val());
}
}],}
},
{name:'id195',index:'id195',
sortable:true,
editable:true,
edittype:"select",
editoptions:{value:{}}
},
The HlpTabla.php return something live "<select><option></option>...</select>"
Fisrt time it loads ok and works but if I change the id384 contents it doesn´t update the id195 select
Thanks for help me.
Martin
07:40
02/09/2009
Offlinetony said:
Hello,
Which search module (method) do you use?
Please refer to docs and the important notes here:
http://www.trirand.com/jqgridw.....rch_config
I read the docs thoroughly, I'm using inline editing.
05:56
Moderators
30/10/2007
OfflineHello,
Simone, please be a more precise. What you use actually? In the previous post you tell me that only surl work.
The surl option is used in search modules - especially in filterGrid and filterToolbar methods.
In order to be clear, please post your code and tell me what you try to do.
Reagrds
Tony
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.
06:59
@Varta: I've got the same problem. I try to populate a second select with the result of a first one. Anybody help me?
My code:
//PAIS (Visible)
{ name:'pais',
index:'pais',
width:90,
align: "center",
// --- Edición ---
editable:true,
formoptions:{elmprefix:"(*)" },
editrules:{required:true},
edittype: 'select',
editoptions: {
dataEvents: [{
type: 'change',
fn: function(e) {
var codpais = e.currentTarget.value;
var prov = $.ajax ({
url: 'dbprovincia.php?p='+codpais,
async: false}).responseText;
$("#grid").setColProp('provincia', {editoptions: {dataUrl: prov }});
}
}],
dataUrl: 'dbpais.php',
defaultValue: 'España',
},
},
//PROVINCIA (Oculto)
{ name:'provincia',
index:'provincia',
width:90,
align: "center",
// --- Edición ---
editable:true,
hidden: true,
formoptions:{elmprefix:"(*)" },
editrules: {edithidden: true, required:true},
edittype:'select',
editoptions: {
dataUrl: 'dbpronvicias.php',
},
},
Thanks!
Most Users Ever Online: 994
Currently Online:
43 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66
Log In
Home