surveyjs / survey-analytics

Customizable JavaScript library to create interactive survey data dashboards and facilitate survey results analysis for your end-users.
https://surveyjs.io/dashboard/examples/plain-data
Other
98 stars 49 forks source link

`DataTables.tableData` is no longer accessible #457

Closed vitexikora closed 1 month ago

vitexikora commented 1 month ago

Are you requesting a feature, reporting a bug or asking a question?

Bug

What is the current behavior?

DataTables.tableData is not accessible (protected property with no getter)

What is the expected behavior?

Having DataTables.getTableData(), just like DataTables.getData()

How would you reproduce the current behavior (if this is a bug)?

No reproduction needed, it is in the codebase

Provide the test code and the tested page URL (if applicable)

Test code

const table = new DataTables(survey, answerData)

// used to be like this (before upgrading)
const rowsDisplayValues = table.tableData

// should be like this (no cast if type is provided)
const rowsDisplayValues = table.getTableData() as Record<string, string>[]

// now we use this...
const rowsDisplayValues = ({...table} as any as { tableData: Record<string, string>[]}).tableData

Specify your

JaneSjs commented 1 month ago

Hello @vitexikora, From what I gather, you wish to obtain data from a table populated with form results. Would you please elaborate on your usage scenario? Do you visualize survey results using DataTables or Tabulator?

I look forward to your reply.

vitexikora commented 1 month ago

Hello, our clients wish to obtain SurveyJS-gathered data from all users together in an Excel spreadsheet. One option would be to to parse SurveyJS answers on the back-end, however, we have decided that that would be too fragile, since these JSONs have no documentation and can change any time, and there is no official SurveyJS backend plugin. Instead, the backend provides a spreadsheet with users only and in the last column the full SJS answer data JSON. We then open the spreadsheet on the front-end, parse these answers via Tabulator & Table (now Datatables, since Table is now abstract) and fill in additional columns in the spreadsheet using the values we get directly from your library - this should ensure it works with every possible scenario of fields & answers, at least thats what we believe. It worked like charm from 1.9.79, but now in 1.11.10 we have to use an ugly hack.

Example

API-provided file: obrazek

FE-modified using native SurveyJS calls to Tabulator & Datatables obrazek

tsv2013 commented 1 month ago

I've addaed getTableData method via the 80673a1bf0b0d9d6b6a52a2867f74bd736bda6f6 commit