TDBGrid columns design time or run time? - delphi

I am using TDBGrid for the first time.
I didn't even notice the Columns property in the object inspector and everything went just fine: the grid was filled.
Then I saw the Columns property and tried it. When I use the object insector to add items to the Columns property of the grid, they do not all of them show up at run time. To me, it looks like the FieldName property is important. It looks like it is correct, but there are no values in some columns.
If I leave this property blank (no columns at all) it seems that the control populates it itself at run time and I do see all the columns. I could live with that. When I set column titles at run time it works, but setting column width does not.
[Update] Thanks for the feedback. I am learning slowly. Now I see what is happening. I wanted three of the five columns to be calculated. Two are gotten from INNER JOINs and the third from an SQL 'cast' of SELECT ... FROM_UNIXTIME(<table>.time_stamp).
If I do not define the columns at design time then these values are populated at run time when I execute my SELECT. Cnn anyone tell me how to set things up at design time? Thanks

There is no difference in functionality between runtime and designtime set up columns. That is: what can be done designtime can also be done runtime, and vice versa.
When te Columns property is kept empty, the grid fills it by default with all fields it finds in the linked dataset, once the dataset is opened. All column specific settings, such as alignment, width, title caption, etc... are set to default, based on the type, length and name of the corresponding field. This is the lazy way which sure could be sufficient.
You could deside to use your own setup or modification of the columns property, for one or more of the following reasons:
Change the order of the dataset fields in which they must appear in the grid,
Truncate the width of text fields (especially VarChar fields or Char fields with a large length normally result in colums that are too wide for normal presentation and/or user interaction),
Change the alignment of the fields (normally numeric fields are right aligned by default),
Hide one or more fields from the dataset,
Etc...
These own settings can be done desingtime as well as runtime.
Using the designtime columns editor is the preferred and RAD way in need of these customizations. Open the editor by double clicking the grid or the property, or via the grid's context menu. If the linked dataset is active then the command Add all fields is enabled, which does exactly the same as if you did not select any field at all, i.e. the default behaviour as described in the second paragraph.

The best way to define the columns on a dbGrid is to doubleclick the dataset in order to create variables that the form knows about (persistent fields). You can edit various properties of these variables such as DisplayLabel, DisplayWidth and DisplayFormat.
You can also add calculated fields by double clicking on the dialog box which appears when you double click on the client dataset.

Related

How can I show TDBGrid columns editor at run time?

I want to make it so that the user with himself changes the properties of the TDBGrid columns at columns editor in run time and then save columns properties (font name, font size, column width, etc).
I need show TDBGrid columns editor at run time.
This is not possible, because that editor is part of a design-time only package that is not redistributable. If you want to do this, you'll need to either find a third-party replacement (which you can't ask about here) or write your own.

Make only one column appear at the start of Orbeon Form Builder

According to latest documentation, one can set the maximum number of grid columns form authors can create:
<property
as="xs:integer"
name="oxf.fb.grid.max-columns"
value="4"/>
Because of some constraints in our use of Orbeon, I set the maximum of columns to "1". However, when I open the Form Builder to create a new form, the default arrangement shows a grid of two columns and one row, one cell containing a text field.
Now, if I delete the second column, I can't add a new column again, in line with the property set. But the fact that you can leave the two columns annoys me.
Is there a way to make default controls use only one column when opening the Form Builder?
It's not possible to change this right now. Orbeon Forms 2017.2 will, in addition, have a 12-column layout, which means that oxf.fb.grid.max-columns will have no effect. I think that constraining a form to follow an n-column layout would be a new feature of the product.

Angular UI-grid, how to tell what the next column in the scroll is

I have a ui grid that has 20 columns, and I would like to be able to tell what the next column will be as I scroll through the horizontal axis so that I can have some text that will tell the users what the names of all the columns they can't see are.
Anyone know if this is possible? As I watch the the inspector and scroll through the columns, I see html attributes changing.
---UPDATE 1----
This is what is all looks like (where it says "home #" is dynamic and will change to show the next column that is out of site)
Based on the ui-grid configuration that you use to render the grid, you already know the order of the columns. You can use this information together with the visible on each column added by the gird itself.
What you need to do is bind a event handler on scroll to iterate over the columns on each change and check the visibility of them. Then the first one with visible === false is the upcoming.
Here is a working Plunker where is used this flag.

TcxGrid column is hidden when dragging to group row

I have two seemingly identical TcxGrids bound to two different tables. On one grid, when the column header is dragged and dropped to the group panel, a large X appears above the column being dragged, when it is dropped the column is immediately hidden. On the other grid a big circle with a line through it shows and it cannot be dropped on to the group panel. The Options.Grouping for both columns is false. Why the difference in the two behaviors ? I cannot see a property setting difference but I'm sure there must be one somewhere that causes this behavior. What property is it ?
John
Inspect the properties of the column which won't group in the Object Inspector. Probably, you'll find that its DisableGrouping property is set to True. If it is, set it to False. If that doesn't work, a) I'll take this answer down and b) edit your q to add the contents of your DFM.
There are two places in DX grid that control the ability to group columns. First is at the grid level and it takes precedent over the columns' individual Options.Grouping settings. Second is at the column level. Look at .OptionCustomize.ColumnGrouping. It may be set to False.

Simple question, value not being display in DevExpress's LookupComboBox

This is a Delphi project, but I suspect DevExpress's component works similar for Delphi and .NET.
I have a DevExpress GridDBTableView, when selecting a cell in one of the column, I want a LookupComboBox to show up, where user can select an item, and the value gets display in the table cell. Simple.
I've set the column's Properties set to 'LookupComboBox'.
I have ListColumns setup with 'LocationName' and 'QuantityOnHand'.
ListSource is set to a datasource that's linked a dataset of 'LocationID', 'LocationName', and 'QuantityOnhand'.
ListFieldNames is set to 'LocationName;QuantityOnHand'
When I click on the cell, the combo box shows up with locations for me to choose, but when I choose a location, the table cell doesn't show the location name. In fact, I can't type anything in the cell.
What am I missing?
Ideally, I would like to be able to select a location from the combo box, the location name shows up in the table cell, and I can somehow store the corresponding LocationID that was selected.
I think that you should also set the column's Properties.KeyFieldName property to the KeyField of the Lookup DataSource. In this case, everything should work properly.
OK, all the answer is in the Express Editors' help file article 'Using Lookup Editors'.
The only step I missed was setting the LookupComboBox's KeyFieldNames property to 'LocationID'.

Resources