SpreadsheetSheetRowCell() shows [object Object]

3 posts, 0 answers
  1. Stephan
    Stephan avatar
    2 posts
    Member since:
    Jul 2013

    Posted 12 Apr Link to this post

    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. Nencho
    Admin
    Nencho avatar
    1671 posts

    Posted 13 Apr Link to this post

    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.
  3. Stephan
    Stephan avatar
    2 posts
    Member since:
    Jul 2013

    Posted 18 Apr Link to this post

    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

     

Back to Top