Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Jornik Posted October 21, 2016 Posted October 21, 2016 Hi, i have problems using two tables with sort options (\IPS\Helpers\Table\Db) on same page, both tables are created in same controller in function manage() function. Each table has some common columns (name) and some different columns. If i try to use sort for the 'name' column, it sorts both tables, if i try to use sort for column that only exists in one of these tables, i get an exception. Is there any way i could 'distinguish' for what table i am using sort?
Faqole Posted February 26, 2017 Posted February 26, 2017 I think that it would help if you posted the code.
BomAle Posted February 26, 2017 Posted February 26, 2017 i must disable with mixin a javascript function but i am rework avoid table into a widget on sidebar...
BomAle Posted March 4, 2017 Posted March 4, 2017 I am wrong, set data-disableTableUpdates on other table fix it but it change the history and url into address bar
BomAle Posted March 4, 2017 Posted March 4, 2017 solved with <div class='ipsBox' data-baseurl='{$table->baseUrl}' data-resort='{$table->resortKey}'{{if isset($table->baseUrl->queryString['orient'])}} data-disableTableUpdates{{endif}} data-controller='core.global.core.table{{if isset($table->baseUrl->queryString['orient'])}}( widgetPoll ){{endif}}' data-tableID='elTable_{$table->uniqueId}' {{if $table->getPaginationKey() != 'page'}}data-pageParam='{$table->getPaginationKey()}'{{endif}}> ips.controller.mixin('widgetPoll', 'core.global.core.table', false, function () { this.after('updateURL', function () { var state = History.getState(); if(this._initialURL != state.url) { $(window).unbind('statechange'); History.back(); History.Adapter.bind( window, 'statechange', _.bind( this.stateChange, this ) ); } }); }); but I don't know if effectly is the best solution @Rikki @bfarber
BomAle Posted March 22, 2017 Posted March 22, 2017 i have solved with ;( function($, _, undefined){ "use strict"; ips.controller.mixin('widgetPoll', 'core.global.core.table', false, function () { this.after('updateURL', function () { var state = History.getState(); if(( _.isUndefined( state.data.controller ) || state.data.controller != this.controllerID ) && this._initialURL != state.url) { var self = this; if( self._eventListeners.length ){ for( var i = 0; i < self._eventListeners.length; i++ ){ var data = self._eventListeners[i]; if( data.event == 'statechange'){ data.elem.off( data.event ); History.back(); data.elem.on( data.event, data.fn ); } } } } }); }); }(jQuery, _)); see previous post for html EDIT: don't work if in the same page there are other tables
BomAle Posted March 23, 2017 Posted March 23, 2017 this work fine: ;( function($, _, undefined){ "use strict"; ips.controller.mixin('widgetPoll', 'core.global.core.table', false, function () { this.around('updateURL', function (fn,newParams) { if(this.scope.data('controller') == 'core.global.core.table( widgetPoll )') { _.extend( this._urlParams, newParams ); var tmpStateData = _.extend( _.clone( this._urlParams ), { controller: this.controllerID } ); var newUrl = this._baseURL + this._getURL(); if( newUrl.slice(-1) == '?' ){ newUrl = newUrl.substring( 0, newUrl.length - 1 ); } this.fakeChange({ data: tmpStateData, title: document.title, url: newUrl }); } else { fn(newParams); } }); this.around('stateChange', function (fn) { if(this.scope.data('controller') != 'core.global.core.table( widgetPoll )') { fn(); } }); /** * stateChange alternative * * @returns {void} */ this.fakeChange = function (state) { // Because tables can exist alongside other widgets that manage the URL, we use the controller property // of the state data to identify states set by this controller only. // If that property doesn't exist, or if it doesn't match us, just ignore it. if( ( _.isUndefined( state.data.controller ) || state.data.controller != this.controllerID ) && this._initialURL != state.url ) { return; } /*if( state.data.bypassState ){ Debug.log('got state, but bypassing update'); //Debug.log( state ); //return; }*/ this._handleStateChanges( state ); // Update data this._urlParams = state.data; // Get le new results // If the initial URL matches the URL for this state, then we'll load results by URL instead // of by object (since we don't have an object for the URL on page load) if( this._initialURL == state.url ){ this._getResults( state.url ); } else { this._getResults(); } }; }); }(jQuery, _)); thanks for mixin feature @Rikki
Recommended Posts
Archived
This topic is now archived and is closed to further replies.