Home › Forums › Guriddo jqGrid JS › Help › Dynamic Select from url
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:
|
1 |
<span class="sc2"><<a href="http://december.com/html/4/element/select.html" target="_blank" rel="nofollow"><span class="kw2">select</span></a>></span> <br /><span class="sc2"><<a href="http://december.com/html/4/element/option.html" target="_blank" rel="nofollow"><span class="kw2">option</span></a> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">'FE'</span>></span> FedEx <span class="sc2"><<span class="sy0">/</span><a href="http://december.com/html/4/element/option.html" target="_blank" rel="nofollow"><span class="kw2">option</span></a>></span> <br /><span class="sc2"><<a href="http://december.com/html/4/element/option.html" target="_blank" rel="nofollow"><span class="kw2">option</span></a> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">'IN'</span>></span> InTime <span class="sc2"><<span class="sy0">/</span><a href="http://december.com/html/4/element/option.html" target="_blank" rel="nofollow"><span class="kw2">option</span></a>></span> <br /><span class="sc2"><<a href="http://december.com/html/4/element/option.html" target="_blank" rel="nofollow"><span class="kw2">option</span></a> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">'TN'</span>></span> TNT <span class="sc2"><<span class="sy0">/</span><a href="http://december.com/html/4/element/option.html" target="_blank" rel="nofollow"><span class="kw2">option</span></a>></span> <br /><span class="sc2"><<a href="http://december.com/html/4/element/option.html" target="_blank" rel="nofollow"><span class="kw2">option</span></a> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">'AR'</span>></span> ARAMEX <span class="sc2"><<span class="sy0">/</span><a href="http://december.com/html/4/element/option.html" target="_blank" rel="nofollow"><span class="kw2">option</span></a>></span> <br /><span class="sc2"><<span class="sy0">/</span><a href="http://december.com/html/4/element/select.html" target="_blank" rel="nofollow"><span class="kw2">select</span></a>></span> |
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 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 blablabla
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
Ok. So, I
The way is working is to make a not asyng call to your server and save the value before making your grid something like:
It's Work Great!
Thanks and sorry for the question. I
Hello,
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
I solved it. The problem was the version. By default the site didn
I'm using 3.5.3 and dataUrl is not working, while surl is. If the documentation out of date?
Hello,
This is not a serious post. No answer.
Regards
Tony
Sorry?
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 One Two. 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.
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 “”;
print '';
print “alfa romeo”;
print “ferrari”;
print “fiat”;
print '';
JavaScript:
{name:'car_name', index:'car', width:120, align:'center', editable:true, edittype:”select”, editoptions:{dataUrl:'cgi-bin/ccs_get_car.pl'}},
I still can't get it to work with dataUrl in searchoptions, just surl in colmodel. Does anyone know why?
Hello,
Which search module (method) do you use?
Please refer to docs and the important notes here:
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:search_config
Now I
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top