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

Am I crazy or does this example not work?

2 Answers 59 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Duke
Top achievements
Rank 1
Duke asked on 27 Mar 2017, 02:31 PM

http://demos.telerik.com/aspnet-mvc/combobox/serverfiltering

The view and the controller do not seem to work together.  The view is calling a controller action that does not exist, the controller action that does exist is not returning any data.

Or if I'm wrong, I'll humbly accept corrections :-)

2 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 27 Mar 2017, 02:53 PM
Hello Duke,

The demo works, enter "ani" for example (note that the ComboBox' MinLength option is set to 3, thus for  filtering to be triggered a minimum of three characters need to be entered).
As for the missing controller and action, in this particular demo the GetProducts action from the Home controller is called: 
read.Action("GetProducts", "Home");

This specific action is called by many other demos, but as you have correctly noticed it is not posted in the demo's source viewer. Currently the demos source viewer displays the view and the associated with it controller (in this case ServerFilteringController.cs), and since the actual server logic for filtering the ComboBox is in the Home controller it is not visible from this demo's page. This is definitely something that we aim at improving in the future in our demos site. The relevant code (views, controllers, etc.) should be displayed in the source section.

Here's the actual definition of the GetProducts action:
public JsonResult GetProducts(string text)
{
    var northwind = new SampleEntities();
 
 
    var products = northwind.Products.Select(product => new ProductViewModel
    {
        ProductID = product.ProductID,
        ProductName = product.ProductName,
        UnitPrice = product.UnitPrice ?? 0,
        UnitsInStock = product.UnitsInStock ?? 0,
        UnitsOnOrder = product.UnitsOnOrder ?? 0,
        Discontinued = product.Discontinued
    });
 
    if (!string.IsNullOrEmpty(text))
    {
        products = products.Where(p => p.ProductName.Contains(text));
    }
 
    return Json(products, JsonRequestBehavior.AllowGet);
}

Since as I explained currently the demos site does not display all the relevant information, we can recommend running the sample demos application locally. It contains all the demos and comes with the Telerik UI for ASP.NET MVC installation. Here's a documentation article, which explains how you can run it. The sample application would allow you to inspect more closely the implementation of any demo that presents an interest.

Regards,
Ivan Danchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Duke
Top achievements
Rank 1
answered on 27 Mar 2017, 02:59 PM

Hey Ivan, thanks for the quick reply!

You're right - the demo itself does work.  Sorry, I should have clarified:  I meant that the code in the source viewer doesn't work.  

Thanks for the explanation about the source code.  Looking forward to seeing the (more) complete source code for these demos!

Regards,

Duke

Tags
ComboBox
Asked by
Duke
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Duke
Top achievements
Rank 1
Share this question
or