Unplanned
Last Updated: 20 May 2019 14:34 by ADMIN
Graeme
Created on: 19 May 2019 23:08
Category: DropDownList
Type: Feature Request
1
DropDownList to submit object

Hi there

I am using MongoDb database and storing much of the data as complex objects.

Like this

Company

string     Name

string     Phone

object[]    Addresses

                   object Id

                   string name

                   string line2

                   string town

So the addresses are not stored in normalised tables such as you would have in a typical sql setup

Also I am using Razor pages and not using view models but binding to page model properties

mostly matching the database document. 

One thing I am wanting to do is make the best of such a plan as it saves a lot of coding time.

If I have a telerik control such as a dropdownlist you would typically return an Id and keep the Id

in the database table.  However in the new style of document database it is common to store

the entire object and not just the Id so the problem is if the control returns only the Id then

the developer has to obtain the rest of the object to store away adding the the complexity of the code.

Telerik allows very easy binding of an object to a control and the whole object remains available to use

such as in a dropdownlist to show a name and return say the Id.

An improvement for those using Document style databases with denormalised data would be the option

to simply return the whole object.

@(Html.Kendo().DropDownList()
                .Name("ToBranch") 
                .DataValueField("Id") 
                .DataTextField("Name") 
                .BindTo((Company.Addreses) 
)

So in addition to DataValueField have something like DataReturnObject(true) or something like that

which would send back all the data for the item which you already have sitting right there.

This would very nicely serialise into the pagemodel complex object property and allow proper model validation

which is a problem when you return an Id but the property expects the full object.

I understand all this can be overcome but just a little tweaking by Telerik would be a significant benefit

where your customers are using document style databases such as MongoDb and Azure Cosmos

 

So..

1 That is my suggestion.

2 Can I currently achieve this somehow?

 

              

        

1 comment
ADMIN
Veselin Tsvetanov
Posted on: 20 May 2019 14:34
Hello Graeme,

Thank you for the detailed explanation of the case and for the nice suggestion. As far as I can understand, you are looking for a solution that would submit a <form> with the entire object, which is currently selected in the DropDownList. If that is the case, I am afraid that with the current implementation (and structure) of the widget, it is not possible. The reason behind that is the fact that the DropDownList has a single <input> (or <select>) element, which value will be submitted to the server. It does not expose additional fields that could accommodate the other field values of the selected item.

Having that said, I have converted the current thread to a feature request. I also made it visible for other developers in our Feedback portal. I would suggest you to cast your vote for it. Depending on the support it receives from the community, we will decide on whether to proceed with its implementation or not.

If I went the wrong way and did not get properly the scenario in question, please let me know.

Regards,
Veselin Tsvetanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.