Good Day,
How to Get Actual Row number of a DataWindow in the initial retrieval, after applying the filter or sort is changed of a DataWindow using computed field?
Regards
Antony
Good Day,
How to Get Actual Row number of a DataWindow in the initial retrieval, after applying the filter or sort is changed of a DataWindow using computed field?
Regards
Antony
Hi Antony,
Not sure exactly what you're trying to do, but does it have to be a computed field? Would GetRowIDFromRow/GetRowFromRowID help?
Cheers.
Best Regards,
Ricardo
In a computed field you can use GetRow() or CurrentRow().
GetRow() is the actual row number at the time. Most useful in the detail band.
CurrentRow() on the other hand is same dw_1.GetRow() in powerscript script.
The datawindow automatically renumbers all rows of data after a SORT, FIND, INSERT, or DELETE.
That's why row-based delete operations should always occur in reverse row order.
FOR ll_row = ll_rowcount TO 1 STEP -1
.....
NEXT
Later -
Oaln
What do you mean actual row number? Row number should be independent of the data in the datawindow or datastore.
If you have code that's row number dependent, you should really consider changing to code to do a Find base on a key field(s), or some other unique piece of data.
If you can't do this for some reason, you could create a dummy column in your select, and immediately after the initial retrieve, fill it in with row number like this:
add "cast(0 as integer) as fake_row" to you select statement (note: your db may need different style of cast statment)
dw_1.retrieve()
long ctr
for ctr = 1 to dw_1.rowcount()
dw_1.setitem(ctr, "fake_row", ctr)
next
No matter how you change sort order, or filters, the "fake_row" column will always contain the original row number (unless you do something that requires a reselectrow, in which case you'll need to save off the original value and restore it afterwards).
What I am looking how I can keep the orginal row number after retrieval of datawindow, if datawindow is filter, sort or delete records, without creating physical column or dummy column in the sql
Regards
Antony
So have you tried GetRowIDFromRow/GetRowFromRowID? GetRowIDFromRow should give you the unique row identifier after retrieve. GetRowIDFromRow will return the original id regardless of which buffer you access.
Cheers.
Best Regards,
Ricardo