Approved
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 is to override an internal function where the Sort expressions are built and use the DataField instead of Column UniqueName.

Place the following JavaScript function on the page where the grid is located:

<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 uniqueName = 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(uniqueName + " ASC");
        } else if ($target.hasClass("rgButtonSortDesc")) {
            this._handleSort(uniqueName + " DESC");
        } else if ($target.hasClass("rgButtonSortClear")) {
            this._handleSort(uniqueName + " 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", this._column.get_uniqueName());
            } else {
                var isClientDataSourceBinding = !!owner._owner._clientDataSourceID;
                owner.fireCommand("GroupByColumn", isClientDataSourceBinding ? this._column.get_dataField() : this._column.get_uniqueName());
            }
        }
 
        if (view) {
            view.show(this._column);
            e.preventDefault();
        }
    }
</script>