仅在未单击时显示模式的动手模式显示第一列

时间:2019-03-11 15:40:40

标签: javascript php html5 bootstrap-4 bootstrap-modal

我刚开始使用handsontable,但遇到了这个问题,当我将其放在模式中时,表格无法正确显示。 Heres an image of it 这是我在bootsrap中可动手操作的代码:

<div id="example1" class="handsontable" autofocus></div>
    <script>

                      function getCarData() {
                        return [
                                                          <?php 
                                        require '../connection.php';
                                        $sql = "Select * from members";
                                        $result = $con->query($sql);
                                        if ($result->num_rows > 0) {
                                            // output data of each row
                                            while($row = $result->fetch_assoc()) {
                                                $col1 = $row['first'];
                                                $col2 = $row['middle'];
                                                $col3= $row['last'];
                                                $col4=$row['rfidnum'];
                                        ?>
                      {RFID:'<?php echo $col4;?>', Name:'<?php echo $col1;?> <?php echo $col2;?> <?php echo $col3;?>',C: '',D:'',E:'',F:'',G:'',H:'',I:'',J:'',K:'',L:'',M:'',N: '',Final:''},<?php }}?>
                        ];
                      }

                      var
                        container = document.getElementById('example1'),
                        hot;

                      hot = new Handsontable(container, {
                        data: getCarData(),
                        colHeaders: ['RFID', 'Name', 'C','D','E','F','G','H','I','J','K','L','M','N','Final'],
                        rowHeaders: true,
                        manualRowResize: true,
                        contextMenu: true,
                        manualColumnResize: true,
                        colWidths: [100,100,100,100,100,100,100,100,100,100,100,100,100,100,100],
                        height: 400, 
                        formulas: true,
                        columnSorting : true,
                        columns: [
                          {
                            data: 'RFID',
                            readOnly: true,
                          },
                          {
                            data: 'Name',
                            readOnly: true,
                          },
                           {
                            data: 'C',
                            type: 'numeric'
                              },
    ...

我也使用了此解决方案,但是它只是显示滚动按钮,除非我单击它们,否则内容仍然不会显示,这是我尝试过的解决方案:

<script>
   $("#addSched").on('shown.bs.modal', function() {
       $(document).off('focusin.bs.modal');
            setTimeout(function() {
                $("#example1").handsontable("selectCell", 0, 0);
            }, 10);
    });
</script>

感谢您的提前答复,希望有一个解决方案,因为很多开发人员也遇到了这个问题。

0 个答案:

没有答案