Problems with default Operator on Filter

4 posts, 0 answers
  1. OfficialCommunity
    OfficialCommunity avatar
    10 posts
    Member since:
    May 2006

    Posted 19 Feb 2015 Link to this post

    Currently using version 2014.3.1411.

    I am trying to always filter on the "contains" operator for string columns in my grid.

    The problem is that when I start typing in any of the the filters, a request is sent to the 
    DataSource Read with the following data:


    Then after a delay a second call is sent:


    The second call is correct. It has the correct pageSize and filter.

    In the grid I have removed all filters except Contains and assigned an Operator("contains") to each filtered cell.

    If I inspect the Filter i see this:

    <input data-bind="value: value" data-role="autocomplete" data-text-field="Name" data-filter="startswith" data-delay="100" data-min-length="1" data-value-primitive="true" type="text" class="k-input" autocomplete="off" role="textbox" aria-haspopup="true" aria-disabled="false" aria-readonly="false" aria-autocomplete="list" aria-owns="" style="width: 100%;" aria-busy="false"><br>

    This is the grid:

    @helper RenderProductsSearch()
                  .Pageable(pager => pager
                  .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
                  .HtmlAttributes(new { style = "height: 100%; border: 0;" })
                  .Columns(columns =>
                      columns.Bound(e => e.Name).Width(300).Title("name").Filterable(f => f.Cell(cell => cell.Operator("contains").ShowOperators(false).Delay(100)));
                      columns.Bound(e => e.Sku).Width(200).Title("sku").Filterable(f => f.Cell(cell => cell.Operator("contains").ShowOperators(false).Delay(100)));
                      columns.Bound(e => e.ShortDescription).Title("description").Filterable(f => f.Cell(cell => cell.Operator("contains").ShowOperators(false).Delay(100)));
                      columns.Command(command => command.Custom("Select").Click("selectProduct"))
                   .Filterable(filterable => filterable
                        .Operators(ops => ops
                            .ForString(str => str.Clear()
                  .DataSource(dataSource => dataSource
                      .Model(model =>
                          model.Id(p => p.Id);
                          model.Field(x => x.Id).Editable(false);
                          model.Field(x => x.Name).Editable(false);
                          model.Field(x => x.Sku).Editable(false);
                          model.Field(x => x.ShortDescription).Editable(false);
                      .Events(events =>
                      .Read(read => read.Action("ReadSelectable", "Product", new { blockId = "#=ID#" }))

    Why is the first call happening and why does the input data-filter contain the wrong operator?


  2. Rosen
    Rosen avatar
    3253 posts

    Posted 23 Feb 2015 Link to this post


    In order to set the autocomplete operator you should use the SuggestionOperator option:

    .Filterable(f => f.Cell(cell => cell.Operator("contains").SuggestionOperator(FilterType.Contains)


    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.

  3. Kyle Smith
    Kyle Smith avatar
    46 posts
    Member since:
    Feb 2012

    Posted 17 Mar 2015 in reply to Rosen Link to this post

    I have the following column definition:

    columns.Bound(x => x.Name).Width(140).Filterable(f => f.Cell(c => c.Operator("eq").SuggestionOperator(FilterType.Contains).ShowOperators(false).InputWidth(120)));

    However, the "Contains" for the suggestion is not honored:

    Generated javascript for the column:
  4. Kyle Smith
    Kyle Smith avatar
    46 posts
    Member since:
    Feb 2012

    Posted 17 Mar 2015 in reply to Kyle Smith Link to this post

    Nevermind! I updated to the latest and it is working now.
Back to Top