我有一个像这样进来的 JSON
{
x:1,
y:2
}
这意味着当我将它贴在我的 ui-grid 上时,x
列是第一列,y
列是第二列。但是,我想要相反的结果:y
然后x
.
如何告诉 UI-gridy
提前显示x
?
我有一个像这样进来的 JSON
{
x:1,
y:2
}
这意味着当我将它贴在我的 ui-grid 上时,x
列是第一列,y
列是第二列。但是,我想要相反的结果:y
然后x
.
如何告诉 UI-gridy
提前显示x
?
通过使用columnDefs
.
像这样在 html 中定义网格:
<div id="grid1" ui-grid="gridOptions" class="grid"></div>
你的应用程序代码是这样的:
var app = angular.module('app', ['ui.grid']);
app.controller('MainCtrl', ['$scope',
function($scope) {
$scope.myData = [{
"x": "1",
"y": "2",
}, {
"x": "3",
"y": "4",
}];
$scope.gridOptions = {
data: 'myData'
};
$scope.gridOptions.columnDefs = [{
name: 'y'
}, {
name: 'x'
},
];
}
]);
请注意如何columnDefs
使用y
第一列和x
第二列。
这是一个Plunker