I have several database tables and have a corresponding basic yii2 application that shows each table in a page. These tables have many columns, so each view contains a wide table. I therefore need horizontal scrolling, which I have enabled using CSS:
table {
display: block;
overflow-x: auto;
}
This works as intended. My problem is the following.
In the web interface, when I scroll to the right and sort by a column, the sorting works as expected, but the table is displayed such that the first few columns are visible on the page. That is, I have to scroll again to the right to view the column by which I sorted. I would like to prevent the table from moving horizontally when the table is reloaded after sorting i.e. I would like to keep the column by which I just sorted in place under my cursor. Could someone please say how could I achieve this?
Possibly use an AJAX/Pjax update to refresh the page. I recently was looking at some of the gii generated code, and "I THINK" it does a refresh in the controller.
Is your controller responding to an AJAX call? Somewhere in the gii code there is a line about uncommenting something for AJAX.
You may need to do a if(->request->isAJAX) return the information via a JSON reply. after the return you do need a Yii::$app->end(); You need to research how to specifically do this, but…