Telerik Forums
UI for ASP.NET MVC Forum
0 answers
28 views
Hi Team,
I am using the Spreadsheet module for ASP.NET Core.
Currently, we can add a dropdown to a specific spreadsheet cell using (https://demos.telerik.com/aspnet-core/spreadsheet/custom-editors).
However, I would like to add a dropdown to an entire column without having to manually add it to each row or cell through code.
Could you please check if this is possible?
Rakesh
Top achievements
Rank 1
 asked on 07 May 2025
1 answer
130 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
81 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
254 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
114 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
4.1K+ 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
163 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
185 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
99 views

 

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

Karina
Telerik team
 answered on 26 Oct 2022
0 answers
117 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
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
DateTimePicker
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?