这里只贴出关键代码,其他代码需要自行编写。返回值处理根据实际需求来,目前是只取第一条,因为选择页面是单选行

  • 表单页面新加方法
 /* 选择社区 */
function selectCommunity() {
    var url = ctx + "community/selectCommunity";
    var options = {
        title: '选择社区',
        width: "600",
        url: url,
        callBack: doSubmit
     };
     $.modal.openOptions(options);
}
/* 选择社区回调 */
function doSubmit(index, layero){
	// 这里取到的是多行的
    var rows = layero.find("iframe")[0].contentWindow.getSelections();
    if (rows.length > 0){
    	// 这里是取第一条数据
        $("#communityId").val(rows[0].id);
        $("#communityName").val(rows[0].name);
    }
    layer.close(index);
}
  • 选择页面新加方法
 /* 获取选择的数据 */
 function getSelections() {
    return $("#" + table.options.id).bootstrapTable('getSelections');
}
Logo

快速构建 Web 应用程序

更多推荐