Wijmo 5 [Flex Grid]
Bind radio Button to cell Edit ended and cell Edit Ending event
HTML
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/interop/angular/wijmo.angular.min.js"></script>
<div ng-app="app">
<div ng-controller="appCtrl">
<wj-flex-grid class="grid" items-source="data" item-formatter="itemFormatter">
<wj-flex-grid-column name="country" header="ID" binding="country" width="80" is-read-only="true"></wj-flex-grid-column>
<wj-flex-grid-column name="downloads" header="downloads" binding="downloads"></wj-flex-grid-column>
<wj-flex-grid-column name="sales" header="sales" binding="sales" width="*"></wj-flex-grid-column>
<wj-flex-grid-column name="Delete" header="Delete">
</wj-flex-grid-column>
</wj-flex-grid>
Your Selection is {{selection}}
</div>
</div>
JavaScript
var app = angular.module('app', ['wj']);
app.controller('appCtrl', function ($scope, $compile) {
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = [];
for (var i = 0; i < countries.length; i++) {
data.push(
{
country: countries[i],
downloads: Math.round(Math.random() * 20000),
sales: Math.random() * 10000, expenses: Math.random() * 5000,
isProfit: true
});
}
$scope.data = new wijmo.collections.CollectionView(data);
$scope.itemFormatter=function(panel, r, c, cell) {
if (panel.cellType == wijmo.grid.CellType.Cell) {
var col = panel.columns[c],
html = cell.innerHTML;
if (panel.columns[c].name == "Delete") {
var html = '<input type="radio" ng-model="selectId" name="radio" value='+r+'>예' + '<input type="radio" ng-model="selectId" name="radio" value='+(r+1)+'>아니오';
cell.innerHTML = html; cell.style.padding = '3px';
$compile(cell)($scope);
var radio = cell.children[0];
console.log(radio);
// radio button state change handling
radio.onchange = function (e) {
panel.grid.startEditing(false, r, c, true);
panel.grid.cellEditEnded.addHandler(function (sender, args) {
$scope.selection = $scope.selectId;
});
}
// radio button click
radio.onclick = function (e) {
...