-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Resolved #329 - Tabulator - Server-Side (Remote) Pagination * Resolved #329 - Tabulator - Server-Side (Remote) Pagination - support promises and server-side filtering and sorting * Update src/tables/table.ts Co-authored-by: RomanTsukanov <RomanTsukanov@users.noreply.github.com> * Update src/tables/table.ts Co-authored-by: RomanTsukanov <RomanTsukanov@users.noreply.github.com> * Update src/tables/table.ts Co-authored-by: RomanTsukanov <RomanTsukanov@users.noreply.github.com> * Update src/tables/table.ts Co-authored-by: RomanTsukanov <RomanTsukanov@users.noreply.github.com> * Update src/tables/table.ts Co-authored-by: RomanTsukanov <RomanTsukanov@users.noreply.github.com> * Work for #329 - Tabulator - Server-Side (Remote) Pagination - Updated API * Work for #329 - Tabulator - Server-Side (Remote) Pagination - Fixed typings --------- Co-authored-by: tsv2013 <tsv2013@noreply.github.com> Co-authored-by: RomanTsukanov <RomanTsukanov@users.noreply.github.com>
- Loading branch information
1 parent
d05cdfb
commit a05429c
Showing
4 changed files
with
129 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Tabulator Example</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
|
||
<link rel="stylesheet" type="text/css" href="../node_modules/tabulator-tables/dist/css/tabulator.css" /> | ||
<link rel="stylesheet" type="text/css" href="../packages/survey.analytics.tabulator.css" /> | ||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script> | ||
<script type="text/javascript" | ||
src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.0.10/jspdf.plugin.autotable.min.js"></script> | ||
<script type="text/javascript" src="https://oss.sheetjs.com/sheetjs/xlsx.full.min.js"></script> | ||
<script src="../node_modules/tabulator-tables/dist/js/tabulator.js"></script> | ||
<script src="../node_modules/survey-core/survey.core.js"></script> | ||
<script src="../node_modules/survey-core/survey.i18n.js"></script> | ||
<script src="../packages/survey.analytics.tabulator.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div id="tabulatorContainer"></div> | ||
<script src="./data_multi_lang.js"></script> | ||
<script src="./tabulator-remote.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var survey = new Survey.SurveyModel(json); | ||
|
||
var normalizedData = data.map(function (item) { | ||
survey.getAllQuestions().forEach(function (q) { | ||
if (!item[q.name]) { | ||
item[q.name] = ""; | ||
} | ||
}); | ||
return item; | ||
}); | ||
|
||
SurveyAnalyticsTabulator.Table.showFilesAsImages = true; | ||
|
||
// function getPaginatedData({ offset, limit, filter, sort, callback }) { | ||
// console.log(JSON.stringify(filter)); | ||
// console.log(JSON.stringify(sort)); | ||
// setTimeout(() => { | ||
// callback({ data: normalizedData.slice(offset, offset + limit), totalCount: normalizedData.length }); | ||
// }, 1000); | ||
// } | ||
|
||
// function getPaginatedData({ offset, limit, filter, sort}) { | ||
// const url = "http://www.example.com/"; | ||
// const reqBody = { offset, limit, filter, sort }; | ||
// return fetch(url, { body: reqBody }); | ||
// } | ||
|
||
function getPaginatedData({ offset, limit, filter, sort }) { | ||
console.log(JSON.stringify(filter)); | ||
console.log(JSON.stringify(sort)); | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
resolve({ data: normalizedData.slice(offset, offset + limit), totalCount: normalizedData.length }); | ||
}, 1000); | ||
}); | ||
} | ||
|
||
var surveyAnalyticsTabulator = new SurveyAnalyticsTabulator.Tabulator( | ||
survey, | ||
getPaginatedData | ||
); | ||
|
||
surveyAnalyticsTabulator.render("tabulatorContainer"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters