0
我有問題,我的網格列寬在ng網格。我的問題是,我不知道提前哪些列將是(他們是在同一時間值的服務調用檢索到的。我的JSON對象,它有兩個屬性,列名的字符串數組和目前列不大小以適合列標題則值的二維數組。據我所知,列將調整大小以適應該行的數據,但如果有什麼不返回任何結果。那麼你有一個爛攤子。我試圖使,所以我沒有設置網格選項,直到我有我的數據,然後得到一個未定義的錯誤。我看到了另一個帖子裏了,該解決方案是使用NG-如果div標籤使電網不會加載,直到你想讓它。沒有工作,無論是作爲電網仍然試圖加載if語句才滿意下面是我的代碼有什麼想法也,我的NG-如果是這樣的:。?。NG-IF =「contentAvailable」還加入了屏幕截圖我的預期將是一個水平滾動條來顯示。ng-grid列大小問題。而ng - 如果問題
app.controller('mainController',function($scope,dataFactory){
$scope.contentAvailable = false;
$scope.gridOptions = {
columnDefs: 'columns',
showGroupPanel: true
};
$scope.url = 'http://example.com';
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str) {
return this.indexOf(str) == 0;
};
}
$scope.Fetch = function() {
dataFactory.Fetch($scope.url,$scope.config).success(function (blah) {
var result = $scope.transformJsonDataSet(blah);
})
.error(function (error) {
$scope.result = error;
});
};
$scope.transformJsonDataSet = function (ds) {
var tmp = angular.fromJson(ds);
var fieldNames = tmp.FieldNames;
var fieldValues = tmp.FieldValues;
var columns = [];
for (var i = 1; i < fieldNames.length; i++) {
if (fieldNames[i].startsWith('DECODE_') == false) {
columns.push({ field: fieldNames[i], displayName: fieldNames[i], cellClass: 'headerStyle'});
}
}
$scope.columns = columns;
$scope.contentAvailable = true;
return ds;
};
});
app.factory('dataFactory', ['$http', function ($http) {
var dataFactory = {};
dataFactory.Fetch = function (url,config) {
return $http.get(url,config);
};
return dataFactory;
}]);
加入空範圍變量後沒有變化。 – Jason