public override void onInit()
 {
     sap.ui.core.routing.Router oRouter = this.getRouter();
     this._oTable           = this.byId <sap.m.Table>("employeesTable");
     this._oVSD             = null;
     this._sSortField       = null;
     this._bSortDescending  = false;
     this._aValidSortFields = new string[] { "EmployeeID", "FirstName", "LastName" };
     this._sSearchQuery     = null;
     this._oRouterArgs      = null;
     this._initViewSettingsDialog();
     // make the search bookmarkable
     oRouter.getRoute("employeeOverview").attachMatched(_onRouteMatched);
 }
        public void _initViewSettingsDialog()
        {
            var oRouter = this.getRouter();

            void confirmFunction([email protected] <sap.m.ViewSettingsDialog.ConfirmInfo> oEvent, object oData)
            {
                var oSortItem = oEvent.getParameterFor(e => e.sortItem);

                this._oRouterArgs.sortField      = oSortItem.getKey();
                this._oRouterArgs.sortDescending = oEvent.getParameterFor(e => e.sortDescending);
                this._oRouterArgs.showDialog     = false;
                oRouter.navTo("employeeOverview", new { query = this._oRouterArgs }, true /*without history*/);
            }

            void cancelFunction([email protected] oEvent, object oData)
            {
                this._oRouterArgs.showDialog = false;
                oRouter.navTo("employeeOverview", new { query = this._oRouterArgs }, true /*without history*/);
            }

            this._oVSD = new sap.m.ViewSettingsDialog("vsd", new sap.m.ViewSettingsDialog.Settings {
                confirm = confirmFunction,
                cancel  = cancelFunction
            });
            // init sorting (with simple sorters as custom data for all fields)
            this._oVSD.addSortItem(new sap.m.ViewSettingsItem(new sap.m.ViewSettingsItem.Settings {
                key      = "EmployeeID",
                text     = "Employee ID",
                selected = true                          // we do this because our MockData is sorted anyway by EmployeeID
            }));

            this._oVSD.addSortItem(new sap.m.ViewSettingsItem(new sap.m.ViewSettingsItem.Settings {
                key      = "FirstName",
                text     = "First Name",
                selected = false
            }));

            this._oVSD.addSortItem(new sap.m.ViewSettingsItem(new sap.m.ViewSettingsItem.Settings {
                key      = "LastName",
                text     = "Last Name",
                selected = false
            }));
        }