Kendo Grid inline dropdownlist shows ValueField After Edit instead of TextField

8 posts, 0 answers
  1. Chinonso
    Chinonso avatar
    18 posts
    Member since:
    Jan 2017

    Posted 21 Aug Link to this post

    I have a Kendo Grid with drop-down lists for in-line update.When i am in edit mode, the drop-down list text fields are displayed. But after i save, the value of the selected items are displayed in the grid instead of the text fields. I am using EditorTemplateName for displaying the drop-down lists in the grid.Can you please help me find what is wrong and help me correct this issue.

    I have uploaded a copy of the code and 2 images. Thanks for the help

  2. Stefan
    Admin
    Stefan avatar
    1028 posts

    Posted 23 Aug Link to this post

    Hello Chinonso,

    Thank you for the provided information and the example.

    The issue occurs because the column is bound to the Id field in the model.

    When a DropDownList is used as an editor, the column should be bound to the complex object that holds the custom or the vendor value. Then a ClientTemplate has to be used in order to display the desired values, in this case, VendorName and CustomerName.

    I noticed that the Grid read action is returning only the ID values instead of complex objects:



    I can suggest checking our runnable example with a DropDownList, as it is demonstrating how the column should be bound and in the network tab the expected response can be observed:

    http://demos.telerik.com/aspnet-mvc/grid/editing-custom

    http://docs.telerik.com/aspnet-mvc/helpers/grid/templating/editor-templates

    I hope this is helpful.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Chinonso
    Chinonso avatar
    18 posts
    Member since:
    Jan 2017

    Posted 23 Aug in reply to Stefan Link to this post

    Hey Stefan i  re-factored the code, but i can't seem to solve this problem

    When i click on the vendor list to select an option, the refresh icon spins endlessly. I think this could be due to the fact the the editor templates are not  using @model int but rather @model customer, @ model vendor etc.  If i change the editor templates to use @model int, i get the error below  

    Error:"The model item passed into the dictionary is null, but this dictionary requires a non-null model item of type 'System.Int32'."

    How do i fix the issue with the vendor list drop-down, i have attached a new version of  the project and an image? thank you.

     

  4. Chinonso
    Chinonso avatar
    18 posts
    Member since:
    Jan 2017

    Posted 23 Aug in reply to Stefan Link to this post

    Hello again Stefan, please ignore my previous reply i fixed that issues. But now, i appear to have a more serious issues. After i am done selecting the values i want from the drop-down lists, when i click update,  nothing show in fields. So i added //.ClientTemplate("#=Customer.CustomerName#") to the column thinking it would display the name. Sadly, it did not and whats worse, when i click the add button, the grid doesn't respond. How can this be remedied?.  

    Here is the updated code and images. 

    Thanks for the help

     

  5. Stefan
    Admin
    Stefan avatar
    1028 posts

    Posted 25 Aug Link to this post

    Hello Chinonso,

    In this scenario, the Grid freezes, because the new item does not has a default value and this is required when creating a new item.

    Please check our example demonstrating how to add a default value:

    http://demos.telerik.com/aspnet-mvc/grid/editing-custom

    model.Field(p => p.Category).DefaultValue(
                   ViewData["defaultCategory"] as Kendo.Mvc.Examples.Models.CategoryViewModel);

    Also, please ensure that the correct data is received from the Controller as in my test the data was received as null even after I added a new item.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Chinonso
    Chinonso avatar
    18 posts
    Member since:
    Jan 2017

    Posted 25 Aug in reply to Stefan Link to this post

    Hello Stefan, thanks for all your help. All but one of my problem is solved. For some reason, on create,update, the grid keeps posting back the default values that i set in the viewdata regardles of what i select from the drop-downs. Is there a way i can tell the grid to not post back the default data. ? 

    I have uploaded a copy of the updated code and 2 images. Thanks for the help

     

  7. Stefan
    Admin
    Stefan avatar
    1028 posts

    Posted 29 Aug Link to this post

    Hello Chinonso,

    I'm glad to hear that the example is almost ready.

    In this case, the issue occurs because the editor names are not matching the property name which is edited. This is creating a scenario, where the actual values have different names and are not sent to the controller inside the License model;

    http://docs.telerik.com/aspnet-mvc/helpers/grid/templating/editor-templates

    "3. Add a Kendo UI DropDownList to that partial view. Set the Name of the DropDownList to the name of the property which will be edited—"Employee" in this case."

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  8. Chinonso
    Chinonso avatar
    18 posts
    Member since:
    Jan 2017

    Posted 30 Aug in reply to Stefan Link to this post

    Hey Stefan,

    Thanks a lot for your help, i now have it working.

    I have uploaded a copy of the updated code for anyone who needs it later. 

Back to Top