Home > Web Front-end > JS Tutorial > jQGrid dynamically fills the option value of the select drop-down box (dynamic filling)

jQGrid dynamically fills the option value of the select drop-down box (dynamic filling)

高洛峰
Release: 2017-01-03 16:34:43
Original
2161 people have browsed it

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=&#39;" + jsonobj[i].personType + "&#39;>" + jsonobj[i].personType+ "</option>").appendTo(typeselect); 
//}); 
} 
alert(str); 
} 
}); 
return str; 
}
Copy after login

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!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template