【问题标题】:bootstrap timepicker is hiding behind the grid in ui-grid, Angular Js引导时间选择器隐藏在 ui-grid、Angular Js 中的网格后面
【发布时间】:2017-04-21 11:51:28
【问题描述】:

我需要在 ui 网格单元格中显示时间选择器。我已经实现了它,但是有一个问题。它适用于上部单元格,但对于底部单元格,timepicker 的某些部分隐藏在网格后面。这里是笨蛋。

http://plnkr.co/edit/YbZbboMz36xTCdikNyhN?p=previewenter code here

双击倒数第二行的 cell3。可编辑单元格模板将打开。现在单击计时器图标。时间选择器将打开。但它的下部隐藏在网格后面。

【问题讨论】:

    标签: angularjs datepicker timepicker ui-grid


    【解决方案1】:

    我明白了,问题是你这个结构:

     $(function () {
    
                $('#timepicker').datetimepicker({
                    //format: 'LT'
                    format: 'HH:mm'
                });
     });
    

    每一行都有相同的id#timepicker

    解决方案

    创建一个指令,我们还需要position 来存储位置配置,如果我们有$last 元素,我们应该将垂直位置切换到顶部:

    app.directive('timeControl', [function(){
    
      return {
         restriction: 'A',
         link: function(scope, elem, attr) {
    
        var position = {
            horizontal: 'right',
            vertical: 'bottom'
        }
    
         if(scope.$last === true) {
            position = {
            horizontal: 'right',
            vertical: 'top'
        }
         }
    
         elem.datetimepicker({
                    //format: 'LT'
                    widgetPositioning: position,
                    widgetParent: elem,
                    format: 'HH:mm'
                });
    
    
    
              elem.datetimepicker({
                    //format: 'LT'
                    format: 'HH:mm'
                });
      }
    }
    

    }]);

    HTML

     <form name="inputForm">
    <div class='input-group date' time-control style="position:absolute; width: 80px;">
                    <input type='text' class="form-control" ng-class="col.colIndex()"  ng-model="MODEL_COL_FIELD" style="height:28px"/>
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-time timer"></span>
                    </span>
     </div>
    

    您只需将time-control 属性添加到div &lt;div class='input-group date"&gt;

    Plnkr example

    还有screenshot

    【讨论】:

    • 您好,Leguest。感谢您的答复。实际上,在我的原始代码中,$last 是 false,而 $middle 对于每一行都是 true。在您的 plunker 中,我认为 $last 对于每一行都是正确的,因为如果您检查第一行的时间选择器,它在顶部的开口现在时间选择器隐藏在顶部行的网格后面。
    • 您好,Leguest。你有机会调查一下吗?
    • 是的,我明白了。我认为要解决此问题,您应该在将数据放入 ui.grid 之前对其进行映射。看这里stackoverflow.com/questions/29637188/…。所以你需要用currentRowIndex == $scope.gridOpts.data.length - 1替换scope.$last。希望对你有帮助
    • 我在指令中的链接中使用 if(scope.grid.renderContainers.body.visibleRowCache.indexOf(row) === 0) 检查第一行的索引。但这里的问题是我们传递的“行”(.indexOf(row))。这是选定的行。我没有找到在链接函数中获取此选定行的方法。
    • 是的,这是 ui 网格的问题。检查这个方法plnkr.co/edit/9QbQCqTSz8aluh9n62Hl?p=preview,列Seq就是你需要的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-03
    • 2020-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多