user7350714
user7350714

Reputation: 365

Enable button only if atleast one row is selected in ui-grid angular

I have a ui grid with set of rows in it and a button below that.I want to disable button when no row is relected and enable it if atleast one row is selected. Below is the plunker of ui grid

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

I tried to disable button this way

<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

Upvotes: 1

Views: 2212

Answers (1)

Vivz
Vivz

Reputation: 6620

It should be the other way around. So when you select one item, then it should be enabled. So your condition should be ng-disabled="gridApi.grid.selection.selectedCount == 0 " which means none have been selected(so disable it).

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

Upvotes: 1

Related Questions