We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to click on columnheader, and sorting in datagrid ?

Hi. Nice site :) As the topic says. When i click on a colum header, i want to sort the data in the datagrid.. The datagrid is using an arraylist as source.. So question 1: How do I "catch" the click on certain column header question 2: How do I sort the data when clicking on the column header. Thank you,

3 Replies

AR Anupama Roy Syncfusion Team November 2, 2005 07:48 AM UTC

Hi Lasse, Do you have many columns in your ArrayList? You can write code on the DataGrid''s MouseDown event to catch the click on Colum header. And for sorting the data,save your data in arrary list and bind your dataview and set the Sort property of DataView .After that call DataGrid''s Refresh method. If you are populating from a database,you can use the SQL statement Select...from...OrderBy ,but you need to load data from database every time you want to sort the data, which makes application slower. Regards, Anu.


AD Administrator Syncfusion Team December 16, 2005 12:54 PM UTC

Hi How do i know which coloumn is selected in the mousedown event? thanks in advance


AD Administrator Syncfusion Team December 16, 2005 12:59 PM UTC

Hai I think thr is no need of any code.Just keep the AllowSorting=true. Am i right?

Loader.
Live Chat Icon For mobile
Up arrow icon