Telerik Forums
UI for ASP.NET MVC Forum
1 answer
6 views

I am trying to update my spreadsheet based on the jsonData i get from my controller.

Controller data:


public ActionResult GetDoubleCombinations(Telerik.Web.Spreadsheet.Workbook jsonData, int id)
{

    foreach (var sheet in jsonData.Sheets)
    {
        var columnCount = sheet.Columns.Count;
        var rowCount = sheet.Rows.Count;

        for (int i = 2; i < columnCount; i++)
        {
            var expressionTop = expressionService.GetExpressionByName(sheet.Rows[1].Cells[i].Value.ToString(), id);
            var parameterTop = expressionTop.FK_ParameterID;

            for (int j = 2; j < rowCount; j++)
            {
                var expressionLeft = expressionService.GetExpressionByName(sheet.Rows[j].Cells[1].Value.ToString(), id);
                var parameterLeft = expressionLeft.FK_ParameterID;

                if (parameterTop == parameterLeft)
                {
                    var position = sheet.Rows[i].Cells[j];
                    position.Enable = false;
                    position.Background = "#d3d3d3";
                }
            }

        }
        
    }
    return Json(new { success = true, data = jsonData });
}

this is what i get in my view:


function getDoubleCombinations() {

    var spreadsheet = $("#matrix").data("kendoSpreadsheet");
    const urlParams = new URLSearchParams(window.location.search);
    const id = urlParams.get('analysisId');

    $.ajax({
        url: "@Url.Action("GetDoubleCombinations", "Matrix")",
        data: JSON.stringify({
            jsonData: spreadsheet.toJSON(),
            id: id
        }),
        contentType: "application/json",
        type: "POST",
        success: function (response) {
            spreadsheet.fromJSON(response.data);
        },
        error: function () {
            alert("Error loading data.");
        }
    });
}

I use "spreadsheet.fromJSON" to update my spreadsheet.

My spreadsheet:


@model Telerik.Web.Spreadsheet.Workbook
@(Html.Kendo().Spreadsheet()
    .Name("matrix")
    .HtmlAttributes(new { style = "width:100%" })
    .BindTo(Model)
    .Toolbar(t =>
    {
        t.Home(h =>
        {
            h.Clear();
            h.ExportAs();
        });
        t.Data(false);
        t.Insert(false);
    })
)

My problem is, that the spreadsheet is not updated.

In the attachement i have a screenshot of my jsonData.

Alexander
Telerik team
 answered on 15 May 2024
1 answer
14 views

Hello, I am trying to make a function that can resize my spreadsheet sheet dynamically based on the data, which is load on the sheet.

I know that the Spreadsheet has a function called "resize". I pass the numbers of columns and rows with a ViewBag, from the controller to the View on JS.

Controller:

public ActionResult Menus_Read([DataSourceRequest] DataSourceRequest request)
{
    try
    {
        List<MenuViewModel> menus = db.GetMenus();
        DataSourceResult result = menus.ToDataSourceResult(request);
        ViewBag.RowCount = menus.Count;
        ViewBag.ColumnCount = typeof(MenuViewModel).GetProperties().Length;
        
        return Json(result, JsonRequestBehavior.AllowGet);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.ToString());

        ModelState.AddModelError(string.Empty, ex.Message);
        return Json(new[] { new object() }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet); ;
    }
}

 

JS:

    $(document).ready(function() {
        var rowCount = @(ViewBag.RowCount);
        var columnCount = @(ViewBag.ColumnCount);

        var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
        var sheet = spreadsheet.activeSheet();
        sheet.resize(rowCount, columnCount);
    });

To use the ViewBag content for the view I first need to get the data, to check the count of the columns and rows. Maybe this could be my problem, the timing.

Has anyone had a similar problem or can help me?

Mihaela
Telerik team
 answered on 01 Apr 2024
1 answer
68 views
could you please  answer the question from SO here https://stackoverflow.com/questions/76809963/check-kendo-spreadsheet-for-validation-errors

Using a (ASP.NET Core) Kendo spreadsheet, how to know if on the sheet are or not validation errors and what kind of if any.

I used this code to add validation

