【问题标题】:Enable button only if atleast one row is selected in ui-grid angular仅当在 ui-grid angular 中选择了至少一行时才启用按钮
【发布时间】:2017-07-05 21:15:33
【问题描述】:

我有一个 ui 网格,其中有一组行,下面有一个按钮。我想在没有行时禁用按钮,如果选择了至少一行,则启用它。 下面是ui grid的plunker

http://embed.plnkr.co/nAJ6h07ksn1MIYcHpQ0Q/

我试图以这种方式禁用按钮

<input class="button" name="submit" type="button" value="Find Flights"
      ng-click="postdata()" ng-disabled="gridApi.grid.selection.selectedCount !== 0 ">

But this it is not getting enabled when a select a grid how can we achieve this

【问题讨论】:

  • 检查下面的答案,看看它是否有效

标签: javascript angularjs ui-grid


【解决方案1】:

应该反过来。因此,当您选择一项时,应该启用它。所以你的条件应该是ng-disabled="gridApi.grid.selection.selectedCount == 0 ",这意味着没有被选中(所以禁用它)。

<input class="button" name="submit" type="button" value="Find Flights"
      ng-click="postdata()" ng-disabled="gridApi.grid.selection.selectedCount == 0 ">

【讨论】:

  • 不,它没有工作。这样,即使默认按钮处于启用模式。不应该
  • 您是否将选定的元素推送到 gridApi.grid.selection 中?该按钮可能处于启用模式,因为默认情况下可能已在您的代码中设置了一些值。
  • No..默认没有选择
  • 但是在您的 plunkr 中,我可以看到选择了一个值
  • 不,我已经删除了
猜你喜欢
  • 2022-08-18
  • 2013-10-29
  • 1970-01-01
  • 2022-01-16
  • 2016-01-28
  • 1970-01-01
  • 2018-07-29
  • 1970-01-01
  • 2015-10-04
相关资源
最近更新 更多