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
7 Answers, 1 is accepted
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:
I hope this is helpful.
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.
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
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:
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.
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
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;
"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."