Skip to content

Commit

Permalink
wc: allow to prepare data for extensions when rendering a local table…
Browse files Browse the repository at this point in the history
… in interpreter grid #TASK-5066
  • Loading branch information
jmjuanes committed Oct 25, 2023
1 parent 25f310d commit 5aa1245
Showing 1 changed file with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ export default class VariantInterpreterGrid extends LitElement {
// return this.fillReportedVariants(variantResponse.responses[0].results);
// return variantResponse;

// Josemi Note 2023-10-25: we would need to move this to gridCommons in the future
// Prepare data for columns extensions
const rows = variantResponse.responses?.[0]?.results || [];
return this.gridCommons.prepareDataForExtensions(this.COMPONENT_ID, this.opencgaSession, this.filters, rows);
Expand Down Expand Up @@ -462,11 +463,35 @@ export default class VariantInterpreterGrid extends LitElement {
this.table = $("#" + this.gridId);
this.table.bootstrapTable("destroy");
this.table.bootstrapTable({
data: this.clinicalVariants,
// data: this.clinicalVariants,
columns: this._getDefaultColumns(),
sidePagination: "local",
sidePagination: "server",
iconsPrefix: GridCommons.GRID_ICONS_PREFIX,
icons: GridCommons.GRID_ICONS,

// Josemi Note 2023-10-25: we have added the ajax function for local variants also to support executing async calls
// when getting additional data from columns extensions.
// This should be moved to a gridCommons in a future
ajax: params => {
const tableOptions = $(this.table).bootstrapTable("getOptions");
const limit = params.data.limit || tableOptions.pageSize;
const skip = params.data.offset || 0;
const rows = this.clinicalVariants.slice(skip, skip + limit);

// Get data for extensions
this.gridCommons.prepareDataForExtensions(this.COMPONENT_ID, this.opencgaSession, null, rows)
.then(() => params.success(rows))
.catch(error => params.error(error));
},

// Jsoemi Note 2023-10-25: we use this method to tell bootstrap-table how many rows we have in our data
responseHandler: response => {
return {
total: this.clinicalVariants.length,
rows: response,
};
},

// Set table properties, these are read from config property
uniqueId: "id",
pagination: this._config.pagination,
Expand Down

0 comments on commit 5aa1245

Please sign in to comment.