Javascript JqGrid选择器选项“未定义”
我将向jqGrid添加一个新字段,该字段充当表之间的外键,但我使用的选择器只是一组选项,它们都表示“未定义”。我已经在我的网站的其他地方使用了下面的方法,但我不明白为什么它在这里不起作用。这是一个django网站 视图: JS:Javascript JqGrid选择器选项“未定义”,javascript,django,jqgrid,Javascript,Django,Jqgrid,我将向jqGrid添加一个新字段,该字段充当表之间的外键,但我使用的选择器只是一组选项,它们都表示“未定义”。我已经在我的网站的其他地方使用了下面的方法,但我不明白为什么它在这里不起作用。这是一个django网站 视图: JS: 看一下拼写错误:tempalte_选项应该是导出视图中的模板_选项Infodict['tempalte_选项]]在这里只是一个拼写错误,代码中拼写正确 def view_export(request): #handle what to do if it's a
看一下拼写错误:tempalte_选项应该是导出视图中的模板_选项Infodict['tempalte_选项]]在这里只是一个拼写错误,代码中拼写正确
def view_export(request):
#handle what to do if it's a POST request
#set other variables in infoDict
infoDict['tempalte_choices'] = get_template_choices()
return renderutils.render_response("export", infoDict, "export")
def get_template_choices():
choices = []
for template in Template.objects.all():
choices.append((template.id, template.code))
#choices is now a list of tuples (id, display code)
return choices
templateChoices = "{{template_choices}}";
baseGrid = new BaseGrid("export-grid", {'edit':true});
#set the other jqGrid attributes
baseGrid.colNames = ['Code', 'Name', 'Status', 'Template']
baseGrid.colModel = [
{name:'code', index:'code', width:70 },
{name:'name', index:'name', width:120},
{name:'status', index:'status', width:50},
{name:'template', index:'template', width:100, editable:true, edittype:'select', editoption:{value: templateChoices} }
]