Exemple #1
0
    protected void ASPxGridView1_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
    {
        ASPxGridView1.ClearSort();
        for (int i = 0; i < ((ASPxGridView)sender).Columns.Count; i++)
        {
            if (((ASPxGridView)sender).Columns[i] is GridViewDataColumn)
            {
                GridViewDataColumn col = ((ASPxGridView)sender).Columns[i] as GridViewDataColumn;
                if (ASPxHiddenField1.Contains("clientColumnNamesunit" + col.FieldName))
                {
                    Dictionary <string, object> dict = ASPxHiddenField1.Get("clientColumnNamesunit" + col.FieldName) as Dictionary <string, object>;
                    string sortOrder = dict["Order"] as string;
                    string FieldName = dict["FieldName"] as string;

                    if (sortOrder == null || FieldName == null)
                    {
                        object previousField;
                        if (dict.TryGetValue("ClearSort", out previousField))
                        {
                            ((GridViewDataColumn)((ASPxGridView)sender).Columns[(string)previousField]).UnSort();
                        }
                        continue;
                    }

                    if (sortOrder == "A")
                    {
                        ((GridViewDataColumn)((ASPxGridView)sender).Columns[FieldName]).SortAscending();
                    }
                    else
                    {
                        ((GridViewDataColumn)((ASPxGridView)sender).Columns[FieldName]).SortDescending();
                    }
                }
            }
        }
    }