Forum

July 12th, 2025
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
Dynamic Select from url
22/09/2009
07:24
Avatar
varta
Member
Members
Forum Posts: 10
Member Since:
22/09/2009
sp_UserOfflineSmall Offline

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

22/09/2009
10:32
Avatar
AdytmRO
Romania
Member
Members
Forum Posts: 24
Member Since:
16/09/2009
sp_UserOfflineSmall Offline

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

22/09/2009
16:07
Avatar
varta
Member
Members
Forum Posts: 10
Member Since:
22/09/2009
sp_UserOfflineSmall Offline

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!

22/09/2009
17:13
Avatar
AdytmRO
Romania
Member
Members
Forum Posts: 24
Member Since:
16/09/2009
sp_UserOfflineSmall Offline

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

22/09/2009
17:39
Avatar
varta
Member
Members
Forum Posts: 10
Member Since:
22/09/2009
sp_UserOfflineSmall Offline

Ok. So, I´m using json

I create the select column and I create the demo.php file that echo json data.

Now. ¿How I assign the data in the select?

Thanks.

22/09/2009
20:55
Avatar
MamaliFrenchi
Member
Members
Forum Posts: 62
Member Since:
22/12/2008
sp_UserOfflineSmall Offline

The 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}},

23/09/2009
05:27
Avatar
varta
Member
Members
Forum Posts: 10
Member Since:
22/09/2009
sp_UserOfflineSmall Offline

It's Work Great!

Thanks and sorry for the question. I´m new with Jqgrid

the command dataUrl doesn´t work for this?

Thanks!

25/09/2009
04:53
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

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

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.

25/09/2009
12:34
Avatar
varta
Member
Members
Forum Posts: 10
Member Since:
22/09/2009
sp_UserOfflineSmall Offline

I solved it. The problem was the version. By default the site didn´t download 3.5 

Now is working! Sorry and thanks!

martin

29/09/2009
08:30
Avatar
Simone
Member
Members
Forum Posts: 8
Member Since:
02/09/2009
sp_UserOfflineSmall Offline

I'm using 3.5.3 and dataUrl is not working, while surl is. If the documentation out of date?

29/09/2009
12:14
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

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.

29/09/2009
19:05
Avatar
Simone
Member
Members
Forum Posts: 8
Member Since:
02/09/2009
sp_UserOfflineSmall Offline

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

01/10/2009
07:30
Avatar
Totti
Guest
Guests

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'}},

01/10/2009
09:25
Avatar
Simone
Member
Members
Forum Posts: 8
Member Since:
02/09/2009
sp_UserOfflineSmall Offline

I still can't get it to work with dataUrl in searchoptions, just surl in colmodel. Does anyone know why?

03/10/2009
03:34
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Which search module (method) do you use?

Please refer to docs and the important notes here:

http://www.trirand.com/jqgridw.....rch_config

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.

03/10/2009
07:20
Avatar
varta
Member
Members
Forum Posts: 10
Member Since:
22/09/2009
sp_UserOfflineSmall Offline

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

03/10/2009
07:40
Avatar
Simone
Member
Members
Forum Posts: 8
Member Since:
02/09/2009
sp_UserOfflineSmall Offline

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

06/10/2009
05:56
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

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.

27/10/2009
06:59
Avatar
bitelemental
Guest
Guests

@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!

Forum Timezone: Europe/Sofia

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

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information