其他分享
首页 > 其他分享> > JqGrid添加时的下拉菜单实现

JqGrid添加时的下拉菜单实现

作者:互联网

 

添加时的下拉菜单中的值需要从数据库中查出来,后台拼接字符串传给前台

 

前台代码:

                    {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();

    }

}

 

 

标签:return,JqGrid,guru,sbu,下拉菜单,添加,findAll,gurus
来源: https://blog.csdn.net/zhang33565417/article/details/99685750