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

Add new record give error

1 Answer 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saima
Top achievements
Rank 1
Saima asked on 07 May 2014, 12:00 PM
i have drop down list in grid popup editor. It works ok for update. But when i click on Add new record it gives me error "TypeError:language is null. Error is returned due to template applied in Grid Columns to show value in grid. I want to use condition some thing like tha
columns: [
                   { field: "contactId",title: "ContactId", hidden: true },
                   { field: "businessName", title: "Business Name", width: 200 },
                   { field: "firstName", title: "Contact Title", width: 200 },
                   { field: "lastName", title: "Last Name", hidden: true },
                   { field: "language", title: "Language", width: 100, editor: langDropDownEditor,template: "#if(language!=null){=language.value}#"},
                   { field: "country", title: "Country", width: "100px", editor: countryDropDownEditor },
                   { field: "address", title: "Address", hidden: true },
                   { field: "city", title: "City", width: 100 },
                   { field: "gsm", title:"GSM",hidden: true },
                   { field: "email",title:"Email", hidden: true },
                   { field: "isActive",title:"Active", hidden: true },
                   { command: ["edit", "destroy"], title: " ", width: "160px" },
               ],
t
But it gives me error.
Please help me to solve this issue

1 Answer, 1 is accepted

Sort by
0
Saima
Top achievements
Rank 1
answered on 08 May 2014, 06:37 AM
After long time searching  i found soln from Stack Overflow because not mentioned in Demo or example. Actually problem was in defining Model. Model field for Dropdownlist should be defined as follows

schema: {
                        model: {
                            id: "contactId",
                            fields: {
                                contactId: { editable: false },
                                businessName: { validation: { required: true} },
                                firstName: { validation: { required: true} },
                                lastName: { validation: { required: true} },
                                country: {defaultValue: { text: "", value: ""} },
                                address: { nullable: true },
                                city: { nullable: true },
                                gsm: { nullable: true },
                                email: { nullable: true },
                                isActive:{type: "boolean",defaultValue: true},
                                language:{defaultValue: { text: "English", value: "English"}}
                            }
                        }//end of model
                   },//end of schema

Here language and country fields are used for DropDownList

Grid columns for language and country are defined as follows
{ field: "language", title: "Language", width: 100, editor: langDropDownEditor,template: "#=language.value#"},
                    { field: "country", title: "Country", width: "100px", editor: countryDropDownEditor,template: "#=country.value#" },

Tags
Grid
Asked by
Saima
Top achievements
Rank 1
Answers by
Saima
Top achievements
Rank 1
Share this question
or