2

I have UI-grid build in angularjs in which cell template I have used check boxes.When i click on particular checkbox I want to get that checked box value,means I have table like structure and in table cell I have checkbox.And now I want to get the selected check box value.

Here is my code

$scope.gridOptionsNew = {
appScopeProvider : $scope,
columnDefs : [{
        enableCellEdit : false,
        field : 'SponsorType',
        displayName : me.labelText.ADD_STORY_TABLE_SPONSOR_TYPE

    }, {
        //enableCellEdit: true,
        field : 'Hoarding',
        displayName : me.labelText.ADD_STORY_TABLE_HOARDING,
        cellTemplate : '<div class="text-center"><input type="checkbox" ' +
        'name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity.Radio)"/></div>'
    },
    {
        //enableCellEdit: true,
        field : 'Print',
        displayName : me.labelText.ADD_STORY_TABLE_PRINT,
        cellTemplate : '<div class="text-center"><input type="checkbox" ' +
        'name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity.Radio)"/></div>'
    }, {
        //enableCellEdit: true,
        field : 'Radio',
        displayName : me.labelText.ADD_STORY_TABLE_RADIO,
        cellTemplate : '<div class="text-center"><input type="checkbox" ' +
        'name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity.Radio)"/></div>'
    }, {
        //enableCellEdit: true,
        field : 'StageBackDrops',
        displayName : me.labelText.ADD_STORY_TABLE_STAGE_BACK_DROP,
        cellTemplate : '<div class="text-center"><input type="checkbox" ' +
        'name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity.Radio)"/></div>'
    }, {
        //enableCellEdit: true,
        field : 'Stalls',
        displayName : me.labelText.ADD_STORY_TABLE_STALLS,
        cellTemplate : '<div class="text-center"><input type="checkbox" ' +
        'name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity.Radio)"/></div>'
    }, {
        //enableCellEdit: true,
        field : 'Banners',
        displayName : me.labelText.ADD_STORY_TABLE_BANNERS,
        cellTemplate : '<div class="text-center"><input type="checkbox" ' +
        'name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity.Radio)"/></div>'
    }, {
        //enableCellEdit: true,
        field : 'Seats',
        displayName : me.labelText.ADD_STORY_SEATS,
        cellTemplate : '<div class="text-center"><input type="checkbox" ' +
        'name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity.Radio)"/></div>'
    }, {
        //enableCellEdit: true,
        field : 'VenueBanners',
        displayName : me.labelText.ADD_STORY_VENUE_BRANDING,
        cellTemplate : '<div class="text-center"><input type="checkbox" ' +
        'name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity.Radio)"/></div>'
    }, {
        //enableCellEdit: true,
        field : 'StagePresence',
        displayName : me.labelText.ADD_STORY_STAGE_PRESENCE,
        cellTemplate : '<div class="text-center"><input type="checkbox" ' +
        'name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity.Radio)"/></div>'
    }
]}

$scope.yourMethod = function (radio) {
  console.log("value", radio);
};

1 Answer 1

1

Please try as shown below.

set grid options like :

 $scope.gridOptionsNew = { 
         appScopeProvider: $scope,
         //your other options

then template :

cellTemplate: '<div class="text-center"><input type="checkbox" '+
name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity.Radio)"/></div>'

Method :

     //your Method
      $scope.yourMethod = function (radio) {

        //your logic
      };

Update :

cellTemplate: '<div class="text-center"><input type="checkbox" '+
name="radio" value="radio" ng-click="grid.appScope.yourMethod(row.entity)"/></div>'
Sign up to request clarification or add additional context in comments.

3 Comments

hello thank you so much for your answer. i just did console the value of radio in the function but is showing undefined.i did this $scope.yourMethod = function (radio) { console.log("hello",radio); }; it is showing "" infront of hello
can you put your latest code snippets on your post above ?
Please see the Update section.Try like that and see the value using debug..Just debug using F10.

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.