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

Column template breaks Add new record function

1 Answer 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vladimir
Top achievements
Rank 1
Vladimir asked on 03 Oct 2013, 08:51 AM
Hi Greg,

I would suggest to add "min" validation rule or define a custom one - for more information you can check this article.

Also about the template error - in current case I would suggest to add additional logic to the template where if the "vendorID" is null to return empty template. Additionally you can define "default" value for current field in the dataSource schema definition. 

1 Answer, 1 is accepted

Sort by
0
Greg
Top achievements
Rank 1
answered on 03 Oct 2013, 01:38 PM
Thanks Vladimir. You identified the core problem; that invalid vendorId values were causing the template to fail and halt javascript processing.

Using this template:

        { field: "vendorId", title: "Vendor ID", editor: vendorDropDownEditor, template: function (dataItem) { return getVendorName(dataItem.vendorId); } },


And this updated function:

  function getVendorName(id) {
    var vendorLookup = vendorLookupDataSource.get(id);
    
    if (vendorLookup == null)
      return "";
    else
      return vendorLookup.value;
  }

Resolves the issue I posted about.
Tags
Grid
Asked by
Vladimir
Top achievements
Rank 1
Answers by
Greg
Top achievements
Rank 1
Share this question
or