2012-07-18 5 views
1

나는이 코드를 사용하여 각 행에 레이블을 씁니다.행의 사용자 정의 레이블로 gridview를 정렬하는 방법

protected void grd_HtmlRowCreated(object sender, ASPxGridViewTableRowEventArgs e) 
{ 
ASPxLabel lblPoint = grd.FindRowCellTemplateControl(e.VisibleIndex, grdBildiriler.Columns["cTotalValue"] as GridViewDataColumn, "lblPoint") as ASPxLabel; 
lblPoint.text = "a value different for each row" 
} 

내 질문은 : 어떻게 [ "cTotalValue"] lblPoint.Text를 사용하여 열에 대한 정렬을 활성화 할 수 있습니다?

답변

1

ASPxGridView에는 CustomColumnSort라는 구현할 수있는 이벤트가 있습니다. http://documentation.devexpress.com/#AspNet/DevExpressWebASPxGridViewASPxGridView_CustomColumnSorttopic

protected void grid_CustomColumnSort (object sender, DevExpress.Web.ASPxGridView.CustomColumnSortEventArgs e) { 
    if (e.Column.FieldName == "cTotalValue") 
    { 
     e.Handled = true; 

     //you can get the row index of 2 columns being sorted through e.ListSourceRowIndex1 and e.ListSourceRowIndex2 
     //Get the two custom values and compare and set result 

     var value1 = "Some custom value you retrieve using e.ListSourceRowIndex1"; 
     var value2 = "Another custom value you retrieve using e.ListSourceRowIndex2"; 

     if (value1 > value2) 
      e.Result = 1; 
     else if (value1 == value2) 
      e.Result = Comparer.Default.Compare(value1, value2); 
     else 
      e.Result = -1; 
    } 
} 
관련 문제