1 Reply Latest reply: Nov 27, 2015 6:09 AM by Øystein Kolsrud RSS

    Alter layout of table

    Anders Uddenberg

      I'm trying to remove/add columns, programmatically, in a table. When using the API Explorer I can get a list of all kolumns and measures using GetLayout but my question is this: using an API, which method is appropriate for adding/removing columns in a table?

       

      Best

      Anders

        • Re: Alter layout of table
          Øystein Kolsrud

          Using the .NetSDK you could do something like this in C#:

           

          ITable table = app.GetObject<Table>(<the id of the table object>);

          using (table.SuspendedLayout)

          {

               table.Properties.HyperCubeDef.Dimensions = table.Properties.HyperCubeDef.Dimensions.Where(KeepColumn);

          }

           

          And then "KeepColumn" would be a function that looks something like this:

           

          private static bool KeepColumn(TableHyperCubeDimensionDef dimensionDef)

          {

              return <logic to check that I want to keep dimension>;

          }