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
setting the "editoption" 'value' field for a select box
23/06/2008
12:06
Avatar
stewbagz
New Member
Members
Forum Posts: 2
Member Since:
23/06/2008
sp_UserOfflineSmall Offline

First up, props for a super jQuery plugin - it really is very neat indeed!

I'm using jqgrid from a perl script, and I can't seem to craft an incantation to populate the a select box from a perl script. If I use a hard-coded values:"<blah>:<blah>;" field it's fine, but it doesn't solve my problem.

Please will someone post an example which shows how to do this? I've recoded it about 50 times to no avail 🙁 - I've tried using setColProp, setGridParam, $.get('/cgi-bin/blah') and onLoadComplete, and even tried specifying the url of the script in the editoptions: segment in the colModel, can't get it working.

Many thanks for your time and a great plugin!

Kind regs

Stew

23/06/2008
12:35
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

The last item should not have this ; at end - i.e the right is

item1:value1;item2:value2;...itemN:valueN

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.

24/06/2008
04:26
Avatar
stewbagz
New Member
Members
Forum Posts: 2
Member Since:
23/06/2008
sp_UserOfflineSmall Offline

Hi Tony,

Thanks for the response, but it's not quite what I'm after.

I've got a little perl script which returns the text (minus the trailing semi-colon) okay, I just can't force that data into the editoptions when the grid loads, i guess what I'm really after is how to craft a line along the following lines;

---

{name:'col1',index:'col1',editable:true,edittype:"select",editoptions:{value: $.get('http://localhost/cgi-bin/selec.....i&#39;)}},

---

(the above doesn't work,btw)

Where the editoptions are pulled from the .cgi script. I can see the script fire, I just can't get it fill the select box with the values (I've even tried getting the script to return a hand-coded list without the trailing semi-colon, and it still doesn't populate the select box)

Thanks for your time

Kind regs

Stew

24/06/2008
09:06
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Try first without cgi script. If all is ok then something with a call is not correct

Tony

P.S

Not sure if you can use get inside this. I recommend you call get before constructing the grid. Set the result in variable and put this in colModel

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.

18/07/2008
12:33
Avatar
ziv1848
New Member
Members
Forum Posts: 1
Member Since:
07/07/2008
sp_UserOfflineSmall Offline

Hi Tony!

This is my first post, so I'd like to take this opportunity to thank you

for the great job you've done.

I have the same problem, i.e. I'm trying to dynamically fill the select box

with the server-side data. I did what you've proposed:

1) call $.get() before constructing the grid

2)  put its result into a variable

3) set that variable in value:name pair of the select box editoptions

in colModel.

This didn't work because of $.get() executing  an AJAX call asynchronously

so that the abovementioned variable is assigned before the AJAX call is

finished and gets 'undefined' value accordingly.

The only way I found to make the stuff work is to use $.ajax() with async

set to 'false' ( instead of calling $.get() ) :

===========================

jQuery(document).ready(function(){

    var selectValue = $.ajax({

                url: "get_some_params_url",

                async: false

    }).responseText;

.............

    colModel : [

        ..........

        {

            edittype: "select",

            editoptions: {value: selectValue}

         },

        .........

    ],

}

========================

Which  is obviously not performance "friendly". It would be great to get

an option just to put a function making an AJAX call into 'editoptions', so

that the call will be fired off only when you click on a select box to pick the

value.

Thanks a lot.

20/07/2008
04:00
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

We have here a lot of possible solutions.

1. Setting the values direct via script - here is PHP example:

When you call the page with a grid - call it as php page and not as html

colModel [{....

{name:"mayname"...editable:true,edittype:"select",

editoptions:{'<?=$myeditoptions?>'}...},

...

]

where the variable $myeditoptions holds the values from the db

This is the recommendet solution. If this is not possible

2. We can use the method from previous post. We can cal this after the grid is constructed.It is not too late - why?

$.get(”myurl”,data:mydata,function(result,status){

if (status == “success”) {

// get the result here, suppose that in myselect are the values

$(”#mygrid”).setColProp(”myname”,{editoptions:{myselects}});

}

}

3. Another possible solution is to use the userData in jqGrid -

(this is another elegant solution). See userData examples haw to do that.

Then

loadComplete : function() {

// get the userData here and convert it to format supported

// in colModel then the same tehchniquie as from 2

$(”#mygrid”).setColProp(”myname”,{editoptions:{myselects}});

}

~Enjoy

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

Currently Online:
31 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