! 제품 버전을 정확하게 입력해 주세요.
제품 버전이 정확하게 기재되어 있지 않은 경우,
최신 버전을 기준으로 안내 드리므로
더욱 빠르고 명확한 안내를 위해
제품 버전을 정확하게 입력해 주세요!

FrozenRow 설정 후 Sort시 FrozenRow도 같이 Sorting > Q&A | 토론

본문 바로가기

ComponentOne

Q&A | 토론 - WPF

WPF FrozenRow 설정 후 Sort시 FrozenRow도 같이 Sorting

페이지 정보

작성자 곰서방 작성일 2022-01-04 17:53 조회 1,291회 댓글 0건
제품 버전 : C1 WPF 4.5.2
컨트롤 이름 : C1 FlexGrid

본문

FrozenRow 설정 후 Sort시 FrozenRow도 같이 Sorting 됩니다.

FrozenRow제외할순 없나요?

  • 페이스북으로 공유
  • 트위터로  공유
  • 링크 복사
  • 카카오톡으로 보내기

댓글목록

등록된 댓글이 없습니다.

1 답변

WPF Re: FrozenRow 설정 후 Sort시 FrozenRow도 같이 Sorting

추천0 이 글을 추천하셨습니다 비추천0

페이지 정보

작성자 GCK폴 작성일 2022-01-12 07:50 댓글 0건

본문

첨부파일

안녕하세요 그레이프시티입니다. 



별도로 이것을 위해 기능이 제공되는 것은 없습니다 

그래서 열의 데이터에 따라 사용자 정의하여 구현해야 합니다.

고정된 행을 제외하고 Flexgrid를 정렬하려면 아래와 같이 SortingColumn 이벤트와 Icomparer 인터페이스를 사용시면 됩니다.

예를 들어 첫 번째 열에 대한 정렬을 구현하려면 다음과 같습니다. 


1) SortingColumn Event

   private void Grid_SortingColumn(object sender, C1.WPF.FlexGrid.CellRangeEventArgs e)
    {
        e.Cancel = true;
        SmartSort(sender, e.Column);
    }
    private void SmartSort(object sender, int column)
    {
        if(direction==ListSortDirection.Ascending) { direction = ListSortDirection.Descending; }
        else { direction = ListSortDirection.Ascending;}
        var dg = sender as C1.WPF.FlexGrid.C1FlexGrid;
        var lcv = (ListCollectionView)CollectionViewSource.GetDefaultView(dg.ItemsSource);
        lcv.CustomSort = new SmartSorter(direction,grid.FrozenRows);
    }

2) IComparer Interface

 public class SmartSorter : IComparer
{
    public ListSortDirection Direction { get; private set; }
    public int FrozenRow { get; set; }  
    public SmartSorter(ListSortDirection direction,int rw)
    {
        Direction = direction;
        FrozenRow = rw;
    }

    public int Compare(object x, object y)
    {
        var dummyx = x as Student;
        var dummyy = y as Student;  
        int valorx = dummyx.Sno;
        int valory = dummyy.Sno;

        if (valorx < FrozenRow && valory < FrozenRow)
            return 0;

        if (valorx <FrozenRow)
            return -1;

        if (valory <FrozenRow)
            return 1;

        if (Direction == ListSortDirection.Ascending)
        {
            return valory.CompareTo(valorx);
        }
        else
        {
            return valorx.CompareTo(valory);
        }
    }
}

간단한 샘플 프로젝트를 첨부드리니 참고해 주시기 바랍니다.


추가 문의가 있으시면 언제든 알려 주시기 바랍니다.


감사합니다.

그레이프시티 드림

댓글목록

등록된 댓글이 없습니다.

메시어스 홈페이지를 통해 제품에 대해서 더 자세히 알아 보세요!
홈페이지 바로가기
메시어스 홈페이지를 통해 제품에 대해서 더 자세히 알아 보세요!
홈페이지 바로가기
이메일 : sales-kor@mescius.com | 전화 : 1670-0583 | 경기도 과천시 과천대로 7길 33, 디테크타워 B동 1107호 메시어스(주) 대표자 : 허경명 | 사업자등록번호 : 123-84-00981 | 통신판매업신고번호 : 2013-경기안양-00331 ⓒ 2024 MESCIUS inc. All rights reserved.