【问题标题】:ng-grid filterOptions blank filterText does not work in IE8ng-grid filterOptions 空白 filterText 在 IE8 中不起作用
【发布时间】:2013-10-10 20:54:57
【问题描述】:

当我设置 filterOptions.filterText = 'category : ' + filteringText 时,当 filteringText 为空白时,我看不到任何行。但是,如果 filteringText 不为空,则此过滤器有效。

这是plnkr的预览

这只是 IE8 的问题。有什么办法解决这个问题?

要复制此问题,请将其下载为 zip 文件并在 IE8 中运行。复选框“All”应该显示所有行,隐藏所有行。 (我上面给出的预览链接在IE8中不起作用,所以你必须下载plunk并打开index.html文件。感谢IE8)

【问题讨论】:

  • 谁能告诉我是否可以添加 OR 条件。因此,我不会将 filterText 设置为空白,而是使用 OR 条件检查所有可能的值以使其工作。

标签: angularjs ng-grid


【解决方案1】:

看起来 ie8 将 undefined 传递给 ng-model 以获得一个空字符串。

因为你的 ngmodel 指令绑定了过滤文本

<input type="radio" ng-model="filteringText" value="" /> All

然后你看这个来实际设置 filterText 之后,试着把你的代码改成这个

$scope.$watch('filteringText',function(newVal){
    if ((newVal === '') || (typeof newVal == 'undefined')) {
        $scope.gridOptions.filterOptions.filterText = '';
    }
    else
      $scope.gridOptions.filterOptions.filterText = 'category : ' + newVal;
});

我进行了简短的测试,似乎在 IE8 和 chrome v30 中都可以使用

【讨论】:

  • 我确认这在 IE8 中有效。当我单击添加时,我应该检查 newVal 值。非常感谢。
猜你喜欢
  • 2013-12-24
  • 2014-09-29
  • 1970-01-01
  • 1970-01-01
  • 2015-11-30
  • 2019-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多