Alarms, Events, and Trends->Grid object->Columns dialog
Tip: You can configure tags between curly brackets in the Label field to modify it dynamically during runtime. When the label is blank (e.g., ""), then the width of the column is set to 0 during runtime. This option is useful to hide columns during runtime.
So, define a tag for each column whose appearance you need to control, and set it to the column title or blank as required.
Thanks Mr. C Shearer. you solution worked, However it is not efficient because in this all column's data are fetched from SQL Server.
I have another question, How we can apply custom SQL select statement to grid object (with column list and where condition)? I don't want to use class tags as DataSource because they complicate things.
Using class tags as a data source can also chew through your tag allowance very quickly
You can apply custom SQL to a grid object in order to return data directly to the grid object and avoid consuming any tags. I use this technique frequently in my applications. I have never used this technique to also dynamically change the number of columns returned ... but I can see that it might be possible. It will also get a bit messy.
As well as dynamically specifying the columns involved in the select statement, you may also still need to specify some column titles as empty strings. This is because you may find the need to return columns as part of the query which you do not actually want to display. You need to trust me on this ... as I've been using this technique for several years now.
I can try to send you instructions on how to do this if I have time tomorrow. You may be able to work it out for yourself ... but the method isn't documented very well. If you send me an example of the kind of queries you might run and indicate the columns to display, I might be able to make the example look more like your actual requirements.
Rather than constructing dynamic column grid displays, you could also consider constructing several individual fixed column grid displays each with 'fixed' sql. You could then selectively display the grid of interest. That is, you can place multiple grid objects on top of each other on a single screen, but only display one of them. You achieve this using the object 'Position' animation 'Show on condition' expression.
As with most things Indusoft ... there are quite possibly several ways to achieve your desired outcome.
Hi. Thanks for your quick and complete replies. :)
I have many columns in database (about 20 columns or much), displaying all of them at once isn't good and necessary always. So i just want if i can let user to select desired columns and time stamp condition. SQL query for this would be as simple as below:
[code] select time_stamp, col1, col2, col3 from TrendData
where time_stamp>=$t1 and time_stamp><=$t2[/code]
I'm very pleased if you post your last works which you mentioned here.
How i can apply this custom query to grid object? if it isn't possible i'm going to select all columns and hide undesired columns by applying blank label to that columns.
selecting column by tag names didn't work, so only option left is to assign each label to a tag and hide the column by setting the tag to empty string.
I'm a bit disappointed that selection of column by tag values didn't work ... but I can also see that if it had, it may not have been a very good solution.
To be honest, I think that using sql to populate the grid directly and then hiding columns using the column label is quite a reasonable solution. This approach doesn't consume tags the way use of a class tag would, and allows the characteristics of each column to be set individually. Also, the difference in performance of always returning 20 columns instead of some smaller number will be negligible.
Hi there. There are many things you should understand for accomplish this issue. First of all you need to disable the sending delimiters (database settings). Second you should understand this: The full query that is sended consists of: 1:The content AFTER SELECT keyword and BEFORE FROM keyword. This content is provided by defining the column names. For example if you have a grid with 2 columns and you define the columns as col1 and col2 then the INSERT content will be: SELECT col1, col2 If you define them as SUM(col1) and SUM(col2) then the SELECT content will be: SELECT SUM(col1), SUM(col2). If the label is blank then the query is the same but the grid does not show this column (0 width). 2. The content after the FROM keyword is defined in the "table" field of the database. for example you can write MyTable WHERE col1>10 ORDER BY col2 GROUP BY col1 Notice that I don't use the "condition" field of the grid at all. All these pieces of the full query can be assembled by tags and some VB logic. Now about the user selection of the fields to show: I usually prefer the creation of a small table in SQL where it has 2 columns: ColName varchar, ColDescription varchar, ColSelection boolean I show it on another grid where ColSelection is a CheckBox Then I use some VB logic and get the columns to show on the above example. I hope I helped.