我使用保存状态服务-> $scope.gridApi.saveState.save()来保存网格的当前状态。但是保存状态对象不包含在列定义中定义的属性'field‘。它只包含name、visible、width、sort和filter属性。
有没有办法从saveStateService获取列的'field‘属性?
发布于 2018-11-18 23:55:05
如果您想要获取在columnDef中定义的字段的值,您可以通过以下方式来实现:
columnDef定义示例
let gridColumnDef = {
enableFiltering: true,
columnDefs: [
{ field: "Types", enableCellEdit: false, wordWrap: false },
{ field: "FileName", displayName: "File Name", enableCellEdit: false, width: "30%", wordWrap: true },
{ field: "NameState", displayName: "Name State", enableCellEdit: false, width: "9%" },
{ field: "Requirement", displayName: "Prop./Insu.", enableCellEdit: false, width: "7%" },
{ field: "Version", displayName: "Ver.", enableCellEdit: false, width: "5%" },
{
field: 'Actions', displayName: 'Action', width: "25%",
cellTemplate: `<div class="ui-grid-cell-contents">
<span ng-click="grid.appScope.SelectedRowGridConfig(row.entity)" style="margin-top: -7px !important;font-size:15px !important"
data-ng-if="(row.entity.Requirement === 'Approach') && row.entity.NameState !== 'uncharged'">
<i class="fa fa-cloud-download color-black"></i>
</div>`
}]
};您还可以从ui-grid访问方法: grid.appScope.nameMethod(params),在我的示例中,我调用方法SelectedRowGridConfig,并将row.entity作为参数传递给您:
grid.appScope.SelectedRowGridConfig(row.entity)我希望它能对你有所帮助。
https://stackoverflow.com/questions/53362199
复制相似问题