asp.net mvc - Kendo Ui Grid Filterable. How can I change filter operator? -


using mvc wrapper, try change default filter "equal" "contains". found examples, none of them want (or wrong use them...)

ok, so, code:

@(html.kendo().grid<portal2.areas.coord.models.viewmodel>()     .name("grid")     .columns(columns =>     {         columns.bound(c => c.operationkey).hidden();         columns.bound(c => c.customer).hidden();         columns.bound(c => c.carnumber).filterable(ftb => ftb.ui("carfilter"));         columns.bound(c => c.drivername).filterable(ftb => ftb.ui("driverfilter"));         columns.bound(c => c.phonenumber).filterable(ftb => ftb.ui("phonefilter"));     })     .filterable(f => f.extra(false))      .datasource(datasource => datasource         .ajax()         .read(r => r             .action("read", "operations2", new { starttime = (datetime)viewbag.starttime, endtime = (datetime)viewbag.endtime })             )         .pagesize(20)         .serveroperation(false)         )     .htmlattributes(new { style = "height: 740px" })     .scrollable()     .groupable()     .sortable()      .pageable(pageable => pageable         .refresh(true)         .pagesizes(true)         .buttoncount(10)         ) ) 

i have js functions:

function filter(element, atr) {     var entitygrid = $(".k-grid").data("kendogrid");     var data = entitygrid.datasource.data();     var totalnumber = data.length;     var drivers = [];     (var = 0; < totalnumber; i++) {         var currentdataitem = data[i][atr];         if ($.inarray(currentdataitem, drivers) == -1)             drivers.push(currentdataitem);     }     element.kendoautocomplete({         datasource: drivers     }); }  function carfilter(element) {     filter(element, "carnumber") } function driverfilter(element) {     filter(element, "drivername") } function phonefilter(element) {     filter(element, "phonenumber") 

they put values helper textbox in each filter. try this:

    columns.bound(c => c.carnumber)         .filterable(ftb => ftb.ui("carfilter"))         .filterable(ftb => ftb.cell(c => c.operator("contains"))); 

but thats work .filterable(f => f.mode(gridfiltermode.row))

    .filterable(filterable => filterable         .extra(false)         .operators(operators => operators             .forstring(str => str.clear()                 .startswith("starts with")                 .isequalto("is equal to")                 .isnotequalto("is not equal to")             )         )     )   

it doesn't provide expected result.

suggestions on how fix this?

kendo ui grid filterable. how can change filter operator?

...

try change default filter "equal" "contains"

...

but works .filterable(f => f.mode(gridfiltermode.row))

so, how change filter operators per column:

http://www.telerik.com/forums/grid-column-filter-default-method#mbwcohyzt02g-szmrs35yq

columns.bound(m => m.field)     .filterable(f =>         f.operators(             o => o                 .forstring(s =>                     s.clear()                      .contains("contains")                      .doesnotcontain("does not contain")                      .isequalto("is equal to")                      .isnotequalto("is not equal to")                      .startswith("starts with")                      .endswith("ends ")                 )         )) 

important use s.clear() add ones want in order want them.

as per linked forum, if values match kendo assumes defaults , doesn't change order - 1 of them needs space.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -