Ticket Q32378
Visible to All Users

Row/record index confusion

created 17 years ago

Hi,

I'm having major issues getting my head around the various ways of indexing rows and records in the Controller and DataController classes. As an example, take this excerpt from the help:

"Do not confuse the View's Controller.FocusedRecordIndex and DataController.FocusedRecordIndex properties. The former specifies the row index of the focused record, i.e. the record's visual position (this is equivalent to the Index property of the Controller.FocusedRecord object and to the TcxCustomDataController.FocusedRowIndex property). The latter specifies the record index of the focused record, i.e. the position of the record in the data controller/dataset (this is equivalent to the RecordIndex property of the Controller.FocusedRecord object)."

To be honest, I'm finding this mindbendling difficult to understand and then remember and am spending inordinate amounts of time buried in the help files every time I want to deal with focused or selected records to make sure my code is doing what I think it's doing. Surely I can't be the only user who's commented on the complexity of this?

Has anyone written a simple® guide to this functionality that might help me better understand it?

Toby Groves

Answers

created 17 years ago

Hi Toby,
Let me first explain how the ExpressQuantumGrid (more precisely the ExpressDataController) manages its data. When the DataController loads data from a dataset, it creates a rectangular matrix (N rows x M columns) where records are ordered in the same manner as they were fetched from the dataset. We name these data rows "records", and you're referring to them when using the Values property of the DataController. When the data layout is changed (records are filtered, sorted or grouped), the DataController does not actually affect the original data matrix (the order of records remains the same). Instead, it uses logical "rows" which represent data in the current layout (taking sorting and grouping into account). "Rows" don't store any data, they just refer to corresponding "records".
I've attached a small sample, illustrating this. The top grid contains several columns. The first two columns display logical and physical index for each record. If you change the Grid's layout , you'll see that the physical index of each record isn't changed, but the logical index does change. The bottom grid shows you that this changes doesn't affect the dataset. Use two buttons on the right to programmatically set a filter and sorting, and obtain indexes for the focused record.
I hope this information will help you understand the Grid's behavior.
Thanks,
Dimitros

    Comments (2)
    Serge (DevExpress Support) 17 years ago

        Toby Groves,

        I agree. The helpfiles are written for themselves, for internal use.  Its almost impossible to understand the helpfiles without creating projects and do a lot of experiments. I have to create my own helpfiles of component after component so i have somewhere to look for clear and precise information. I got the feeling helpfiles and demos are more created to show of their skills than to focus on teaching. To learn about D you first have to also be a master of A, B and C that has notting to do with D. I consider moving away from Delphi just because of this. That something i myself could teach in anyone in one day will take 1 week for me to learn because of the imprecise and over-complicated documentation.

        Regards, Pär.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.