This article will share with you a piece of code about the skill of jqgrid dynamically filling the option value of the select drop-down box. I won’t say much more. I will directly paste the code for you. The specific code is as follows:
function gettypes(){ //动态生成select内容 var str=""; $.ajax({ type:"post", async:false, url:"checkpersontype", success:function(data){ if (data != null) { var jsonobj=eval(data); var length=jsonobj.length; for(var i=0;i<length;i++){ if(i!=length-1){ str+=jsonobj[i].personType+":"+jsonobj[i].personType+";"; }else{ str+=jsonobj[i].personType+":"+jsonobj[i].personType;// 这里是option里面的 value:label } } //$.each(jsonobj, function(i){ //str+="personType:"+jsonobj[i].personType+";" //$("<option value='" + jsonobj[i].personType + "'>" + jsonobj[i].personType+ "</option>").appendTo(typeselect); //}); } alert(str); } }); return str; }
Note: To return and async:false otherwise have no effect
Set edittype:'select',editoptions:{value:gettypes()} in colModel: and it will be ok.
The above is the option value (dynamic filling) of the jQGrid select drop-down box that the editor introduces to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will Reply to everyone promptly. I would also like to thank you all for your support of the PHP Chinese website!
For more articles related to jQGrid dynamically filling the option value of the select drop-down box (dynamic filling), please pay attention to the PHP Chinese website!