How to make a row display always as the last row based on its cell value?
I have sorted the rows based on some column value. But there is a row which I need to display always as the last row irrespective of the sorting order. How can I do this?
Thanks.
Do you want the row at the bottom of the list? Or the bottom of the grid?
If you want to have a fixed row at the bottom of the grid, you would do something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Override.FixedRowStyle = FixedRowStyle.Bottom; }
Then you just set the Fixed property on the row you want. The InitializeRow event would be a good place to set this.
If you just want the row to always be last in the sort order, then you would have to use a custom SortComparer on the column.
I want the row to be displayed at the bottom of the list.
I don't even need to compare the column values, need to just display the row as the last row based on the column value.
If SortComparer is only the way can you please provide me a sample code.
This is not related to the Summary Information.
My scenario is something like this.
I have a grid with Date and Type Column.
I have three types of column values like "E, R and T".
I need to show the earliest date on top and then R on top of T and E always as the bottom row. My grid should look something like this. The type E should always display as the bottom row irrespective of its date value.
Date Type
03/07 R
03/07 T
03/08 R
03/08 T
03/07 E
What is the best way to solve this ?? Grouping ??
As I am new to Infragistics..I have never worked on grouping before... Can you please provide the sample code??
Thanks in Advance..
So you want the E row to always appear at the bottom, regardless of the date, and the regardless of whether the sort is ascending or descending? Is that right?
As I said above, the easiest way to do this would be to Fix row E at the bottom. But if you don't want that, then you would have to use the SortComparer like I suggested. I don't think grouping will help you there.
Basically, you would use a SortComparer for the Date column which also examines the Type column's value. If you are having trouble getting that to work, let me know and I will try to whip up a simple sample project for you.
Yes, I want the E row to always appear at the bottom.
Can you give me a sample project ? I have tried working on it and its a bit confusing to me.
Thanks in advance.
Hi,
I created a sample using the SortComparer like I mentioned, and I got it to work, but it was really very complicated.
So I found a simpler way to do this using the Move method on the rows collection.
So basically, the sample I attached here loops through all of the rows in the grid after it's bound and finds the row that I want to always be last. In this case, it's the row whose Type is "E".I just store a reference to that row in a variable.
Then I trap AfterSortChange and use the Move method to move that row to the bottom.
Thanks Mike.
The sample you gave works well on HeaderClickAction.
But I need my grid to be sorted when it is loaded.
I tried placing the Move in the formLoad after the for loop. If I do this, all my rows are not displaying in some cases.
Thanks a lot Mike.
That helped.
Hm, that shouldn't be. So the rows are scrolled out of view? That probably happens because the grid is trying to maintain the same first visible row after the sort.
You should be able to correct it by using the grid.ActiveRowScrollRegion.Scroll methods to scroll to the top after you Move the row.
Yes MIke, As I told you in my last post, If I try to call the Move method in Form_Load after the loop, the grid is not displaying all the rows. It is displaying only the row with the cell value E.
This happens only when the first row has the cell value E.
Okay, so then you need to call the same method to Move the row after the grid is loaded and sorted the first time. You can probably do it in Form_Load, right after the loop that finds the row and stores it.