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

$expand and adding new row

2 Answers 258 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 1
Christopher asked on 23 Jun 2017, 07:12 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 27 Jun 2017, 04:27 AM
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.
0
Christopher
Top achievements
Rank 1
answered on 27 Jun 2017, 10:28 AM

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

 

Tags
Grid
Asked by
Christopher
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Christopher
Top achievements
Rank 1
Share this question
or