Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
350
How to change column index dynamically?
posted

I need to apply user settings on IgxGrid. What I am trying is that whenever a user reorders columns, I am saving the column indices in my database and next time when the user opens the same grid; I need to show the same settings on grid which he saved previously. But when I try to set the column index it says that there is no setter for index property. How can I achieve the functionality to change column indices dynamically? Here is what i am trying to do, 

for (var iterator = 0; iterator < gridSettings.ColumnSettings.length; iterator++) {
   
      if (this.componentRef.columns != null) {
        for (let colIndex = 0; colIndex < this.componentRef.columns.length; colIndex++) {

          if (this.componentRef.columns[colIndex].field == gridSettings.ColumnSettings[iterator].Key) {

            if (this.enableColumnHiding) {
              this.componentRef.columns[colIndex].hidden = gridSettings.ColumnSettings[iterator].Hidden;
            }

            this.componentRef.columns[colIndex].width = gridSettings.ColumnSettings[iterator].Width;
            this.componentRef.columns[colIndex].index = gridSettings.ColumnSettings[iterator].Index;

            break;
          }
        }
      }
      }

Here is the error which I am encountring,

ERROR Error: Uncaught (in promise): TypeError: Cannot set property index of [object Object] which has only a getter
TypeError: Cannot set property index of [object Object] which has only a getter

Parents Reply Children
No Data