Page 1 of 1

TCRDBGrid - some problems

Posted: Mon 02 Jul 2007 20:39
by mix2000
I am using TCRDBGrid which included in Mydac (5.10.0.9 for Delphi 7).
I have 3 problems with it:

1. Showing proper number of rows in grid

In TMyStoredProc I have:

FetchAll=False
Options: QueryRecCount=True

After opening TMyStoredProc, TCRDBGrid does not show number of records in status bar of the grid. There is only information f.e. "13/0". I found that if I am using TMyQuery everything is OK (f.e. "13/129") but I prefer TMyStoredProc. Maybe I am doing something wrong. Can somebody help me?

2. Popup menu in TCRDBGrid

I wanted to switch off the standard popup menu in the TCRDBGrid component. I found it possible only when switching off the option "dgIndicator" but then I am also loosing indicators I wanted to have. Maybe somebody had similar problem?

3. Sorting rows in TCRDBGrid

In TMyStoredProc when I have FetchAll=False and click the name of the column for sorting it - only rows loaded to the grid (f.e. 25) are sorted. When after it I am moving in grid and it loads next rows they are completly not sorted. Has everyone such problem ?

Thank you in advance for any help.

Posted: Wed 04 Jul 2007 12:53
by Antaeus
1) TMyQuery has access to the text of the query that returns records, so it can modify the query so that it returns total record count. For example, this query:

Code: Select all

SELECT * FROM Emp 
is converted to this one:

Code: Select all

SELECT COUNT(*) FROM Emp
The TMyStoredProc component has no such possibility. This is the reason of such behaviour.

2)
You can do this in following ways:
- change code of the TCRDBGrid.IndicatorClick method in the CRGrid.pas unit to disable this menu. Note this unit is not included in MyDAC Trial Edition;
- create a mew menu instance and assign the TCRDBGrid.OptionsMenu property with it:

Code: Select all

CRDBGrid.OptionsMenu := TPopupMenu.Create(nil);
3)
I could not reproduce this problem. Applying order to TCRDBGrid leads to assigning the IndexFieldsNames of attached dataset if it is possible. This will force fetching all records. Please provide more detailed description of this problem, or send me a complete small sample at evgeniyD*crlab*com to demonstrate it, including script to create server objects.

Posted: Sat 07 Jul 2007 15:32
by mix2000
Thank you very much for your help.
I solved 3rd problem so now everything is working OK.

I have one additional question: I wanted to change text showed in status bar of the grid - where number of record is presented. Is it possible to do it writing Delphi code somewhere in my application?

Posted: Mon 09 Jul 2007 06:29
by Antaeus
You should change sources of TCRDBGrid. You need the PaintStatusLine procedure in the CRGrid unit.