Multicolumn in combobox

4 posts, 0 answers
  1. Teo
    Teo avatar
    4 posts
    Member since:
    Jun 2014

    Posted 10 Jun 2014 Link to this post

    Hi Telerik team,

    I'm a new bie in ASP.net MVC and telerik. When i create my project, i met the problem in multicolumn in combobox like your demo at : http://demos.telerik.com/aspnet-mvc/combobox/template... I don't attach the headertemplate because i don't need the title of column. But it cannot run when i add template ..hope your suggestion.

    here is test.cshtml file:
    @(Html.Kendo().ComboBox()
              .Name("test")
              .DataTextField("Category")
              .DataValueField("Category")
              .Filter("startswith")
              .MinLength(1)
              .HtmlAttributes(new { style = "width:250px" })
              .DataSource(source =>
              {
                  source.Read(read =>
                  {
                      read.Action("GetCategory", "User");
                  })
                  .ServerFiltering(false);
              })
                  .Template("<span class=\"k-state-default\">#: data.Category #</span>" +
                            "<span class=\"k-state-default\">#: data.ProductID #</span>")
    )

    and the getcategory method in  usercontroller:

    public JsonResult GetCategory()
            {
                var a = new DataClasses1DataContext().Dat_Hangs.Select(b => new OrderViewModel
                {
                    ProductID = b.ProductID,
                    ShopID = b.ShopID,
                    OID = b.OID,
                    Category = b.Category,
                    Quantity = b.Quantity,
                    Price = b.Price
                });

                return Json(a, JsonRequestBehavior.AllowGet);
            }


  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 10 Jun 2014 Link to this post

    Hi Teo,


    Could you please specify what issue are you experiencing - Is the page not loaded at all, is the widget not initialized or the data is not received? As a general advice I would suggest you to check the browsers console for JavaScript errors and also the network tab of the developer tools to assure that the data is received as expected.

    I am looking forward to hearing from you.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Teo
    Teo avatar
    4 posts
    Member since:
    Jun 2014

    Posted 10 Jun 2014 Link to this post

    Hi Dimiter,

    Thank you for your reply.

    When i use the combo box without template, it works. But I can not receive data when attach the temple for multi-column in combo box... 

    This is my error: JavaScript critical error in (unknown source location)\n\nSCRIPT1009: Expected '}'
  5. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 10 Jun 2014 Link to this post

    Hi Teo,


    Since the current error does not state much about the issue and there is no noticeable problem in the provided sample code, would it be possible to send us a small isolated project, which demonstrates the case? The sample data is not important, only a single page with the ComboBox would be enough for us to inspect it.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready