Forum


02:36

21/10/2008

Hii,
How can i use data to be populated to a field of edittype: select, from database instead of using editoptions: {value: some values}. I cannot hardcode these value and has to populate from database. How can i do this?
Since surl can be used only with filter grid, i cannot use that too.
Thanks in advance.
Regards,
Prathap.
02:49

Moderators
30/10/2007

Hello,
I will try to add this in next release. For now you can use a combination of loadComplete event again with setColProp to add extra fields of the select dynamically.
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.
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.
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
Most Users Ever Online: 715
Currently Online:
37 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