Custom Editor (Dropdown) not sending default values on CRUD add

2 posts, 0 answers
  1. Paul Sheridan
    Paul Sheridan avatar
    6 posts
    Member since:
    Dec 2009

    Posted 14 Aug 2012 Link to this post

    I've run into a problem insofar as I've managed to get a complex foreign key editor to work with basic CRUD on the grid. However, upon adding new rows, if the drop downs are left unchanged from their initial state, no data is sent to the server for the add, showing 'undefined' in the colums and sending nulls to the add method.

    I'm sure this is something to do with the defaultValue option on the model but can't find any reference on the forums

    any help appreciated.

    VS2012 project attached.
  2. Todd
    Todd avatar
    26 posts
    Member since:
    Sep 2012

    Posted 30 Oct 2012 Link to this post

    I had the same problem, and I can tell you It definitely has to do with setting defaultValue on the model field.  Also, you need to have that field defined as "number" if your values are integers.  When you set defaultValue, you can set it to either an integer or to a nested property if your model field is a "complex field" (.Net class or enum).  If it's a class or enum, you can do this: defaultValue: { MyField.MyValue }  (not sure if you need the extra curly braces)  ....and if it's a regular integer, you can do something like: defaultValue: 21

    Without setting defaultValue, then new records will be sent to the server with null/zero values for these fields.

    Telerik's own demo called "ForeignKey" grid demo is missing this defaultValue, so when you try to add a new row, you can not select the first drop-down value.  Shame, because this demo shows the best way to implement drop-downs in a grid cell.  I first used custom cell drop-down editors, but this is what I use now because it builds the drop-down for you.
  3. Kendo UI is VS 2017 Ready
Back to Top