Unplanned
Last Updated: 14 May 2019 09:50 by ADMIN
ADMIN
Konstantin Dikov
Created on: 22 Jun 2015 13:45
Category: Grid
Type: Bug Report
0
When RadGrid is in Mobile RenderMode, sorting through the HeaderContextMenu is sorting by the UniqueName of the columns and not by the DataField (nor the SortExpression)

		
1 comment
ADMIN
Attila Antal
Posted on: 14 May 2019 09:19

Workaround

Place the following JavaScript function on the page where the grid is located. This will override an internal function where the Sort expressions are built and change it to use the DataField instead of Column UniqueName.

<script type="text/javascript">
    Telerik.Web.UI.GridMobileColumnView.prototype._click = function (e) {
        var $target = $(e.target);
        var owner = this.get_owner();
        var uniqueName = this._column.get_uniqueName();

        var dataField = this._column.get_dataField(); // DataField to be used instead of Column UniqueName
        var view;

        if ($target.hasClass("rgFilter")) {
            view = owner._getViewByType(Grid.MobileViewType.Filter);
        } else if ($target.hasClass("rgColumns")) {
            view = owner._getViewByType(Grid.MobileViewType.Columns);
        } else if ($target.hasClass("rgButtonSortAsc")) {
            this._handleSort(dataField + " ASC");
        } else if ($target.hasClass("rgButtonSortDesc")) {
            this._handleSort(dataField + " DESC");
        } else if ($target.hasClass("rgButtonSortClear")) {
            this._handleSort(dataField + " NONE");
        } else if ($target.hasClass("rgFreeze")) {
            this._column._toggleFreeze();
            this.close();
        } else if ($target.is(this._$groupOption)) {
            if (this._$groupOption.prop("checked")) {
                owner.fireCommand("UnGroupByColumn", uniqueName);
            } else {
                var isClientDataSourceBinding = !!owner._owner._clientDataSourceID;
                owner.fireCommand("GroupByColumn", isClientDataSourceBinding ? dataField : uniqueName);
            }
        }

        if (view) {
            view.show(this._column);
            e.preventDefault();
        }
    }
</script>