Bind Dataset Result to Telerik Spreadsheet

2 posts, 0 answers
  1. Karthik
    Karthik avatar
    10 posts
    Member since:
    Nov 2011

    Posted 20 Oct 2017 Link to this post


    I have embed the spreadsheet for MVC in my mvc application.I am loading data from database into a dataset and I want to bind the dataset to my spreadsheet. I am not using Entity Framework as my database and column retrieved dynamic and changes each time. Hence i wont be able to create a model for my values. 

    Below is my code for loading data to dataset

    public ActionResult Products_Load([DataSourceRequest]DataSourceRequest request)
                DataSet ds = HandlerFunctions.GetDynamicSheetData(1, 2);
                var das = ds.Tables[0].AsEnumerable().AsQueryable();
                DataSourceResult result = das.ToDataSourceResult(request);
                return Json(result);


    I am struck on how to map this dataset to my spreadsheet in the cshtml using @(Html.Kendo().Spreadsheet()

    Can anyone help me in how to bind the dataset to spreadsheet control in razor view?


  2. Veselin Tsvetanov
    Veselin Tsvetanov avatar
    1041 posts

    Posted 25 Oct 2017 Link to this post

    Hello Karthik,

    The required could be achieved by setting the Sheet DataSource with JavaScript instead of configuring it in the Spreadsheet HTML helper. To do that you can handle the first Render event of the widget:
    var shouldLoadData = true;
    function onRender(e) {
        if (!shouldLoadData) {
        shouldLoadData = false;
        var spread = e.sender;
        var sheet = spread.activeSheet();
        var dataSource = new{
            transport: {
                read: '@(Url.Action("Products_Load", "Home"))'
            schema: {
                data: "Data",
                total: "Total"

    Attached you will find a small sample, implementing the above suggestion.

    Veselin Tsvetanov
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top