添加时的下拉菜单中的值需要从数据库中查出来,后台拼接字符串传给前台
前台代码:
{name: 'guruId',editable : true, edittype:'select',
editoptions: {
dataUrl:'${ctx}/guru/findAll'
},
formatter:function (value, options, row) {
return row.guru.dharma;
}
}
后台代码:
@RestController
@RequestMapping("/guru")
public class GuruController {
@Autowired
private GuruService guruService;
@RequestMapping("findAll")
public String findAll(){
List<Guru> gurus = guruService.selectList(null);
StringBuilder sbu = new StringBuilder("<select>");
for (Guru guru : gurus) {
String option = "<option value='" + guru.getId() + "'>" + guru.getDharma() + "</option>";
sbu.append(option);
}
sbu.append("</select>");
return sbu.toString();
}
}