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

Kendo grid Add New Record start date giving throwing an error called"Uncaught ReferenceError: StartDate is not defined".

1 Answer 670 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nageswara
Top achievements
Rank 1
Nageswara asked on 13 Dec 2017, 10:26 AM

Here i have grid with columns, when try to add a new record giving an error and following is the code.

$('#dcmMappingGrid').kendoGrid({
dataSource: response.DCMMappings,
schema: {
type: 'json',
parse: function (data) {
$.each(data.items, function (i, val) {
val.StartDate = toDate(val.StartDate);
val.EndDate = toDate(val.EndDate);
});
}
},

pageable: false,
height: 550,
toolbar: ['create'],
                
columns: [
{ field: 'DCMId', title: 'DCM Id', width: '120px', format: '{0: 0}' },
{ field: 'StartDate', title: 'Start Date', width: '120px', format: '{0: dd-MMM-yyyy}', template: '# if( false ) { #<span>#: kendo.toString(new Date(), "dd-MMM-yyyy")#<span># } else {#<span>#: kendo.toString(toDate(StartDate), "dd-MMM-yyyy")#<span>#} #', editor: startDateEditor },
{ field: 'EndDate', title: 'End Date', width: '120px', format: '{0: dd-MMM-yyyy}', template: '#= kendo.toString(toDate(EndDate), "dd-MMM-yyyy") #', editor: endDateEditor },
{ command: ['edit', 'destroy'], title: '&nbsp;', width: '250px' }],
editable: 'inline',
edit: function (e) {
//if (!e.model.isNew()) {

//}
},
detailTemplate: kendo.template($('#template').html()),
detailInit: detailInit
});

Please help to fix this.

advance thanks.

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 14 Dec 2017, 09:42 AM
Hello, Nageswara,

Thank you for the provided code.

After inspecting it, I can assume that the issue may occur because the values used in the column templates are null. In this scenario I can suggest setting default values inside the model as in our demo:

https://demos.telerik.com/kendo-ui/grid/editing-custom

schema: {
                          model: {
                            id: "ProductID",
                            fields: {
                               ProductID: { editable: false, nullable: true },
                               ProductName: { validation: { required: true } },
                               Category: { defaultValue: { CategoryID: 1, CategoryName: "Beverages"} },

If the issue still occurs, please share the error message with us and send a runnable example reproducing the issue, and I will gladly assist further.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Nageswara
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or