dfaruque / Serenity.Extra

Name of the repo says that this is an EXTRA of http://serenity.is platform
60 stars 34 forks source link

How to filter Item picker grid #40

Closed reach2rv closed 4 years ago

reach2rv commented 4 years ago

Hi,

Thank you for this great work.

I am using your griditempicker and have scenario where need to load filtered data based on multiple criteria. as of now I can only set one

filterField: "AtbId", filterValue: this.ItemAtbId

how we can set multiple filters or array of values to filter. this will be good to have feature as in application we may required filter grid with multiple criteria.

Please advice.

Regards

Arvind

dfaruque commented 4 years ago

use filteringCriteria just like filtering a grid

this.form.Books.options.filteringCriteria = Serenity.Criteria.or([[bookfld.TariffCategory], '=', TariffCategory.Industrial],
 [[bookfld.TariffCategory], '=', TariffCategory.Irrigation]);

see https://github.com/dfaruque/Serenity.Extra/tree/master/SerExtra/SerExtra.Web/Modules/BasicSamples/Grids/GridFilteredByCriteria for more filtering samples

reach2rv commented 4 years ago

this.form.Books.options.filteringCriteria = Serenity.Criteria.or([[bookfld.TariffCategory], '=', TariffCategory.Industrial], [[bookfld.TariffCategory], '=', TariffCategory.Irrigation]);

thanks.. but can you please elaborate, as in where to write filtering criteria on editor or on grid or on dialog. I tried with on grid but noting happens even debug does not hit.

Regards,

Arvind

dfaruque commented 4 years ago

Suppose you have a dialog called "DialogA". DialogA has a property with GridPickerEditor. then you could write the following in DialogA's constructor

this.form.Books.options.filteringCriteria = Serenity.Criteria.or([[bookfld.TariffCategory], '=', TariffCategory.Industrial],
[[bookfld.TariffCategory], '=', TariffCategory.Irrigation]);

here Books will be your picker editor's property name. bookfld will be picker row's fld should be declared on top of the ts file just bellow namespace line.

Hope you understand.

reach2rv commented 4 years ago

Thank You @dfaruque