Telerik Forums
UI for ASP.NET MVC Forum
0 answers
2 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?

Herr Walter Gartmann
Top achievements
Rank 1
 asked on 27 Mar 2024
1 answer
53 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
0 answers
55 views

 

The following is traversal binding. The onDataBound method allows you to bind cells individually, similar to my following writing method of $("# spreadsheet"). data ("kendoPrepadsheet"). activeSheet(). range ("K3"). format ("yyyy MM dd");

 

zhe
Top achievements
Rank 1
Iron
Iron
 asked on 23 Mar 2023
2 answers
2.4K+ 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
0 answers
65 views
0

I use Kendo Spreadsheet widget with local data binding in MVC. How can I set the datasource to the spreadsheet to do create, update and delete operation?

I know this example,

https://demos.telerik.com/aspnet-mvc/spreadsheet/datasource

but ajax remote binding is not fine for me, because the excel file has a realy complex header with many merged cells. And remote data fills the first row which overwrite header files. So I use this example:

https://www.telerik.com/forums/loading-data-into-a-specific-row-in-kendo-spreadsheet

After using it data liested in the proper rows, but it's very slow.

So please give me some information to resolve this issue. A have to save modifications of the spreadsheet.

Here I list a simple example of how I bind the data:

ViewModel:

public int ID { get; set; }
    public int Name { get; set; }
    public string Status { get; set; }
}

Action in controller:

public ActionResult Index()
{
    List<ViewModel> model = service.GetData();
    return View(model);
}

View cshtml:

@model List<Namespace.Model.ViewModel>

@section body {

    @(Html.Kendo().Spreadsheet()
        .Columns(3)
        .Name("DataExcel")
        .HtmlAttributes(new { style = "width:auto; height: 770px;" })
        .Toolbar(false)
        .Sheetsbar(false)
        .Events(e => e
            .Select("Scripts.onSelect"))
        .Sheets(sheets =>
        {
            sheets.Add()
            .Name("DataSheet")
            .Columns(columns =>
            {
                // Megbízott neve és státusza + Tantárgy neve
                columns.Add().Width(50);
                columns.Add().Width(100);
                columns.Add().Width(100);
            }).Rows(rows =>
            {
                foreach (var dataRow in Model)
                {
                    rows.Add().Height(50).Cells(cells =>
                    {
                        // Megbízott státusza
                        cells.Add()
                            .Value(dataRow.ID)
                            .VerticalAlign(SpreadsheetVerticalAlign.Center)
                            .Color("black");

                        // Tantárgy neve
                        cells.Add()
                            .Value(dataRow.Name)
                            .VerticalAlign(SpreadsheetVerticalAlign.Center)
                            .Color("black");

                        // Órakeret
                        cells.Add()
                            .Value(dataRow.Status)
                            .VerticalAlign(SpreadsheetVerticalAlign.Center)
                            .Color("black")
                            .Bold(true);
                    }
                }
            });
        })
    )
}
Norbert
Top achievements
Rank 1
 asked on 02 Mar 2023
0 answers
85 views

Note that this is Workbook.sheets and not Spreadsheet, but I couldn't select a more relevant tag nor create my own.

I am having an issue merging cells that are in an existing sheet in a workbook. My attempt to use mergedCells after the sheet has been created has a roadblock, I can't seem to get the range name in string format as documented for the mergedCells option in Workbook.sheet:

mergedCells: ["A6:A8"]

I have the logic to determine which cells' indexes I want to merge, but only the indexes. I can't figure out a way to get the range in an Excel cell name. In the following example, ignoring how I got the index values, I can't merge the cells based on index where indexA is the column and indexB1 and indexB2 are rows.

let indexA = 0;

let indexB1 = 5;

let indexB2 = 7;

sheet.mergedCells = [[{indexA, indexB1},{indexA,indexB2}]]

I have attached a picture of the types of cells I want to merge, my loop first hits A6 through A8 and determines the indexes are to be merged because all the cells' values equal "Boat". Any help is appreciated, and I will try to provide more detail if needed, but it is difficult to provide much more because of the nature of the system I am on.

Thanks in advance.

Alden
Top achievements
Rank 1
 asked on 06 Feb 2023
1 answer
47 views

 

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

Karina
Telerik team
 answered on 26 Oct 2022
0 answers
51 views

I replaced these JS references. If I use the 2022 version, if the submission fails, the page will always be loaded and can't be clicked. If I use the 2021.1.224 JS page, it won't always be loaded and can be used normally!

zhe
Top achievements
Rank 1
Iron
Iron
 asked on 08 Sep 2022
0 answers
64 views

When spreadsheet click Submit, the value of my cell is copied and pasted in. I can't get the value of data.updated in the background! How to solve this problem

zhe
Top achievements
Rank 1
Iron
Iron
 asked on 30 Aug 2022
0 answers
51 views

Can I translate the header generated in the first line into Chinese. Translation, urgentspreadsheet

zhe
Top achievements
Rank 1
Iron
Iron
 asked on 23 Aug 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?