2

I am using the cellTemplate to display the data in grid ,now i have to display the data in ng-grid ,where i can display the data containing true or false value in one column ,please guide me how to display the true or false data like yes or no ,i.e ,for true value i have to display yes and for false value to no .please guide me what changes in makes my required result.

4
  • true & false in column for every row? Commented Jul 7, 2014 at 13:22
  • not for every row ,only one column contain true of false data that i need to display like yes or no Commented Jul 7, 2014 at 13:46
  • see hare codegur.net/33693297/… .. Commented Nov 24, 2015 at 8:39
  • This question has been closed off, but see this answer for how to display yes/no instead of true/false: stackoverflow.com/a/26162569/914352 Commented Jun 30, 2016 at 3:30

3 Answers 3

20

Create a simple filter like:

app.filter('true_false', function() {
    return function(text, length, end) {
        if (text) {
            return 'Yes';
        }
        return 'No';
    }
});

and use it in your cellTemplate (or wherever you want):

cellTemplate: '<div class="ngCellText">{{row.getProperty(col.field) | true_false}}</div>'

Here is a Plunker

Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your suggestions ,i am expecting ng-if type solution to convert the true to yes based on condition .if possible please send your answer
0

You can add ng-options in your tag

ng-options="myMethod(item) for item in [true, false]"

Then define

$scope.myMethod = function(arg) {return arg ? 'Yes' : 'No'};

1 Comment

The value is not hard coded ,either true or false value coming to variable from json data dynamically
-1

Hi Please see here: http://jsbin.com/bogir/1/edit?html,js

  <span ng-show="model">true</span>
  <span ng-hide="model">false</span>

5 Comments

i want to change the true to yes at line no .24 in the plunker [link](plnkr.co/edit/N1wtkAHnnKA77gI6YW4D?p=preview )
Errm, where is the ng-grid in this example?
Anyhow, filter works here too. plnkr.co/edit/sTYo8hSIwYYnhX2YfKVU?p=preview I allowed myself to clean up your messy example. Please read some tutorials about angular before continuing to ask questions. And make the TOUR in the HELP menu at the top of this page to learn how to ask questions. This might spare you the downvotes.
thank you for your suggestions ,ng-grid is my work space ,i want to explain my situation i used that plunker ,is there any ng-if condition based solution to transfer the dynamic data true to yes based on condition .

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.