Forum


Quite simply actually, I do it with all my selectables:
Do this before you define the jqGrid and make sure async is set to false. If you do not set it to false, the grid will completely render before the data has retuened and the drop down box wil be empty.
var products = $.ajax({url: $('#ajaxAllProductsUrl').val(), async: false, success: function(data, result) {if (!result) alert('Failure to retrieve the Products.');}}).responseText;
The define your grid:
.jqGrid({
url: listURL,
postData: {ContractId : $('fieldset#ContractDetails #ContractId').val()},
datatype: “json”,
colNames:['Id', 'Product Name'],
colModel:[
{name:'Id', index:'Id', sortable:true, editrules:{edithidden:false}},
{name:'ProductName', index:'ProductName', sortable:true, required:true, editable:true, edittype:"select", editoptions:{value:products}, editrules:{required:true}}],
You can also do it on the loadComplete event by using setColProp, which I do in some other cases as if you are going to have modal boxes for editing it will generate a runtime error if you do not have it set the following way:
loadComplete: function() {$(item).setColProp('ProductName',{editoptions:{value:products}});
By the way “item” is the id of the grid. Hope this helps
03:34

Moderators
30/10/2007

Hello,
Thanks Renso.
Also the new option dataUrl can be used too - which I recommend.
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.
23:53

24/07/2009

I have a similar requirement but I need the contents of the select box to be different depending on the record being edited.
I tried calling
before firing
However, this only worked for the first call. Subsequent calls for other records would not change it.
I tried editing the SetColProp() function to make the extend a deep copy:
but this still didn't fix the problem.
Edit: I was able to fix this by adding
to
Most Users Ever Online: 715
Currently Online:
67 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