Apply a filter to a datagrid by code (Freedom UI)
12:59 Feb 18, 2025
Hi,
There is an issue with apply a filter to a datagrid by code (Freedom UI).
We have a page parameter (ex: UsrDuns), and we want to filter an account datagrid filtered by this text value.
When done on crt.HandleViewModelInitRequest handler, no filter is applied, so all accounts are loaded.
When done by manually changing a TextField and use this text field to apply the filter, the filter works as expected.
Is there any way to apply this filter on page load (like in the old UI) ?
Best regards,
Like
2 comments
21:07 Feb 19, 2025
Hello,
Can you share an example of the implemented code? Screenshots with an example page would also be helpful.
17:40 Feb 20, 2025
On page Load, 2 is not filtered by 1
handlers: /**SCHEMA_HANDLERS*/[ { request: "crt.HandleViewModelInitRequest", handler: async (request, next) => { await next?.handle(request); request.$context.events$.subscribe((async (evt) => { if (evt?.type === "finish-load-model-attributes" && evt?.payload?.PageParameters_UsrTextParameter1_p75os8h) { var siren = await request.$context[ clientTool.findPageParameterByDesignName(request, "UsrNumeroSIREN") ]; await clientTool.reloadGridDetail(request, "DataGrid_yoo8q38DS"); } })); } }, { request: "crt.LoadDataRequest", handler: async (request, next) => { console.log("LoadDataRequest - START"); if(request.dataSourceName === "DataGrid_yoo8q38DS") { console.log("LoadDataRequest - DS"); var siren = await request.$context[ clientTool.findPageParameterByDesignName(request, "UsrNumeroSIREN") ]; if (siren) { console.log("LoadDataRequest - SIREN=" + siren); if (typeof request.parameters === "undefined") { console.log("Init request.parameters"); request.parameters = []; // Initialize it as an empty object or some default value } if(request.parameters) { const filter = new sdk.FilterGroup(); await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "UsrNumSiren", siren); // note, these lines are only needed due to an issue with filters in Creatio-DevKit SDK // expected to be fixed in Creatio 8.1 const newFilter = Object.assign({}, filter); newFilter.items = filter.items; request.parameters.push({ type: "filter", value: newFilter }); } } } return await next?.handle(request); } }, { request: "crt.HandleViewModelAttributeChangeRequest", handler: async (request, next) => { if(request.attributeName === clientTool.findPageParameterByDesignName(request, "UsrNumeroSIREN")) { console.log("HandleViewModelAttributeChangeRequest"); await clientTool.reloadGridDetail(request, "DataGrid_yoo8q38DS"); } return next?.handle(request); } } ]/**SCHEMA_HANDLERS*/,
Show all comments