GridForeignKey ComboBox Initial Value is 0 ?

4 posts, 0 answers
  1. Michael
    Michael avatar
    38 posts
    Member since:
    Mar 2009

    Posted 14 Feb 2013 Link to this post

    Subject says it all. In my GridForeignKey.cshtml I've placed a combo box rather than the dropdownlist. For editing values in my grid it works fantastically. When adding a new row inline however, the default value displayed is 0. This is a non-nullable field with no default. How can I get my own "Select..." text in there initially or nothing at all?

    Thank you!
    Michael
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 18 Feb 2013 Link to this post

    Hello Michael,

    Basically the easiest way to achieve this will be to use the edit event of the Grid.

    I tried other approaches however since most probably the column field is of type int (or nullable int) you wont be able to set the default value to be empty string - which is actually the value of the combo when there is "option label". Also if you want this field to be required you will once again need to make the default value empty string.

    For simplicity I created a sample project which you can try. 


    Kind regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Robert
    Robert avatar
    6 posts
    Member since:
    Jan 2013

    Posted 27 Mar 2013 Link to this post

    Hey Peter,
    If I wanted to use a combobox with an Ajax datasource instead of the SelectList for the Foreign key column, what would the razor markup look like for the columns configuration?

    Thanks,
    Rob
  5. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 29 Mar 2013 Link to this post

    Hello Michael,

    I am afraid this is not possible. 
    Basically here is the scenario:
    ForeignKey column is nothing more than a template column and the template should have the Key/Value pairs to display the text for a given id. However the ComboBox is loaded when the column is being edit - so you cannot use the data it loads in the client template.


    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready