Ticket Q33881
Visible to All Users

RecordIndex on par with Microsoft's DLL debauchery

created 17 years ago

OK, call me really thick, but I need help on this issue… yet again. I think this is at least my third question on the topic…
RecordIndexes!
How many could DevExpress create, and how confusing could this be?
let's see here, there is:
Controller.FocusedRowIndex
Controller.FocusedRecordIndex
DataController.FocusedRowIndex
DataController.FocusedRecordIndex
and finally DataController.FilteredRecordIndex[]
did I miss any?
did I miss any?
Then there is the magic bullet:
TcxCustomDataController.GetRowInfo(ARowIndex: Integer)
So far, this is what I have learned from trial/error in terms of getting the recordIndex to apply to the Values[][] array:
If you call DataController.FilteredRecordIndex[] you get back a RecordIndex - lovely, life is as it should be
If you refer to the DataController.FocusedRecordIndex you get back a RecordIndex - life is still good!
If you refer to the Controller.FocusedRecordIndex you must run this through the magic bullet (GetRowInfo)
I am to scared and nervous to sort out what I need to do if I have a Controller.FocusedRowIndex :)
The bottom line is, when things don't seem to work, and I suspect that I have the wrong index, I throw my RecordIndex into the DataController.GetRowInfo and magically it pops back to me the *real* record Index I probably want so I can manipulate the DataController.Values[][] correctly.
To Make matters worse, event handlers like TcxGridGetDisplayTextEvent (OnGetdisplayText) are defined as:
  TcxGridGetDisplayTextEvent = procedure(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: string) of object;
You would think from this, that if you wanted the RecordIndex from within this even handler, you would just refer to ARecord.Index. Bzzz. Try again. In fact you must use the magic bullet (GetRowInfo method) to get the real RecordIndex. And if you dig into the source you will see that the ARecord param is a misnomer. It should be ARow since GetRowInfo takes in a RowIndex and not a RecordIndex.
Yes, I have read the documentation… over and over. Clearly it is not sinking in. What I want to know is when exactly do I need to call GetRowInfo. When will the FocusedRowIndex differ form the FocusedRecordIndex for both the Controller and DataController. and most importantly - why?
cheers
-randall

Show previous comments (6)
DevExpress Support Team 17 years ago

    Hi Randall,
    You're correct in your assumption. Modifying values via a data controller's Values property sends a notification about a data change. Then, the ViewData and records are recreated. So, the record object is invalid as it actually references another record. You can pass a record object to the SelectedRowChange method only if this method doesn't change the grid's layout or data. To suspend these changes, enclose your code within the View's BeginUpdate/EndUpdate blocks or call the SetEditValue method mentioned above.
    Thanks,
    Alex

      See my latest comments in http://www.devexpress.com/Support/Center/p/Q34130.aspx - it all amounts to the same problem. The EndUpdate will still attempt to refresh the grid. and SetEditValue only works against the current record.
      -rs

      DevExpress Support Team 17 years ago

        Yes, that's how the EndUpdate and SetEditValue methods work. Based on your code sample, you're working with a focused record. So, the SetEditValue method should do the trick.
        Thanks,
        Alex

        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.