2016-05-05 7 views
2

UI-gridangularjsのセルテンプレートを使用しています。特定のチェックボックスをクリックすると、チェックボックスの値が表示されます。私はテーブルのような構造を持っており、テーブルのセルにはチェックボックスがあります。そして今、私は選択されたチェックボックスの値を取得したいと思います。ここでanglejsを使用してui-gridのセルで選択したチェックボックスの値を取得する方法

は、以下のようにしてみてください私のコード

$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); 
}; 

答えて

0

です。

セットグリッドオプションのように:

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

、テンプレート:

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

方法:

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

     //your logic 
     }; 

更新:

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

お返事ありがとうございます。私はちょうど機能でラジオの値を慰めましたが、undefined.iを示していることは、この\t \t \t \t \t \t $ scope.yourMethod =機能(ラジオ){ \t \t \t \t \tはconsole.log( "こんにちは" をやりました、無線); \t \t \t \t};こんにちはの前に表示しています –

+0

上記のあなたのポストにあなたの最新のコードスニペットを置くことができますか? – Sampath

+0

'Update'セクションをご覧ください。そのようにして、debugを使って値を見てください。ちょうど' F10'を使ってデバッグしてください。 – Sampath

関連する問題