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

Combobox(cascading) not calling Method on Controller

4 Answers 28 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Agropur
Top achievements
Rank 1
Agropur asked on 25 Nov 2013, 05:52 PM
Here is my View:
<div class="form-group">
            @Html.LabelFor(model => model.locationCode, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownListFor(model => model.locationCode, new SelectList(Model.Locations))
                @Html.ValidationMessageFor(model => model.locationCode)
            </div>
        </div>
 
        <div class="form-group">
            @Html.LabelFor(model => model.loadType, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownListFor(model => model.loadType, new SelectList(Model.LoadTypes))
                @Html.ValidationMessageFor(model => model.loadType)
            </div>
        </div>
 
        <div class="form-group">
            @Html.LabelFor(model => model.loadDescrip, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @(Html.Kendo().ComboBox()
                        .Name("loadDescription")
                        .Filter(FilterType.Contains)
                        .DataSource(source => {
                            source.Read(read =>
                            {
                                read.Action("GetCascadeDocumentNumbers", "DockDoor")
                                    .Data("filterLoadDescription");
                            })
                          .ServerFiltering(true);
                        })
                        .Enable(false)
                        .AutoBind(false)
                        .CascadeFrom("loadType")
                        )
                <script>
                    function filterLoadDescription(){
                        return {
                            locCode: $("#locationCode").val(),
                            loadType: $("#loadType").val(),
                            docNumFilter: $("#loadDescription").data("kendoComboBox").input.val()
                        };
                    }
                </script>
                @Html.ValidationMessageFor(model => model.loadDescrip)
            </div>
        </div>


Here is the method in my Controller:
public JsonResult GetCascadeDocumentNumbers(string locCode, string loadType, string docNumFilter)
       {
           var docNums = db.GetCurrentDocumentNumbers(locCode, loadType).AsQueryable();
 
           if (!string.IsNullOrWhiteSpace(docNumFilter))
           {
               docNums = docNums.Where(x => x.Contains(docNumFilter));
           }
 
           return Json(docNums.Select(x => new {DocCode = x}), JsonRequestBehavior.AllowGet);
       }


What am I doing wrong that this is not being called?

4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 27 Nov 2013, 10:27 AM
Hello,

Thank you for the given code snippets. At first glance, the setup of the widgets looks just fine. In order to proceed with the investigation I will ask you to send us a simple repro test project. Thus I will be able to observe the issue locally and advice you further.

Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
ajith
Top achievements
Rank 1
answered on 20 May 2015, 07:21 AM

Hi Georgi Krustev's

I have same issue.the problem is my id field is string not int, so i cant filter in controller. Please help me

public JsonResult GetAssetSubGroup([DataSourceRequest] DataSourceRequest request, AssetGroupViewModel locations, string groups, string groupfilter)
        {
            try
            {
                var assetGroup = _assetSubGroupManager.GetSubGroup();
 
                var groupViewModel = Mapper.Map<List<SubGroupModel>, List<AssetSubGroupViewModel>>(assetGroup);
                if (groups != null)
                {
                    assetGroup = assetGroup.Where(p => p.group_code(groups));
                }
                return Json(assetGroup.Select(c => new { ID = c.group_code, Name = c.name })
                    .OrderBy(o => o.ID)
                    .ToList(), JsonRequestBehavior.AllowGet);
 
            }
            catch (Exception ex)
            {
                throw;
            }
        }

0
ajith
Top achievements
Rank 1
answered on 20 May 2015, 07:24 AM

hi Agropurs,

    I have same issue. is your issue is resolved?. if yes help me too. Thank you in advance.

0
Georgi Krustev
Telerik team
answered on 22 May 2015, 06:56 AM
Hello ajith,

The shared code is not sufficient to determine why the cascading functionality does not work on your end. Could you send us a repro demo that demonstrates the issue?

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