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

Inline Edit shows "[Object]"

1 Answer 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 07 Aug 2014, 07:09 PM
Hi Guys! 

First of all, sorry for my English.

I have a little problem with the inline edit feature.

In my dataSource I have these columns:

            columns =
            [
                    { id: 1, field: 'name', title: 'Name'                    },
                    { id: 2, field: 'extra_info', title: 'Extra Info'              },
                    { id: 3, field: 'localnames[0]', title: 'Localname 1', template: "#=name#" },
                    { id: 4, field: "localnames[1]", title: 'Localname 2', template: "#=name#"  },
                    { command: [{ name: "edit", text: "Edit" },{ name: "destroy", text: "Remove" }] }
            ];

In my list, i have an array "localnames", and when I was rendering the grid, in the column "Localname 1" and "Localname 2" the text was showing [Object]. To solve this I used "template: "#=name#"" to render the name of the object localname[0].

But now, while I'm using the inline-edit, when I click on the edit button, the grid show me [Object] to edit. How can I solve this?
Anyone had this problem before?

Thanks for your help and sorry for my English.






1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 11 Aug 2014, 12:00 PM
Hello David,

This happens because the column's field option points to an object. Specifying the exact property of the objects should resolve the issue. For example: 
{ id: 3, field: 'localnames[0].name', title: 'Localname 1'},

I would also recommend specifying a default value for the localnames field, otherwise new items will produce errors. For example: 
schema: {
  model: {
    fields: {
      localnames: {defaultValue: [{name: ""}, {name: ""}]}
    }
  }
},

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or