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.
-
true & false in column for every row?micronyks– micronyks2014-07-07 13:22:19 +00:00Commented 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 nouser3812457– user38124572014-07-07 13:46:31 +00:00Commented Jul 7, 2014 at 13:46
-
see hare codegur.net/33693297/… ..oCcSking– oCcSking2015-11-24 08:39:31 +00:00Commented 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/914352NMrt– NMrt2016-06-30 03:30:34 +00:00Commented Jun 30, 2016 at 3:30
Add a comment
|
3 Answers
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
1 Comment
user3812457
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
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
user3812457
The value is not hard coded ,either true or false value coming to variable from json data dynamically
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
user3812457
i want to change the true to yes at line no .24 in the plunker [link](plnkr.co/edit/N1wtkAHnnKA77gI6YW4D?p=preview )
mainguy
Errm, where is the ng-grid in this example?
mainguy
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.
user3812457
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 .
sylwester
hi please see here :plnkr.co/edit/mXhcLRWLyDI22cr4rS1P?p=preview