|
function updateCollection() {
// To update the modified data in spreadsheet (For ex: bind only 10 records in spreadsheet)
new DataManager({
url: "https://ej2services.syncfusion.com/production/web-services/api/Orders"
})
.executeQuery(new Query().take(10))
.then((e: ReturnOption) => {
spreadsheet.sheets[0].ranges[0].dataSource = e.result.result; // bind the modified records in the datasource property
});
} |
Here is the code (malformed divs as they won't display properly in the forum):
div id="spreadsheet">
div id="customBtn" class="e-btn"> To refresh the data
var spreadsheet_data = new ej.data.DataManager({
url: 'https://ej2services.syncfusion.com/production/web-services/api/Orders',
});
var spreadsheet = new ej.spreadsheet.Spreadsheet({
sheets: [
{
name: "Shipment Details",
ranges: [{ showFieldAsHeader: true, startCell: "A1",
//Shows at the spreadsheet load
//dataSource: spreadsheet_data //Using a linked dataManager results in values showing up on load in the spreadsheet
}],
columns: [
{ width: 100 },
{ width: 130 },
{ width: 110 },
{ width: 100 },
{ width: 180 },
{ width: 100 },
{ width: 130 },
{ width: 150 },
{ width: 200 },
{ width: 180 },
{ width: 180 }
]
}
],
created: function(args){
//Using this function doesn't show data on load in the spreadsheet
spreadsheet.cellFormat(
{ fontWeight: "bold", textAlign: "center" }, "A1:K1"
);
new ej.data.DataManager({
url: 'https://ej2services.syncfusion.com/production/web-services/api/Orders',
})
.executeQuery(new ej.data.Query())
.then(function(e) {
// console.log(e.result); //If you do e.result.result = undefined
//console shows an array of 45 items
spreadsheet.sheets[0].ranges[0].dataSource = e.result;
// console.log(spreadsheet.sheets[0].ranges[0].dataSource);
//console shows an array of 45 items BUT no results are shown
});
},
});
spreadsheet.appendTo('#spreadsheet');
document
.getElementById("customBtn")
.addEventListener("click", updateCollection);
function updateCollection() {
// To update the modified data in spreadsheet ( For ex: bind only 10 records in spreadsheet)
//console.log(spreadsheet.sheets[0].ranges[0].dataSource);
//console shows an array of 45 records
new ej.data.DataManager({
url: 'https://ej2services.syncfusion.com/production/web-services/api/Orders',
})
.executeQuery(new ej.data.Query().take(5))
.then(function(e) {
spreadsheet.sheets[0].ranges[0].dataSource = e.result; // bind the modified records in the datasource property
// console.log(spreadsheet.sheets[0].ranges[0].dataSource);
//console shows an array of 5 records BUT the spreadsheet does not change what is shown
});
//console.log("Out of DataManager");
}
Fresh Load of the page.
After the Refresh button hit.
Loaded with the Data Manager outside the created function call.
Attachment: Pictures_ef41c003.7z
|
created: function(args) {
//Using this function doesn't show data on load in the spreadsheet
spreadsheet.cellFormat(
{ fontWeight: "bold", textAlign: "center" },
"A1:K1"
);
new ej.data.DataManager({
url:
"https://ej2services.syncfusion.com/production/web-services/api/Orders"
})
.executeQuery(new ej.data.Query())
.then(function(e) {
// console.log(e.result); //If you do e.result.result = undefined
//console shows an array of 45 items
spreadsheet.sheets[0].ranges[0].dataSource = e.result;
// console.log(spreadsheet.sheets[0].ranges[0].dataSource);
//console shows an array of 45 items BUT no results are shown
});
}
});
new ej.data.DataManager({
url: "https://ej2services.syncfusion.com/production/web-services/api/Orders"
})
.executeQuery(new ej.data.Query().take(5))
.then(function(e) {
spreadsheet.sheets[0].ranges[0].dataSource = e.result.result; // bind the modified records in the datasource property
// console.log(spreadsheet.sheets[0].ranges[0].dataSource);
//console shows an array of 5 records BUT the spreadsheet does not change what is shown
});
//console.log("Out of DataManager");
}
|