在GridColumnView Telerik中排序方向

时间:2015-04-02 19:04:34

标签: c# wpf telerik

在使用Telerik时,我遇到了让SortDirection处理我的代码的问题。实际的后端代码如下所示:

private void SaveColumnSort(GridViewColumn dataGridColumn, string type)
  {
     var sortDirection = string.Empty;
     if (dataGridColumn.SortDirection == null)
     {
        sortDirection = "ASC";
     }
     else if (dataGridColumn.SortDirection == ListSortDirection.Ascending)
     {
        sortDirection = "DESC";
     }
     else
     {
        sortDirection = "ASC";
     }

     var sort = string.Format("{0};{1}", dataGridColumn.Header, sortDirection);

     if (type == "Claims")
     {
        PopulationOverlayInstance.Settings.RegOverlayClaimsColumnSort = sort;
     }
     else
     {
        PopulationOverlayInstance.Settings.RegOverlayChargesColumnSort = sort;
     }

     PopulationOverlayInstance.Settings.Save();
  }

datagridcolumn.sortdirection表示无法解析sortdirection符号。我尝试将顶部的GridViewColumn更改为其他内容但没有成功。

这都在radgridview

1 个答案:

答案 0 :(得分:0)

private void SaveColumnSort(GridViewColumn gridViewColumn, string type)
  {
     var sortDirection = string.Empty;
     switch (gridViewColumn.SortingState)
     {
        case SortingState.None:
           sortDirection = "ASC";
           break;
        case SortingState.Ascending:
           sortDirection = "DESC";
           break;
        default:
           sortDirection = "ASC";
           break;
     }

     var sort = string.Format("{0};{1}", gridViewColumn.Header, sortDirection);

     switch (type)
     {
        case "Claims":
           PopulationOverlayInstance.Settings.RegOverlayClaimsColumnSort = sort;
           break;
        case "Charges":
           PopulationOverlayInstance.Settings.RegOverlayChargesColumnSort = sort;
           break;
     }

     PopulationOverlayInstance.Settings.Save();
  }