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

Kendo Grid inline dropdownlist shows ValueField After Edit instead of TextField

7 Answers 358 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chinonso
Top achievements
Rank 1
Chinonso asked on 21 Aug 2017, 01:32 PM

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

Sort by
0
Stefan
Telerik team
answered on 23 Aug 2017, 06:14 AM
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.
0
Chinonso
Top achievements
Rank 1
answered on 23 Aug 2017, 04:53 PM

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.

 

0
Chinonso
Top achievements
Rank 1
answered on 23 Aug 2017, 06:13 PM

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

 

0
Stefan
Telerik team
answered on 25 Aug 2017, 11:42 AM
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.
0
Chinonso
Top achievements
Rank 1
answered on 25 Aug 2017, 02:10 PM

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

 

0
Stefan
Telerik team
answered on 29 Aug 2017, 05:56 AM
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.
0
Chinonso
Top achievements
Rank 1
answered on 30 Aug 2017, 09:35 PM

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. 

Tags
Grid
Asked by
Chinonso
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Chinonso
Top achievements
Rank 1
Share this question
or