0

I am using save state service -> $scope.gridApi.saveState.save() to save the current state of the grid. But the save state object doesn't contain the property 'field' defined in column Def. It contains only name, visible, width, sort and filter properties.

Is there any way to get the 'field' property of the column from saveStateService?

1 Answer 1

0

If you want to get the value of a field defined in columnDef, you can do it in the following way:

example of a definition of 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>`
                }]
        };

you can also access methods from ui-grid: grid.appScope.nameMethod(params), in my case I call the method SelectedRowGridConfig and I pass you row.entity as a parameter:

grid.appScope.SelectedRowGridConfig(row.entity)

I hope it helps you.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the response. I want to save the state on columnPositionChanged event. So i need the value of 'field' in save state service. I can't get it from row entity.
@Geetha Do you still have the inconvenience?
No it is resolved. I got 'field' value from columnDefs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.