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

Simple issue with Remote Data Source

1 Answer 61 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 12 Jun 2019, 12:55 PM

Having a simple issue with binding data to a dropdown.  Trying to follow from the demo code.  The code for RemoteDataSource_GetFirms never gets called.  Missing some basic concept I think.

Here is the controller:

public class ImpersonationController : Controller
    {
        public ActionResult Impersonation()
        {
            return View();
        }
            // GET: Impersonation
        public ActionResult RemoteDataSource()    //RemoteDataSource()
        {
            return View();
        }
        public JsonResult RemoteDataSource_GetFirms(string text)
        {
            var fo = new FirmObject();
            var firms = fo.GetFirms();
             
            if (!string.IsNullOrEmpty(text))
            {
                firms = firms.Where(p => p.SourceDataset.Contains(text));
            }
 
            return Json(firms, JsonRequestBehavior.AllowGet);
        }
    }

 

View:

@{
    Layout = null;
}
 
<!DOCTYPE html>
 
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Impersonate</title>
</head>
<body>
    <div class="demo-section k-content">
        <h4>Select a Firm</h4>
        @(Html.Kendo().DropDownList()
              .Name("ddFirms")
              .DataTextField("SourceDataset")
              .DataValueField("FirmID")
              .DataSource(source =>
                      {
                  source.Read(read =>
                  {
                      read.Action("RemoteDataSource_GetFirms", "Impersonation");
                  });
              })
              .HtmlAttributes(new { style = "width: 100%" })
        )
    </div>
</body>
</html>

 

1 Answer, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 12 Jun 2019, 03:25 PM
Solved.  I wasn't seeing the javascript error "kendo not defined".    Didn't have the scripts included in the right order.
Tags
DropDownList
Asked by
Robert
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Share this question
or