$expand and adding new row

3 posts, 1 answers
  1. Christopher
    Christopher avatar
    16 posts
    Member since:
    Apr 2013

    Posted 23 Jun 2017 Link to this post

    Hi folks,

    i try to add a new row in my grid, but it raises an error. In my datasource i work with $expand and have something like this:

    Firstname, Lastname, AttributeID, Attribute (Name,Description, Value)

    In my grid the columns show Firstname, Lastname, Attribute.Name, Attribute.Description, Attribute.Value

     

    If i try to add a new row, the error is "can't read property 'Name' of null" and that is because of the expanding items.

    $kendoHtmlEncode(data.Attribute.Name==null?'':data.Attribute.Name)

     

    Do you have an example how to work with adding new rows with expanding items? Or what am I doing wrong?

     

    Thanks and regards,

    Chris

     

    Uncaught TypeError: Cannot read property 'Name' of null
        at eval (eval at compile (kendo.all.js:194), <anonymous>:3:898)
        at init._rowsHtml (kendo.all.js:52270)
        at init._renderContent (kendo.all.js:52843)
        at init.refresh (kendo.all.js:52706)
        at init.proxy (jquery-1.12.4.js:529)
        at init.trigger (kendo.all.js:124)
        at init._process (kendo.all.js:6965)
        at init._change (kendo.all.js:6925)
        at init.proxy (jquery-1.12.4.js:529)
        at init.trigger (kendo.all.js:124)
  2. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 26 Jun 2017 Link to this post

    Hello Christopher,

    When you work with complex objects you need to ensure that you are setting a default value for that object, because the dataSource will not be able to create that complex object on its own. You could refer to the Category field configuration in the dataSource in the following online demo:
    Hope this helps.


    Regards,
    Konstantin Dikov
    Progress Telerik
    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. Christopher
    Christopher avatar
    16 posts
    Member since:
    Apr 2013

    Posted 27 Jun 2017 in reply to Konstantin Dikov Link to this post

    Hello Konstantin,

    that works indeed much better than before. Another mistake I made was to name the columns e.g. Category.Name instead of Category and working afterwards with the template. 

    Thank you very much! :-) 

    Regards,
    Chris

     

Back to Top