一只会飞的白菜 2017-11-04 12:31 采纳率: 0%
浏览 1474
已结题

bootstrap 获取不到行

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Document</title>
    <script src="static/js/import.inc.js"></script>
</head>
<style type="text/css">
    .table{
        margin-top: 5px;
    }

    .button{
        margin-top: 8px;
        margin-left: 10px;
    }
</style>
    <script type="text/javascript">
        $(function(){
            //编辑表格
            $('#reportTable').bootstrapTable({
                //数据来源的网址
                url:'/index.xhtml',
                method: 'post',
                editable:true,//开启编辑模式
                clickToSelect: true,
                showPaginationSwitch:true, //显示分页切换按钮 
                search: true,  //显示检索框
                showRefresh: true,  //显示刷新按钮
                showToggle:true, //显示切换按钮来切换列表/卡片视图
                pagination: true,  
                pageList: [5,25],  
                pageSize:5,  
                pageNumber:1,  
                columns: [[
                    {field:"id",edit:false,title:"编号",align:"center"},
                    {field:"user_company",edit:{
                                        type:'select',//下拉框
                                        //数据来源地址
                                        //url:'user/getUser.htm',
                                        data:[{id:1,text:'lzx'},{id:2,text:'lsl'}],
                                        valueField:'id',
                                        textField:'text',
                                        onSelect:function(val,rec){
                                            console.log(val,rec);
                                        }
                    },title:"下拉框",align:"center",width:"200px"},
                    {field:"time",edit:{
                        type:'date',//日期
                        required:true,
                        click:function(){
                        }
                    },title:"时间",align:"center"},
                    {field:"name",title:"名字",align:"center"},
                    {field:"age",title:"年龄",align:"center"},
                    {field:"gender",title:"性别",align:"center",width:"200px",formatter:function(value,row,rowIndex){
                         if(value==1){
                          return '男';
                      }else if(value==2){
                          return '女';
                      }
                    },edit:{
                    type:'select',//下拉框
                    //数据来源地址
                    data:[{id:1,text:'男'},{id:2,text:'女'}],
                    valueField:'id',
                    textField:'text',
                    onSelect:function(val,rec){
                    console.log(val,rec);
                     }
                }}
                // {field:"userstatus_end_time",title:"操作",align:"center",formatter:function(value,row,rowIndex){
                //  var strHtml ='<a href="javascript:void(0);" onclick="removeRow('+row+')">删除</a>';
                //  return strHtml;
                // },edit:false}
              ]]
            });
            $('#addRowbtn').click(function(){
                var data = {};
                $('#reportTable').bootstrapTable('append',data);    
            });

        });


        function removeRow(row){
            console.log(row);
        }
        function update(){
             var row = $('#reportTable').bootstrapTable('getSelections')
             console.log(row)
             location.href="delete.action?uid="+row.uid
             var row = $('#dg').datagrid('reload');
    }
    function sava(){
        var row = $('#reportTable').bootstrapTable('getSelections');
        if(row.length==1){
         console.log(a[0].id);  
     }else{alert("请选中一行")}  
    }
</script>
<body>
    <div id="myTabContent" class="tab-content" style="">
       <!--可编辑表格-->
       <div class="tab-pane fade in active button" id="tab2">
          <button type="button" class="btn btn-success dropdown-toggle" id="addRowbtn">
           <span class="glyphicon glyphicon  glyphicon-plus" aria-hidden="true"></span>增加
         </button>
         <button type="button" class="btn btn-warning" onclick="javascript:update()">
              <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>修改
         </button>
         <button type="button" class="btn btn-info" onclick="javascript:sava()">
              <span class=" glyphicon glyphicon-floppy-save" aria-hidden="true"></span>保存
         </button>
       </div>      
    </div>
 <div>
    <table class="table table-striped table-hover" id="reportTable"></table>
 </div> 
  </body>
</html>

点击保存时打印了一下为undefined 不知道为啥

  • 写回答

1条回答 默认 最新

  • devmiao 2017-11-04 13:21
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题