The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi,
I am binding the databound grid control to an arraylist of my custom objects, manually adding GridBoundColumns for the columns that I wish to display.
The grid didn''t automatically provide sorting (I''m guessing because I didn''t implement iComparable??). I''ve manually wired it up so that when they click on a column heading, a customised comparer object bound to the arraylist reorders the data. I then rebind the AL to the grid and ''voila''. This works fine.
The problem is that I can''t get the little arrows showing up and down in the currently sorted by column headings. Can you please show me how to set these manually?
Thanks in advance,
Damien
ADAdministrator Syncfusion Team April 2, 2004 06:33 AM UTC
In order for the GridDataBoundGrid to handle sorting, the datasource must implement IBindingList and supporting through its sorting implementation methods. ArrayList does not implement IBindingList.
To get the sort headers I think the simplest thing to do is to add a member to your class, sortedCol, that you set when you sort a column. Then handled the PrepareViewStyleInfo event, and if the cell is your sort header cell, set its properties there.
//add the member
private int sortedCol
//then after you complete your sort, insert code to set the
//member and redraw the header row so PrepareViewStyleInfo will be hit
this.sortedCol = e.ColIndex;
this.gridDataBoundGrid1.RefreshRange(GridRangeInfo.Row(0));
//the event handler
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if(e.RowIndex == 0 && e.ColIndex == sortedCol)
{
e.Style.CellType = "ColumnHeaderCell";
e.Style.Tag = ListSortDirection.Descending;
}
}