This is a migrated thread and some comments may be shown as answers.

'TypeError: this is undefined' error while calling the controller through ajax

1 Answer 106 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Hudson
Top achievements
Rank 1
Hudson asked on 13 Apr 2016, 04:37 PM

Hi,

I am uploading an excel file that has some formulas in them to the kendo spreadsheet. The sheet seems to be loading in the Spreadsheet fine, but when I try to send the retrieved values from the kendo spreadsheet, there seems to be an exception - 'TypeError: this is undefined'

function fetchDataForKidsGridModel(ExcelVals) {
    debugger;
    var cellValues, range, ArrOfCellValue = [], CellValueArr,
    startPoint = 17,
    mandotoryColumn = "E";
 
    var outletArr = [];
 
    var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
    var sheet = spreadsheet.activeSheet();
    var endPoint = getSheetLength(sheet, startPoint, mandotoryColumn
    for (var l = 0; l < endPoint ; l++) {
 
        var StartColumn_CI = 85;
        CellValueArr = [];
        var arrOfOutlets = [];
        for (var i = 0; i < ExcelVals.length ; i++) {
 
            var rowCellNo = ExcelVals[i].ColumnVal.replace("#", startPoint).trim();
            range = sheet.range(rowCellNo)
            cellValues = range.values();
            if (cellValues[0][0] == null) {
                cellValues[0][0] = "";
            }
            CellValueArr[i] = cellValues;
        }
        ArrOfCellValue[l] = CellValueArr;
 
        startPoint++;
    }
    //ERROR is thrown at this point while debugging
    $.ajax({
        url: '/UploadPO/CreateModelForGridEcomm',
        type: 'POST',
        async: true,
        dataType: 'json',
 
        data: { cellValues: ArrOfCellValue, BrandID: brandName }, //
 
        success:
            function (result) {
                console.log(result);
                // you code comes here
                GetGrid(result)
            },
        error:
    function (result) {
        //Error Handling
        if (result.success = true) {
            alert(result.responseText);
        }
        if (result.success = false) {
            alert(result.responseText);
        }
    }
    });
}

Any help would be much appreciated.

Feel free to ask any questions to further clarify my question..

Thanks in advance...

1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 15 Apr 2016, 07:25 AM

Hello Hudson,

The error appears to be unrelated to the spreadsheet component, but caused by the serialization of the data that you are posting. The line "cellValues[0][57][0][0][toString]" hints at that. Please verify the problematic entry in ArrOfCellValue.

Regards,
Alex Gyoshev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Spreadsheet
Asked by
Hudson
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or