Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Jon Erickson Posted September 3, 2018 Posted September 3, 2018 Hey all, I am displaying multiple Db/Tables on the same page which causes them to no work properly. I am assuming this is because the javascript functions are trying to be called on each table etc. How do I differentiate the tables so that the javascript only works on one table at a time and does not call the other one? Do I need to create separate table controllers for each of them? Thanks!
BomAle Posted September 3, 2018 Posted September 3, 2018 I have solved with a custom mixin but I also would know if exist a better solution.
Adriano Faria Posted September 4, 2018 Posted September 4, 2018 You just need to use a different key for each table.
Jon Erickson Posted September 4, 2018 Author Posted September 4, 2018 @Adriano Faria where do you define the Table key?
Adriano Faria Posted September 4, 2018 Posted September 4, 2018 Sorry, I’m on a mobile device now and don’t remember. I’ll post tomorrow in the morning if anyone else helps you.
Adriano Faria Posted September 4, 2018 Posted September 4, 2018 10 hours ago, Jon Erickson said: where do you define the Table key? Use: $table->resortKey = 'something'; It's enough to use a different resortKey per table.
bfarber Posted September 4, 2018 Posted September 4, 2018 You can also use a different $paginationKey to prevent conflicts with pagination (e.g. in the event you link to a specific page in the table).
Jon Erickson Posted September 4, 2018 Author Posted September 4, 2018 Are you using the core.global.core.genericTable or core.global.core.table controller? They both handle the table differently. The genericTable does not process paginationClicked actions using the paginationKey while the regular table does. The regular table does not respond to tableSort actions but the genericTable does. Looking at the table controller, the resortKey is only used as a parameter when fetching new data for the table and the Table.php model only checks to see that it is present when returning the data. It does not differentiate the tables on a single page. Below is how my tables are displayed. PHP: $table = new \IPS\Helpers\Table\Db( \IPS\perscom\Records\ServiceRecord::$databaseTable, \IPS\Http\Url::internal( 'app=perscom&module=personnel&controller=soldier&tab=service&id=' . $soldier->id, 'front', 'soldier_service' ), array( 'service_records_soldier=?', $soldier->id ) ); $table->include = array( 'service_records_date', 'service_records_text', 'service_records_document', 'service_records_soldier', 'service_records_id' ); $table->limit = 15; $table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'servicerecords', 'perscom' ), 'serviceRecordTable' ); $table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'servicerecords', 'perscom' ), 'serviceRecordRows' ); $table->rowClasses = array( 'service_records_text' => array( 'ipsTable_wrap' ) ); $table->sortDirection = $table->sortDirection ?: 'desc'; $table->sortBy = $table->sortBy ?: 'service_records_date'; $table->paginationKey = 'serviceRecordsPage'; $table->resortKey = 'serviceRecords'; HTML: <div data-baseurl="https://www.deschutesdesigngroup.com/index.php?/perscom/personnel/soldier/service/1/&serviceRecordsPage=1" data-resort="serviceRecords" data-tableid="serviceRecords" data-controller="core.global.core.table" data-pageparam="serviceRecordsPage"> The other strange thing is...each table is under its own tab. When using the genericTable controller and I switch between the tabs, the correct tab data and table is loaded but the URL appears to be from the last tab, but the table parameters are from the current tab. Super strange. Using the regular table controller, the URL's are updated properly.
Midnight Modding Posted September 5, 2018 Posted September 5, 2018 I have a lot of situations with multiple ones on a page. I had planned on doing different pagination keys, but I can't remember if I did or not, so I'm glad you asked this, where I can look back and be sure I didn't forget and can either do that or the resort key. In case you haven't noticed my other posts on it, a problem nobody seems able to figure out is when you put a Table/Db in a tab. A lot of issues come up then. Overlapping content from one tab to another, etc.... only happens on the public side, though. edit: that post above about different table types is going to make it confusing, though, since they seem to have so many differences in how they handle things. I haven't really got into testing multiple pages on pages with my multiple tables yet, I don't think.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.