Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140734

Display conditional based cell value in grid - AnguarJS

$
0
0

I have grid with few number of fields and one of them is Roles. The goal is to display the value to that field as a checkbox based on the value from response I get (response is a grid named deoUsers it contains many fields, one of the fields from response will be depCode with possible values of 2,4,8,15,17 & 20 ) along with these two conditions

  1. display this field with this value - when depCode is 15, 8,4,2 then display them as CRT, Deo, BM, KM respectively and make the check box disable

  2. display this field with this value - when depCode is 17,20 then make them display all the values in checkbox CRT, Deo, BM, KM, HOIT, ROIT so that user will select any one from the checkbox...

below is my half baked code :

var checkBoxCell = '<input type="checkbox" class="includeCheckBox" ng-model="row.entity.checked" ng-true-value="true" ng-false-value="false" />';
$scope.checkAll = false;
$scope.label = 'select all';
var roleOptions = '';
$scope.roles = [{'depCode':'8','name':'Deo'},{'depCode':'4','name':'BM'},{'depCode':'2','name':'KM'},{'depCode':'15','name':'CRT'}];
roleOptions = "<select style='width:100%'><option value='0'> - None -</option>";
$scope.roles.forEach(function (role) {
    opt = role ;
    roleOptions += "<option value='" + opt.depCode + "'selected'>" +opt.name+ "</option>";
    });
roleOptions += '</select>';
$scope.roleOptions = roleOptions;
$scope.gridDeo = {
data: 'deoUsers',
columnDefs: [
    {
    field: 'role',
    displayName: "Roles",
    cellTemplate: '<div>' + roleOptions + '</div>',
    },
    {
     other field 1
    },
    {
     other field 2
    }
    ]



Viewing all articles
Browse latest Browse all 140734

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>