Designer - hiding unused columns and assign specific column names

Сonversation on different topics
Post Reply
robinpearce
Posts: 38
Joined: Thu Apr 02, 2009 5:54 am

Designer - hiding unused columns and assign specific column names

Post by robinpearce »

Hiya,

I am writing am application in c# which will allow our customers to design and run their own reports. I pass objects into the Report Designer and the items available within the datasource are the properties in the object - exactly as I would expect.

However our customers can assign different meanings to certain columns and sometimes decide not to use them at all
For example we have 50 free format columns and customer1 may use FreeFormatColumn1 to store a card holders date of birth and
FreeFormatColumn2 to store a card holders Mothers Maiden Name and not use the other 48 columns. Another customer may use 20 of
the 50 columns. Obviously the "column uses" i.e the names the customer has assigned to each column are available to me.

We want to provide the ability for our customers to design their own reports but they would only expect to see the
columns they use and to see the actual meanings they assign to each column, like "Mothers Maiden Name" and not FreeFormatColumn2.

Have you any ideas if this is possible and how I would achieve this. I know I can use aliases to give columns alternative names
but this is not what they want. This also does not allow me to "hide" un-used columns.

Best regards
Robin
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Designer - hiding unused columns and assign specific column names

Post by Alex K. »

Hello,

Please see the attached report. In this report, before rendering, it is offered for a user to select columns which he wants to see. You may do something similar for your users but only before running the designer. For better recognizing the column names, please use aliases.

Thank you.
Attachments
563.SelectingColumns.mrt
(36.88 KiB) Downloaded 602 times
robinpearce
Posts: 38
Joined: Thu Apr 02, 2009 5:54 am

Designer - hiding unused columns and assign specific column names

Post by robinpearce »

Thanks for the example, however, what I want is to hide the columns so they are not available in the designer. So we have a object which contains the following properties for example

CardHolderId, CardHolderName, FreeFormatColumn1, FreeFormatColumn2, FreeFormatColumn3, ..... FreeFormatColumn50.

Ideally what I need is a way so I can pass that same object to the designer but somehow tell the designer to hide certain columns so that the user can not see or select them. For example if this customer only uses FreeFormatColumn1 and FreeFormatColumn2 then they would not want to see FreeFormatColumn3 - FreeFormatColumn50 in the designer. Another customer may use the first 10 free format columns so in this case I would want to hide column FreeFormatColumn11 - FreeFormatColumn50 from the designer.

Sorry if I was not clear before. I fully expect this requirement is not possible but I have to ask the question.

Best regards
Robin
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Designer - hiding unused columns and assign specific column names

Post by Alex K. »

Hello,

As a way put check boxes with the list of columns in the report in your application and let users define columns they need, then add only defined ones. A code sample using SQL connection (you may have another one) but actions are the same:

Code: Select all

using (SqlConnection connection = new SqlConnection(sqlConnectionString))
{
      SqlCommand myCommand = new SqlCommand("select * from Table_2", connection);
      SqlDataAdapter dataAdapter = new SqlDataAdapter(myCommand);
      DataTable dataTable = new DataTable("Table_2");
      dataAdapter.Fill(dataTable);
      StiReport report = new StiReport();
      Stimulsoft.Report.Dictionary.StiSqlDatabase db = new Stimulsoft.Report.Dictionary.StiSqlDatabase("myConnection", "");
      db.ConnectionString = sqlConnectionString;
      Stimulsoft.Report.Dictionary.StiSqlSource userSource = new Stimulsoft.Report.Dictionary.StiSqlSource();
      userSource.NameInSource = "myConnection";
      userSource.Name = "UserDataSourse";
      userSource.Alias = "UserDataSourse";
      userSource.SqlCommand = "SELECT * FROM Table_2";
      userSource.CommandTimeout = 3000;
      
      /// Here, users in any way determine the visible columns 
      /// for example
      int[] isVisible = new int[] {1,1,0,0,1};
      int ind = 0;
      
      foreach (DataColumn col in dataTable.Columns)
      {
            if (isVisible[ind] == 1)
            {
                  userSource.Columns.Add(new Stimulsoft.Report.Dictionary.StiDataColumn(col.ColumnName, col.GetType()));
            }
            ind++;
      }
      report.Dictionary.Databases.Add(db);
      report.Dictionary.DataSources.Add(userSource);
      report.Dictionary.Synchronize();
      report.Design();
}
Thank you.
robinpearce
Posts: 38
Joined: Thu Apr 02, 2009 5:54 am

Designer - hiding unused columns and assign specific column names

Post by robinpearce »

OK thank you very much for you help.

What I am actually doing is getting the object to present to the designer via out data access layer, but from what you are saying it looks like I would need to create an intermediate object which would only contain the columns I require, which is fair enough.

Once again thanks for your prompt help


Best Regards
Robin


Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Designer - hiding unused columns and assign specific column names

Post by Alex K. »

Ok! We are always glad to help you!
Post Reply