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

SpreadsheetSheetRowCell() shows [object Object]

2 Answers 33 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Stephan
Top achievements
Rank 1
Stephan asked on 12 Apr 2017, 07:04 AM

Hy,
I created a Spreadsheet. But I want to add a class to the SpreadsheetSheetRowCell Value attribute. The cell only shows me [object Object] in the view. I tried to override the toString method but with no effect.

As an example if my class looks like:
public class User
{
    public int ID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

How can I display the first and the last name?
Thx for Help!

2 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 13 Apr 2017, 12:33 PM
Hello Stephan,

Could you please elaborate a bit more on your scenario? How do you bind the Spreadsheet? In addition, it would be best, if you could submit a support ticket, along with a runnable sample attached, containing your current implementation, so we could locally revise it and evaluate the scenario that you aim to achieve.

Regards,
Nencho
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Stephan
Top achievements
Rank 1
answered on 18 Apr 2017, 05:50 AM

Hi Nencho

As you mentioned I have submitted a ticket. Here the information for anybody else who might need it and to close the post:

EXPLANATION/EXAMPLE:

We are trying to pass a object/class into the value of a SpreadsheetSheetRowCell.
Example:
TEST-Class:

public class JASTViewModel
{
    public int EmployeeID { get; set; }
    public string FirstName { get; set; }
}



Controller:

var test = new JASTViewModel() {EmployeeID = 1, FirstName = "JAST"};
 
var row1Cell8 = new SpreadsheetSheetRowCell()
{
    Value = test,
    Bold = false,
    Background = "rgb(191,191,191)",
    Color = "rgb(255,255,255)",
    TextAlign = SpreadsheetTextAlign.Center
};



This works fine and the object is also passed into the value object but in view it displays [object Object].
How do we define what is displayed in the cell in the view?
In the above example we would like to have EmployeeID and FirstName in the SpreadsheetSheetRowCell-value object and display FirstName (JAST) in the cell.

ANSWER:

I am afraid that the Spreadsheet could not be configured to display a custom object in a cell. The reason for that is the fact, that the Spreadsheet displays only a limited number of formats (types) as values of its cells. As default formatting for a cell is text (string), all the other types (those that are not predefined) will be displayed with the result from their JavaScript toString() method. In the most common case this value is "[object Object]".

 

ANSWER AFTER ASKING IF IT WILL BE IMPLEMENTED:

I am afraid that such feature is not under consideration currently. This is why, my suggestion would be to log this as a feature request in our public portal below, so it would be opened for voting and eventually and escalated for implementation:
http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback

Thank you for your support.

Stephan

 

Tags
Spreadsheet
Asked by
Stephan
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Stephan
Top achievements
Rank 1
Share this question
or