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

Replicating functionality moving from MVC Extensions to Kendo MVC

5 Answers 298 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 1
Danny asked on 04 Jul 2012, 09:28 AM
We are currently having problems achieving the same functionality we have in MVC Extensions.

1. In MVC Extensions we have a modified combobox helper below which allows us to set the initial value & text in a 'load on demand' combobox.  As part of the helper we also modify the name to change "-input" to "_input" so both the posted value and text can be bound to properties in our view model (ie int abc and string abc_input).  

Can you advise how to best achieve this using Kendo MVC combobox as we have been unable to convert the logic below.

            return helper.Telerik().ComboBox()
                         .Name(name)
                         .InputHtmlAttributes(new
                         {
                             id = name + "_input",
                             name = name + "_input",
                             value = text
                         })
                         .Value(value != null ? value.ToString() : string.Empty);

2. Perhaps related to my issue above but when I select an item from a kendo combobox and post the the results the combobox selection is not maintained when the view is redrawn... in fact the firebug shows only the combobox selected data value is posted

    @using (Ajax.BeginForm("Index", "Home", new AjaxOptions { HttpMethod = "POST" }))
    {
        @(Html.Kendo().ComboBox()
                .Name("TestComboID")
                .AutoBind(false)
                .DataTextField("Text")
                .DataValueField("ID")
                .Filter("contains")
                .DataSource(source =>
                {
                    source.Read(read =>
                    {
                        read. Action("GetProducts", "Home")
                    })
                    .ServerFiltering(true);
                })
        )
   
3. Server Filter

Currently to implement combobox server filtering in MVC extension is quick and easy.  The way it has been implemented in Kendo MVC examples requiring .Data to be manually set in the DataSource is clumsy and inefficient given the amount of code required.. If you only have a few combobox's it wouldn't be an issue but we have over 100... Is there any way to improve this so the value is automatically passed when server filtering is on?

Thanks in advance,
Danny

5 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 06 Jul 2012, 12:34 PM
Hello Danny,

 
Straight upto your questions:

#1:
For the Q2 release of KendoUI ( scheduled for the next week) we will provide a Text() method which will give you the ability to set the text of the visible input easily:

return helper.Kendo().ComboBox()
         .Name(name)
         .Text(text) //will be available in Q2 2012 release of KendoUI
         .Value(value != null ? value.ToString() : string.Empty)

Currently in the available beta the visible input does not have name attr and that is why it does not post its value. We will change this for the Q2 release. The name will be ComboBox's name plus "_input". Hence you will not need to override html attributes as you do in your extension method.

#2:
As you already noticed, the value of the visible input is not sent to the server. We will change this as I pointed in the point 1.

#3:
After further investigation, we decided that we can improve current approach.  If the server filtering is enabled and Data handler is not defined, we will render one by default. Thus the combobox will sent automatically the text of the visible input. By default it will be text as in the Telerik Extensions for ASP.NET MVC.

Let me know if other questions arise.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Danny
Top achievements
Rank 1
answered on 06 Jul 2012, 01:25 PM
Hi Georgi,

Thanks alot, the changes you have described as coming make moving to Kendo MVC very encouraging.

Based on these changes, one final related combobox functionality that I would like to confirm will be in Kendo that was implemented in MVC extensions is the initial filtering text sent when the combobox is preset with a selected ID & Text...

Currently in MVC Extensions if I load a view and preset a combobox ID & Text and then dropdown the combobox list the server filter text is sent as empty rather than the defaulted text... Obviously without this functionality changing the selection is difficult for the user... if the original text is sent the system would generally just return the same item so the user would need to clear the current selection if they wanted to check what other items are in the list.

Thanks,
Danny
0
Georgi Krustev
Telerik team
answered on 09 Jul 2012, 08:05 AM
Hi Danny,

 
The default Data handler, whcih we will provide for the official release, will handle this functionality. If the dataSource of the widget does not have filters, then we will send empty string as filter text. In other words the required functionality will be implemented in KendoUI for ASP.NET MVC.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Danny
Top achievements
Rank 1
answered on 09 Jul 2012, 08:32 AM
Thanks Georgi...

Just want to clarify when you say  "If the dataSource of the widget does not have filters, then we will send empty string as filter " that any initial Text set on the combo is not considered to be a filter

Looking forward to the release
Danny
0
Georgi Krustev
Telerik team
answered on 09 Jul 2012, 09:15 AM
Hello Danny,

 
The value set with Text() method is not considered as filter. For more information about the filters check this link.

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ComboBox
Asked by
Danny
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Danny
Top achievements
Rank 1
Share this question
or