Spreadsheet - Count of rows set by datasource

0 Answers 50 Views
Spreadsheet
Daniel
Top achievements
Rank 3
Iron
Iron
Iron
Daniel asked on 27 Mar 2023, 12:58 PM

Hey guys,

I'm currently working newly with the kendo spreadsheet. Default amount of rows is 200 and I can define it programatically, I know.

My spreadsheet has a datasource. Is there a smart solution to handle the count of rows by it's datasource? So if the datasource has 400 elements, that my spreadsheet increase the rows?

Best Regards,
Daniel

@(Html.Kendo().Spreadsheet()
	.Name("bestandsliste")
	.HtmlAttributes(new { style = "width:100%" })
	.Sheets(x =>
	{
		x.Add()
			.Name("Bestandsliste")
			.DataSource<Fahnenbestand>(y => y
				.Custom()
				.Transport(z => z.Read("spreadsheet_onRead"))
			);
	})
	.Sheetsbar(false)
	.Toolbar(false)
)

function spreadsheet_onRead(options) {
	$.ajax({
		url: `@ViewData[ViewDataVariables.UrlWebApi]/FlagCategory/GetOverviewAllFlagsAsSpreadsheet`,
		headers: { 'Authorization': '@token' },
		success: function (result) {
			console.log(options);
			console.log(options.rows);
			options.success(result.Data);
		},
		error: function (result) {
			options.error(result);
		}
	});
}



 

Daniel
Top achievements
Rank 3
Iron
Iron
Iron
commented on 29 Mar 2023, 09:16 AM | edited

Found a solution :)

function spreadsheet_onRead(options) {
	$.ajax({
		url: `@ViewData[ViewDataVariables.UrlWebApi]/FlagCategory/GetOverviewAllFlagsAsSpreadsheet`,
		headers: { 'Authorization': '@token' },
		success: function (result) {
			var sheet = kendoSpreadSheetBestandsliste.activeSheet();
			sheet.resize(result.Total, 3);

			options.success(result.Data);
		},
		error: function (result) {
			options.error(result);
		}
	});
}

Alexander
Telerik team
commented on 30 Mar 2023, 05:50 AM

Hi Daniel, 

Thank you for sharing your solution with the community. It is greatly appreciated.

Indeed, utilizing the resize method would expose the ability to incorporate a new number of rows, as well as columns.

No answers yet. Maybe you can help?

Tags
Spreadsheet
Asked by
Daniel
Top achievements
Rank 3
Iron
Iron
Iron
Share this question
or