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

Behavior stange in combobox

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Xavier
Top achievements
Rank 1
Xavier asked on 06 Mar 2015, 09:45 AM
I show you the scenario, we have a combobox with filter “contains”. 

Combobox ProductorSearch
@model int
 
@(Html.Kendo().ComboBox()
    .Name("ContactID")
    .HtmlAttributes(new { style = "width:300px" })
    .AutoBind(false)
    .Placeholder("Escriu...")
    .DataTextField("Nom")
    .DataValueField("ContactID")
    .Filter(FilterType.Contains)
    .MinLength(4)
    .DataSource(source =>
    {
        source.Read(read => read.Action("SearchProductors", "Productors", new { area = "Comercial" }).Data("filterProductors"))
            .ServerFiltering(true);
    })
    //.HeaderTemplateId("ProductorSearch_HeaderTemplate")
    .TemplateId("ProductorSearch_ItemTemplate")
)
 
<script id="ProductorSearch_HeaderTemplate" type="text/x-kendo-tmpl">
    <div>
        <span class="k-widget k-header">Productor</span>
        <span class="k-widget k-header">Poblacio</span>
    </div>
</script>
<script id="ProductorSearch_ItemTemplate" type="text/x-kendo-tmpl">
    <div style="width:300px">
        @*<span class="k-state-default">#: data.Poblacio #</span>*@
        <p><span class="k-state-default">#: data.Nom #</span><span class="k-state-default">#: data.Poblacio #</span></p>
    </div>
</script>

Model
public class CollectServiceViewModel
    {
        [DisplayName("Ordre")]
        [HiddenInput(DisplayValue = false)]
        [Required(ErrorMessage = "El número d'ordre es obligatori.")]
        public int ServiceID { get; set; }
 
        [DisplayName("Albarà")]
        public string RefExt { get; set; }
 
        [DisplayName("Full Seguiment")]
        public string DocNum { get; set; }
 
        [DisplayName("Data Comanda")]
        //[DisplayFormat(DataFormatString = "{0:d}")]
        [DataType(DataType.Date)]
        public DateTime DataOrdre { get; set; }
 
        [DisplayName("Data Servei")]
        [DataType(DataType.Date)]
        [UIHint("CustomDate")]
        public Nullable<DateTime> DataServei { get; set; }
 
        [DisplayName("Expedició")]
        [UIHint("ExpeditionsByData")]
        public Nullable<int> ExpeditionID { get; set; }
        //public Nullable<short> Position { get; set; }
 
        [DisplayName("Urgent")]
        public bool Urgent { get; set; }
 
        [DisplayName("Reclamat")]
        [DataType(DataType.Date)]
        public Nullable<DateTime> DataClaim { get; set; }
 
        [DisplayName("Recollida Extra")]
        public bool Extra { get; set; }
 
        [DisplayName("Productor")]
        [Required(ErrorMessage = "El productor es obligatori.")]
        [UIHint("ProductorSearch")]
        public int ContactID { get; set; }
 
        [DisplayName("Productor")]
        [HiddenInput(DisplayValue = false)]
        public string ProductorName { get; set; }

Grid in View
@(Html.Kendo().Grid<CollectServiceViewModel>()
        .Name("collects")
        .HtmlAttributes(new { style = "height: 100%; border: 0;" })
        .Scrollable()
        .ToolBar(t =>
        {
            if (User.IsInRole("Modify"))
            {
                t.Create().Text("Nou Servei");
            }
        })
        .Columns(columns =>
        {
            columns.Bound(f => f.ServiceID).Width(80);
            columns.Bound(f => f.DataServei).Width(110);
            columns.Bound(f => f.RefExt).Width(110);
            columns.Bound(f => f.DocNum).Width(110);
            columns.Bound(f => f.ProductorName).Width(300).Filterable(f => f.Operators(g => g.ForString(h => { h.Clear(); h.Contains("Conté"); })));
            columns.Bound(f => f.ContactID).Title("Codi").Width(80);


The first time I write a text with 4 o more chars my chars are hidden and then I can see a char 0. This behavior is only occurred the first time, after that the behavior is normal.



Thanks in advance.
Xavier

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 10 Mar 2015, 08:35 AM

Hello Xavier,

The problem is caused by the fact that the combobox has autoBind set to false, and a value is set when the Grid goes into edit mode, and while there is value, but there is nothing in the dataSource you see the value in the widget. I would suggest you to turn on the autoBinding in order to resolve this issue.

Regards,
Kiril Nikolov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Xavier
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or