我想在条件的基础上在特定位置添加一列..这是代码..它在最后一个位置添加列名...但是我想在列“ def”之后添加列“ jkl” ...我该怎么做的???通过以下代码,它将列添加到结束位置.....
$scope.columnNames = [
{field: "abc", displayName: $scope.lable_abc, cellTemplate: '<div class="celltemplate" tooltip="{{row.entity.abc}}" tooltip-append-to-body="true" style="padding-left:10px" > {{row.entity.abc}}<div>'},
{field: "def", displayName: $scope.lable_def, cellTemplate: '<div class="celltemplate" title="{{row.entity.def}}" style="padding-left:10px" > {{row.entity.def}}<div>'},
{field: 'ghi', displayName: $scope.lable_ghi, cellTemplate: '<center><div> <img src="{{row.entity.ghi}}" width="20px" ></div></center>', width: 60},
];
if($scope.x == "2" || $scope.y == "3")
{
$scope.columnNames.push({field: "jkl", displayName: $scope.lable_jkl, cellTemplate: '<div class="celltemplate" title="{{row.entity.jkl}}" style="padding-left:10px" > {{row.entity.jkl}}<div>'});
}
您应该使用如下的拼接方法:
$scope.columnNames.splice(2, 0, {field: "jkl", displayName: $scope.lable_jkl, cellTemplate: '<div class="celltemplate" title="{{row.entity.jkl}}" style="padding-left:10px" > {{row.entity.jkl}}<div>'});
“ push”方法总是在最后添加。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句