1

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

1
  • Check the answer below and see if it is working Commented Jul 5, 2017 at 13:31

1 Answer 1

1

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 ">
Sign up to request clarification or add additional context in comments.

8 Comments

NO it didnt worked.In this way,even by default the button is in enabled mode.which shouldnt be
Are you pushing the selected elements into gridApi.grid.selection? The button might be enabled mode because by default some value might have been set in your code.
No..by default nothing is selected
But in your plunkr, I can see that one value is selected
No I have removed that
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.