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

Problems with default Operator on Filter

3 Answers 447 Views
Grid
This is a migrated thread and some comments may be shown as answers.
OfficialCommunity
Top achievements
Rank 1
OfficialCommunity asked on 19 Feb 2015, 04:17 PM
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:

sort:page:1group:filter:Name~startswith~'t'

Then after a delay a second call is sent:

sort:page:1pageSize:5group:filter:Name~contains~'t'

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()
{
    @(Html.Kendo().Grid<ViewableSelectableProduct>()
              .Name("grid-products-search-#=ID#")
              .AutoBind(true)
              .Pageable(pager => pager
                    .Input(true)
                    .Numeric(true)
                    .Info(true)
                    .PreviousNext(true)
                    .Refresh(true)
                    .PageSizes(true)
              )
              .Scrollable()
              .Sortable()
              .Navigatable()
              .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"))
                            .Title("commands")
                            .Width(Constants.Columns.Default.Widths.ColumnCommands);
              })
               .Filterable(filterable => filterable
                    .Extra(false)
                    .Operators(ops => ops
                        .ForString(str => str.Clear()
                            .Contains("Contains")
                            )))
              .DataSource(dataSource => dataSource
                  .Ajax()
                  .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);
                  })
                  .PageSize(5)
                  .Events(events =>
                  {
                      events.Error("standard_grid_error_handler");
                  })
                  //.Batch(true)
                  .ServerOperation(true)
                  .Read(read => read.Action("ReadSelectable", "Product", new { blockId = "#=ID#" }))
              )
              .ToClientTemplate()
    )
}


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

thanks








3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 23 Feb 2015, 08:23 AM
Hi,

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

.Filterable(f => f.Cell(cell => cell.Operator("contains").SuggestionOperator(FilterType.Contains)
     .ShowOperators(false).Delay(100)))


Regards,
Rosen
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.

 
0
Kyle Smith
Top achievements
Rank 1
answered on 17 Mar 2015, 12:48 PM
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:
sort=&page=1&group=&filter=Name~startswith~'f'

Generated javascript for the column:
{"title":"Name","width":"140px","field":"Name","filterable":{"cell":{"showOperators":false,"inputWidth":120}},"encoded":true,"editor":null}
0
Kyle Smith
Top achievements
Rank 1
answered on 17 Mar 2015, 01:05 PM
Nevermind! I updated to the latest and it is working now.
Tags
Grid
Asked by
OfficialCommunity
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Kyle Smith
Top achievements
Rank 1
Share this question
or