Forum


11:31

17/06/2009

I have a column marked as "select" and I would like to dynamically specify the values from server. I have JSON/normal string ready from server.
I have tried to do ajax or $.JSON call, and the string is returned correctly as :
var locationData= ...get string from server;
and in colModal:
{
name: 'locations',
index: 'locations',
width: 300,
height: 800,
editable: true,
hidden: true,
edittype: "select",
editoptions: {
multiple: true,
value: locationData
},
editrules: {
edithidden: true,
required: true
}
}
it did not work! However if I specify the same string statically, it worked:
locationData = "1:loation1; 2:location2";
Burt
08:53

24/06/2009

Hi Burt,
I just have the same problem, but I made a little trick to solve it, I don't know if there is another solution. By now I want to search my code with you.
I declare and input hidden and ther is where I put the values that I need in the select.
$(document).ready(function(){
$.ajax({
url:'tipomaquina.do?methodCall=getOptions',
async : false, //notice that async has to be false
success: function(datos){
$("#datos").val(datos);
}
});
var idArea = $("#areas :selected").val();
$("#table1").jqGrid({
url:'tipomaquina.do?methodCall=fillTable&idArea='+idArea,
datatype: 'xml',
colNames:['Tipo de Maquina','Area'],
colModel:[ {name:'tipoMaquina',index:'tipoMaquina', width:200, editable:true, edittype:'text',editrules:{required:true,size:30}},
{name:'area',index:'area', width:200, editable:true,edittype:'select',editoptions:{value:getOptions()},editrules:{required:true}}],
rowNum:5,
imgpath: gridimgpath,
viewrecords: true,
pager: $('#footer1'),
caption:'Tipo de Máquina',
editurl:'someurl'
}).navGrid('#footer1',{edit:true,add:true,del:true,refresh:true,search:false,view:false},
{height:280,reloadAfterSubmit:true,top:130,left:500,url:'tipomaquina.do?methodCall=edit',closeAfterEdit:true},
{height:280,reloadAfterSubmit:true,top:130,left:500,url:'tipomaquina.do?methodCall=add'},
{height:150,reloadAfterSubmit:true,top:130,left:500,url:'tipomaquina.do?methodCall=delete'},
{});
function getOptions(){
return $("#datos").val();
}
$("#areas").change(function(){
var idArea = $("#areas :selected").val();
$("#table1").setGridParam({url:'tipomaquina.do?methodCall=fillTable&idArea=' + idArea,page:1}).trigger("reloadGrid");
});
});
Hope this is useful to you. If there is someone that have another solution please let use know.
Thanks,
Sara
Most Users Ever Online: 715
Currently Online:
68 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