cancel
Showing results for 
Search instead for 
Did you mean: 

Quickly Sort an iGrid

Former Member
0 Kudos

I want to sort an iGrid based on the column a user double clicks within the grid. Is this easy to do?

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Perfect.

Thanks

Former Member
0 Kudos

Thanks. I thought this was the route to go.

jcgood25
Active Contributor
0 Kudos

John,

You might also consider using ...ORDER BY [Param.1] [Param.2] in your query template. This would give you a very convenient way to not only sort by the selected column but also control the sort order. You can do the comparison for ASC / DESC in Param.2 and if the newly selected column name is not the same as the active Param.1 you know they've selected a new column and can revert to ASC sort, otherwise you use the opposite sort order.

Regards,

Jeremy

Former Member
0 Kudos

Thanks, but ...

Former Member
0 Kudos

Hi, John.

There is an event fired when the column is selected. You can attach a Javascript handler to this event, and you can determine the name of the column that was selected. If the back-end source of data is a relational database (e.g. you are linking your iGrid to a SQLQuery), you need only change the SortExpr property of the query object (if using Query mode) or the SQL expression itself (if using FixedQuery mode), then refresh the iGrid.

If using a FixedQuery, one other cool trick for this is to use the Param.# placeholders to provide dynamic sorting. As an example, you might write your fixed query expression as:

SELECT EmpID,EmpName,Salary,Birthdate FROM Employees ORDER BY [Param.1]

Then, in the query template editor Parameters page, provide a default value for the Parameter, in this case, perhaps EmpID.

Then, at runtime, you can simply set Param.1 to the name of the column selected, refresh the iGrid, and off you go.

- Rick

Former Member
0 Kudos

Yes.