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

ComboBoxFor in a modal window

2 Answers 135 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jacob
Top achievements
Rank 1
Jacob asked on 22 Nov 2019, 07:33 PM

I am trying to get a ComboBoxFor to work inside a Kendo Modal Window. Thing is, the value type is always null.  THis is what I am doing in side a modal window:

 
 
<div class="demo-section k-content">
    <h4>Find a product</h4>
 
    @(Html.Kendo().ComboBox()
          .Name("products")
          .Placeholder("Select product")
          .DataTextField("ProductName")
          .DataValueField("ProductID")
          .HtmlAttributes(new { style = "width:100%;" })
          .Filter("contains")
          .AutoBind(false)
          .MinLength(3)
          .DataSource(source => {
              source.Read(read =>
              {
                  read.Action("ServerFiltering_GetProducts", "ComboBox").Data("onAdditionalData");
              })
              .ServerFiltering(true);
          })
    )
    <div class="demo-hint">Hint: type at least three characters. For example "che".</div>
</div>
 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Jacob
Top achievements
Rank 1
answered on 22 Nov 2019, 07:34 PM

Then in the calling *cshtml page, I have this method:

When I type 3 chars in the combobox this method gets hit, but the value is always null. Any ideas? Thanks

<script type="text/javascript">
   function onAdditionalData() {
       return {
              value: $("#products").val());
      };
  }
</script>
0
Petar
Telerik team
answered on 26 Nov 2019, 04:01 PM

Hi Jacob,

Can you specify if you want to use ComboBox or ComboBoxFor? The provided code is for implementing a ComboBox. 

Regarding the "null" value can you specify if you are talking for the returned by $("#products").val() value or the value of the "value" variable that is passed to the controller? 

Can you share the code of the ServerFiltering_GetProducts controller? Is the "value" variable defined in the controller? 

Can you share a project/code of your definition of the Modal and the ComboBox inside it?

Regards,


Petar
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.
Tags
ComboBox
Asked by
Jacob
Top achievements
Rank 1
Answers by
Jacob
Top achievements
Rank 1
Petar
Telerik team
Share this question
or