Display only distinct rowsTag(s): Datawindow


First you need to Sort() the datawindow based on the columns that need to be distinct. After you apply a Filter(), to filter out the non-distinct rows.

For example, we have a datawindow with a column named prod_id and we want to display only one row for each prod_id.

First we turn off the datawindow redraw function to speed up the operation

dw_1.setredraw(false)
Sort the rows based on the prod_id column
dw_1.setsort("prod_id a")
dw_1.sort()
Define the appropriate Filter
dw_1.SetFilter("IsNull(prod_id[-1]) OR prod_id[-1] <> prod_id")
dw_1.filter()
Finally turn back on the datawindow redraw
dw_1.setredraw(true)

blog comments powered by Disqus