How to display a tooltip in Dynamics AX 4.0? - x++

I'm looking to add hover text to a given column in a grid with row specific data. I'm planning on overriding the mouse-enter event, but I'm unsure how to populate a Tooltip and have it display next to the mouse.
Any direction would be appreciated, thanks!
**Edit: It looks like the method to override is actually called "Tooltip". I was able to override this and get a tooltip to display.
The question remains: How to access the current row's data for the column that the Tooltip is on?

To show a tooltip with the description of the foreign key field, the following must be met:
Base your field on an extended data type
Put a relation on the extended data type
Have the relation point to a base table
Set the TitleField1 and TitleField2 attributes on the base table
Have a unique index on the key fields of your base table
You can put the relation on the (transaction) table instead of the extended data type.
Do that in AX 2012 or if the relation has more than one field to join.

Here's the tooltip code that I ended up using:
public str toolTip()
{
;
return tblYourTable::find(this.value()).Description;
}
**Edit per Jan's comment to greatly simplify code

Related

How to set focus on a particular row in a TDBgrid Delphi

I want to set the focus on a specific row on a Tdbgridview.
First, I choose the criteria field ( column concerned by search ex: FisrtName) from a combo box then I type criteria in a TeditField (ex : Jack ).
Then the arrow of the Dbgrifd should point on the concerned row.
How should I do?
thanks.
The TDBGrid component (and all other TDBxxx components as well) are what Delphi defines as dataware components. This kind of component exists as a visual expression of a dataset.
So, in a TDBGrid you should not think about focusing a row of the grid, rather think about positioning a row of the grid's dataset (using the Locate method suggested by TLama, for instance). The grid will notice that the current row of its dataset has changed (because the grid is aware about the condition of the dataset) and will focus the corresponding row.
Update 1
Below you can see an example of what I said:
MyDataset.Locate('Id', 123, []);
The code above simply looks for a certain record in a dataset named MyDataset. The first parameter is the name of a existing field in the dataset. So, you have a dataset with some fields and one of those is named Id. The second parameter is the value contained in that field in the desired row and the third parameter is some options that do not apply here. Go to the Delphi docwiki for more details on the Locate method.
In other words, we are looking for a row in which the field Id has the value 123! If the dataset can find such a row, it will become the current record (or row). If there is a TDBGrid connected to a TDataSource that is connected to TMyDataset, it will automatically update to select the corresponding row, just like you wanted.

Delphi - How to get a image for a cxGrid column?

I have a TcxGrid component to show data of a MS Access table. One of this columns have a picture. The column "Properties" of this column is marked as "ButtonEdit".
I don't want to use a BlobEdit. I want to create another form, for display this picture. It will be opened by OnButtonClick() event of the grid column. But, I don't know how to get the column content (as TStream or other type), or the column name/field name in the OnButtonClick() event. I can't fix the column name, because it's a "generic" grid for show any Access table.
How can I do it?
It will be nice to understand your question better if you can post your code. But offcourse You can get column contents easily by using FieldByName method. Try to use that.
You did not say how you load the data into the grid, but to get the cell content you can use:
VarAsType(cxGrid1TableView1.DataController.Values[cxGrid1TableView1.Controller.FocusedRecordIndex,cxGrid1TableView1.Controller.FocusedColumnIndex],varString)

Add field in DataObject in PowerBuilder

I am new to PowerBuilder and I need to add a new column to a DataObject. The DataObject has several fields which retrieves data using select statement. So if I add a column in the select statement I get another field with a name compute_0041 along with the added column field. When i try to remove the compute_0041 field I cannot see any value in the field representing a new column. How do I remove the compute_0041 that gets automatically added?
Thanks
In Datawindow if you accidentally put a 0 or '' in one of the rows in the tab called Computed Columns then these columns may come in. Of course, you can also have a computed column yourself by specifying it there but since it seems you think you didnt do anything and it came up on its own it appears to be an accidental issue.
You can of course check for it by going to the SQL mode and checking for it there. Also, the last tab in the design view it shows the complete generated SQL where you can easily see a select column that is not chosen by you.
Hope the above will aid you to identify the issue. Please let me know if you still have the issue.

