cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort a table column

former_member182374
Active Contributor
0 Kudos

Hi All,

I'm trying to implement a table sort.

I changed the column's sort state to Ascending and then I see the Sort Asc/Desc arrows on the columns title but when I press the arrows the Sort event doesn't fired.

Also, I tried to do it by regular button.

I write the following code in the button's action:

Table1.Columns("FirstName").SortState = sortState.ASCENDING

Table1.SortColumn("FirstName")

I get

"Input string was not in a correct format"

I tried also with Integer index instead of "FirstName", still - didn't help

What steps need to be done in order to implement table sort?

Thanks,

Omri

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member182374
Active Contributor
0 Kudos

Hi Reshef,

I looked at the documentation.

The code below is not executed when I press the column:

Private Sub Table1_Sort(ByVal sender As Object, ByVal e As SAP.Web.UI.Controls.Table.SortEventArgs) Handles Table1.Sort

Write("Sort")

End Sub

Another question:

My datasource is a dataTable filled with data which I get from a DB.

When the page loads I retrieve the data.

The page has Add, Update & Delete of data.

Does it mean that for each operation on the data (Add, Update & Delete) I need to update the dataTable, sort it and then bind it again in order to see the change in the

SAP Table?

Thanks,

Omri

Former Member
0 Kudos

Hi Omri,

Is the sort handler registered with the table's sort event?

For your second question, in case that u perform the operation on the data using an sql query directly on the database (and not by working on the rows of the data table) u will have to update the data of the DataTable.

Binding is requied anyway.

Regarding the sort operation, u can sort either the Table control or the Data of the DataView (DataTable.DefaultView) using the DataView.Sort property.

Reshef

Former Member
0 Kudos

Hi Omri,

Did u supply an handler for the sort event?

Please look at the documentation of the Table.Sort event in the PDK documentation.

U can find it online here: https://media.sdn.sap.com/html/submitted_docs/dotnet/Reference/SAP.Web.UI.Controls.Table.Sort.html

Thanks, Reshef