Beispiel #1
0
        protected void dGridMain_CustomColumnSort(object sender, DevExpress.Web.ASPxGridView.CustomColumnSortEventArgs e)
        {
            if (e.Column != null && e.Column.GroupIndex > 0)
            {
                ASPxGridView Grd = sender as ASPxGridView;

                string campo = "ORDENACAO";//e.Column.FieldName;


                var i1 = getExpSortIndex(e.GetRow1Value(campo).ToString());
                var i2 = getExpSortIndex(e.GetRow2Value(campo).ToString());
                e.Handled = true;
                e.Result  = System.Collections.Comparer.Default.Compare(i1, i2);
            }
        }
    protected void ASPxGridView1_CustomColumnSort(object sender, DevExpress.Web.ASPxGridView.CustomColumnSortEventArgs e)
    {
        ASPxGridView grid           = sender as ASPxGridView;
        bool         isRow1Selected = grid.Selection.IsRowSelectedByKey(e.GetRow1Value(grid.KeyFieldName));
        bool         isRow2Selected = grid.Selection.IsRowSelectedByKey(e.GetRow2Value(grid.KeyFieldName));

        e.Handled = isRow1Selected != isRow2Selected;
        if (e.Handled)
        {
            if (e.SortOrder == DevExpress.Data.ColumnSortOrder.Descending)
            {
                e.Result = isRow1Selected ? 1 : -1;
            }
            else
            {
                e.Result = isRow1Selected ? -1 : 1;
            }
        }
    }
    protected void grid_CustomColumnGroup(object sender, DevExpress.Web.ASPxGridView.CustomColumnSortEventArgs e)
    {
        if (e.Column.Name != "VisibleProductName")
        {
            return;
        }

        int res1 = GetGroupNumber(e.GetRow1Value(e.Column.FieldName).ToString());
        int res2 = GetGroupNumber(e.GetRow2Value(e.Column.FieldName).ToString());

        int res = res1 - res2;

        if (res < 0)
        {
            res = 1;
        }
        else if (res > 0)
        {
            res = -1;
        }

        e.Result  = res;
        e.Handled = true;
    }