Delphi grid with a different data type in each row, displayed dynamically

I am trying to create a Delphi grid to allow display and edit in a db grid of data that might have a different data type on each row. I would like to display a specific control for each data type, e.g. when the data type is DateTime, I want to display my custom edit control that allows typing a date in or popping up a calendar.
The data looks something like this:
Name DataType DateValue StringValue BooleanValue
---------------------------------------------------------
A Date 1/1/2007
B String asdf
C Boolean True
...and in the db, this table has a column for each possible type of value. So, there is a BooleanValue column, DateValue, etc.
What I would like to do is display a single 'Value' column in the grid that displays the appropriate edit control depending on what the 'DataType' is for that row. So, the grid should look like :
Name DataType Value
---------------------------
A Date 1/1/2007
B String asdf
C Boolean True
It seems I will need to display a different edit control (to allow the user to edit the Value column) for each row dynamically based on the value of the DataType column. I know there are more advanced grids out there that handle this sort of problem, but the powers that be will not allow anything but what is available out-of-the-box with Delphi.
Any ideas on how to make something like this work?
Personally, I would not go for editing directly inside the TDBGrid in this case, since your Table is not DB normalized (I don't use it in any case actually). I would have used a Calculated field to display the desired value in the grid, And dynamically created the TDBxxxEdits on the form for each field type (How about your own TDBTreeEdit for example, a TDBRichEdit, or a DB Image pickup editor, etc...?).
In case you do want to use your own controls on the TDBGrid, and replace the default TInplaceEdit editor, you can refer the following article: Adding components to a DBGrid, and a related article: Displaying and editing MEMO fiels in Delphi's TDBGrid
Displaying all of the data in the same column is quite easy. You can simply add a calculated string field, and change the value according to what you are storing in that row.
The editing is quite a bit more complicated. If you want to have an in-place editor, you are in for a world of hurt... I've done it, it's a pain, and takes a lot of time. If you want to display a dialog to edit the value, that's much easier. You can add a column objects to the grid and you can setup the column you have attached to the calc field to display a button. When the button is clicked you simply display the editing dialog needed for that row, and commit the edits when the dialog is closed.
There are other ways to get this done, but I would say the above would be the shortest way. Other ways may include custom draw events to display your data in one column, intercept clicks to create your own editor, etc, etc, etc...
after add calculated fields .
Sample:
procedure OnCalculate(DataSet:TDataSet);
begin
case IndexText(DataSet['ValueType'],['Date','String','Boolean']) of
0:DataSet['DateValue']:=StrToDateTime(DataSet['Value']); // also converting
1:DataSet['StringValue']:=DataSet['Value'];
2:DataSet['BooleanValue']:= MatchText(DataSet['Value'],['1','True','T','Y','Yes']);
{etc datatypes}
end;
end;

TDataSource TDBMemo issues with values coming back

as a follow up question to my previous one. I can edit the DBMemo's now.
However they always seem to have the values from the very first row in the table.
I've done a DBMemo1.Text = ''
I've done a locate on the DataSet underneath to see if it would clear it. but no.
What do I need to do to have that empty and type something in to insert it?
Like any other data-aware control, the memo is bound to the values from the current row in the table. Try putting a TDBNavigator and a TDBGrid on your form so you can play around with the current record and see what's going on. If you want to create an empty row to insert into it, you need to call Insert or Append on the dataset, or click the + symbol on the TDBNavigator. This creates a new, blank row in the dataset and sets it to the current row.
You probably need to add a new row to the dataset.
DataSet.Append;
I saw your last question and I believe the following tutorial will help you:
http://delphi.about.com/od/database/a/databasecourse_2.htm
To clear the text from DBMemo you should either Insert, Append or Delete+Insert/Append on your data set. Mason explained you very well that you need to have a 'navigator' for your data set. Follow the examples provided here:
http://delphi.about.com/od/database/ss/dbcourse_browse.htm
Best regards,
Radu

Resources