myCell.Validation(v => v
    .ComparerType("custom")
    .DataType("custom")
    .From("R[0]C[0] > 0")
    .Type("warning")
    .ShowButton(true)
    .AllowNulls(true)
    .TitleTemplate("Alerte de validation")
    .MessageTemplate("Attention, cette valeur est négative !"));
Alexander
Telerik team
 answered on 04 Aug 2023
2 answers
2.7K+ views

I used the upgrade wizard to download the latest version and I'm getting this error message on pages that have the components:

Could not load file or assembly 'Telerik.SvgIcons, Version=1.0.0.0, Culture=neutral, PublicKeyToken=20b4b0547069c4f8' or one of its dependencies. The system cannot find the file specified.

VISHAAL
Top achievements
Rank 1
Iron
 updated question on 16 Mar 2023
1 answer
51 views

 

I filled in the G2 unable to trigger formula. Who can tell me

Karina
Telerik team
 answered on 26 Oct 2022
1 answer
199 views

I am using @Html.Kendo().Spreadsheet() on a Razor page in a DotNet Core App. I want to Configure which options are available on the Toolbar and add a Custom one. I see from an older question from 2017, adding a Custom button was not supported back then. Has that changed?

 

Can someone point me to the appropriate documentation for that please.

 

 

Aleksandar
Telerik team
 answered on 12 May 2022
1 answer
72 views

I really have two questions: The first is as described above. I really have no need for the tool bar other than for entering cell comments, so I would like to know if there is a way to invoke that functionality with a double click. Also, I am replacing a Windows Desktop Application that does allow the users to double click to add comments so if I cannot do this in Kendo UI, it will be a behavior change for the users.

Secondly, can comment data be bound to the data source so that when I do a load or submit the database Comment field is updated along with all the other data?

Anton Mironov
Telerik team
 answered on 29 Apr 2022
5 answers
79 views
Good morning,

we would need to implement the following excel-like functions on a Telerik spreadsheet:
 - Average/Sum/Count of the selected cells. (sum-avarage-count.jpg)
 - copy-paste in the cells below with respect to a cell selected by double clicking in the lower-right corner. (copy-paste double click 1/2.jpg)

Are there any options in Telerik to replicate these features?

Kind regards,
Eyup
Telerik team
 answered on 03 Mar 2022
1 answer
74 views

I have a grid that contains a child detail spreadsheet.  I am trying to duplicate some code I used from another Kendo Spreadsheet, but each spreadsheet and Export button needs to have a unique id.  In the form I am using to export the Excel for the spreadsheet, I am using a Kendo Button to allow addition of the unique id (TplNum) from the parent grid.  For some reason, the template is not valid when I add the Kendo Button.  Any ideas?

I was going to use the Click event to determine the TplNum based on location of the button or the button id field in the Javascript callback, but thought that was giving me problems.  Currently, I gave the buttons a class, "export_excel" and I'm trying to create a jQuery onClick function in my document.load, which is invoked based on class, rather than id.

    $(document).ready(function () {
        $(".export_excel").click(function (e) {

        }

   }

<script id="campaign_template" type="text/kendo-tmpl">

        @using (Html.BeginForm("SpreadsheetDownload", "Campaign", FormMethod.Post, new { @class = "form-horizontal", role = "form", id = "spreadsheet_form_#=TplNum#" }))
        {
            @Html.Hidden("data", null, htmlAttributes: new { name= "data", id = "download-data_#=TplNum#" });
            @Html.Hidden("extension", null, htmlAttributes: new { name = "extension", id = "download-extension_#=TplNum#" });
            @(Html.Kendo().Button()
                    .Name("export_excel")
                    .HtmlAttributes(new { type = "button", id = "export_excel_#=TplNum#", @class = "export_excel" })
                    .Content("Export to Excel"));
                    //.Events(e => e.Click("ExportExcel")));
        }
Eyup
Telerik team
 answered on 28 Feb 2022
1 answer
113 views

Good morning,

in a Telerik spreadsheet, is there a property to set the number of maximum decimal places of the value of each single cell? what default value has this property set?
What scope does it have? Is it set for each single cell or on the entire spreadsheet?

For example we have a cell that has value with 11 decimal places, how can we modify it (increase or decrease it)?

Kind regards,

Eyup
Telerik team
 answered on 25 Feb 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?