c1.documentReady(function () {
var theGrid = wijmo.Control.getControl(
'#theGrid'
);
theGrid.formatItem.addHandler(function (s, e) {
if
(e.panel == s.cells && e.col == 0) {
var html = wijmo.format(
'<div class="item-header">{CompanyName}</div>'
+
'<div class="item-detail">{ContactName}, {ContactTitle}</div>'
+
'<div class="item-detail">{Address}, {City}, {Country}</div>'
,
s.rows[e.row].dataItem);
e.cell.innerHTML = html;
}
});
var defaultRowHeight = theGrid.rows.defaultSize;
theGrid.addEventListener(window,
'resize'
, updateGridLayout);
function updateGridLayout() {
var narrow = theGrid.hostElement.clientWidth < 600;
theGrid.columns.forEach(function (col) {
col.visible = col.index == 0 ? narrow : !narrow;
});
theGrid.rows.defaultSize = defaultRowHeight * (narrow ? 3 : 1);
theGrid.headersVisibility = narrow ?
'None'
:
'Column'
;
}
success: function (xhr) {
var response = JSON.parse(xhr.responseText);
theGrid.itemsSource = response.value;
updateGridLayout();
}
});
});