有一个网格需要在同一列中具有不同选项值的选择框。例如,在试图解决这个问题的测试网格中,概念是使用选择框从电影中选择一个演员。每行都有不同电影的数据。在每一行内,actors列都有一个不同的actor列表,这些列表需要用来动态填充该行的选择框。演员名单设置为CSV,逗号分隔值,在数据库中:I.E.,Clint Eastwood,Tom Cruz,Vin Diesel。使用jqGrid具有不同选项的单列选择框
从测试完成后,看起来像一旦建立了列模型,它只在每个网格加载时执行一次,这意味着您只能获得列中所有选择框的一组选项。通过设置一个循环块,在填充网格的php文件(在本例中为myfirtgridajax.php)中生成适当的代码并将其显示为功能时,已成功将具有所需值的html字符串作为返回数据传递给网格用正确的价值观选择框,它不会那样做是在列模型时置一个选择框使用
{... edittype:select, edit options:{value:{CE:'Clint Eastwood'... }}}
我们需要的是,生成一个POST请求的onChange或具有相同的结果的东西,从选择框将在数据库中设置另一个值。也就是说,如果选择了Clint Eastwood,则需要生成POST请求以将该值传递给另一个php页面进行处理。
我的问题是,虽然看起来像通过传递一个HTML字符串创建的选择框上的黑客设置事件侦听器,是否有更好的方法来做到这一点?
<script>
$(function() {
$('#displayresultstable').jqGrid({
url:'../gridcalls/myfirstgridajax.php',
datatype:'json',
mtype: 'GET',
colNames:['ID', 'movie', 'topic', 'rating','actors'],
colModel :[
{name:'ID', index:'ID', width:50},
{name:'movie', index:'movie', width:200, editable:true},
{name:'topic', index:'topic', width:350, editable:true},
{name:'rating', index:'rating', width:50, editable:true },
{name:'actors', index:'actors', width:350, editable:true },
],
pager: '#pager',
rowNum:10,
height: 'auto',
rowList:[5,10,15],
sortname:'ID',
sortorder: 'desc',
viewrecords: true,
gridview: true,
cellEdit: true,
cellurl:'../editfirstgridajax.php',
caption: 'Movie Greats'
});
$('#displayresultstable').jqGrid('navGrid','#pager', {view: true});
});
</script>
<table id='displayresultstable'>
<tr><td></td></tr>
</table>
<div id='pager'></div>
感谢