Стол с креплениями knockout.js currenlty выглядит LKE это:KnockoutJS observableArray: групповые данные в Еогеасп
source total division
00234 4506 div1
30222 456 div2
63321 23 div2
40941 189 div1
требуемый выход будет что-то вроде ниже. Данные необходимо сгруппировать по division
.
source total
div1
00234 4506
40941 189
div2
30222 456
63321 23
Вот мой ViewModel:
var ReportingViewModel;
ReportingViewModel = { Results: ko.observableArray(null) }
ReportingViewModel
получает заполняется через AJAX запроса:
ReportingViewModel.Results(data["Data"]["Report"]);
Q: Как можно достичь желаемых результатов?
EDIT:
Вот мой Вид:
<table class="table table-condensed" id="reportData">
<thead>
<tr>
<th>source</th>
<th>total</th>
<th>division</th>
</tr>
</thead>
<tbody data-bind="foreach: Results">
<tr>
<td data-bind="text: source"></td>
<td data-bind="text: total"></td>
<td data-bind="text: division"></td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
ReportingViewModel.Results(null);
e.preventDefault();
var numbers = null;
if ($('#numbersdd').find("option:selected").length > 0) {
numbers = $('#numbersdd').find("option:selected");}
if (numbers != null) {
$.ajax({
url: '/Reporting/ReportData.aspx',
type: 'POST',
data: numbers,
dataType: 'json',
contentType: "application/json",
success: function (data) {
ReportingViewModel.Results(data["Data"]["Report"]);
},
error: function() {
alert('Error Running Report');
}
});
}
else { alert('No Data!'); }
});
var ReportingViewModel;
ReportingViewModel = {
Results: ko.observableArray(null),
}
ko.applyBindings(ReportingViewModel);
});
</script>
Адрес электронной почты: Когда вы написали имя ko.applybindings()? – beauXjames