ag-grid / ag-grid-aurelia

Aurelia wrapper for ag-Grid project
MIT License
23 stars 8 forks source link

getQuickFilterText 'params' argument is undefined #17

Closed don-bluelinegrid closed 7 years ago

don-bluelinegrid commented 7 years ago

I'm submitting a ... (check one with "x")

[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/ceolter/ag-grid-aurelia/blob/master/CONTRIBUTING.md#question

Current behavior When using the getQuickFilterText function in the Aurelia plugin, the params argument is always undefined. As a result, it is impossible to provide the quickfilter text, because the data is not available in params.

Expected behavior When a getQuickFilterText function is bound to a declarative column definition, the params object should be bound to the function argument, so that we can retrieve the data from params.

Minimal reproduction of the problem with instructions

        <ag-grid-column  get-quick-filter-text.bind="getMessageQuickFilterText(params)" cell-class="ag-notification-group-child" header-name="group" field="notificationCategory.categoryName" suppress-sorting.bind="true" suppress-filter.bind="true">
            <ag-cell-template>
                <span  style="display: block;">
                    <strong>${params.data.notificationCategory.categoryName}:</strong> ${params.data.message}
                </span>
            </ag-cell-template>
        </ag-grid-column>
  getMessageQuickFilterText(params) {
    this.logger.debug("===== getMessageQuickFilterText ===== " + params);
    return !!(params)?params.data.notificationCategory.categoryName + '_' + params.data.message:'';
  }

What is the motivation / use case for changing the behavior? We need to be able to use custom quickfilter text when using the Aurelia plugin. To do this, the getQuickFilterText function must work as designed.

Please tell us about your environment: MacOS

don-bluelinegrid commented 7 years ago

Note -

It appears that the getQuickFilterText callback is being called by the grid before the grid is ready and has data; that would partially explain why params is undefined. See log below:

DEBUG [NotificationsTableGridCustomElement] BInd
aurelia-logging-console.js:24 DEBUG [NotificationsTableGridCustomElement] ===== getMessageQuickFilterText ===== undefined
aurelia-logging-console.js:24 DEBUG [Alerts] Alerts | bind()
aurelia-logging-console.js:24 DEBUG [NotificationsTableGridCustomElement] attached
aurelia-logging-console.js:24 DEBUG [NotificationsTableGridCustomElement] ===== getMessageQuickFilterText ===== undefined
logger.js:52 ag-Grid.Context: >> creating ag-Application Context
logger.js:52 ag-Grid.Context: bean InMemoryRowModel created
logger.js:52 ag-Grid.Context: bean PaginationAutoPageSizeService created
logger.js:52 ag-Grid.Context: bean GridApi created
logger.js:52 ag-Grid.Context: bean ComponentProvider created
logger.js:52 ag-Grid.Context: bean CellRendererFactory created
logger.js:52 ag-Grid.Context: bean HorizontalDragService created
logger.js:52 ag-Grid.Context: bean HeaderTemplateLoader created
logger.js:52 ag-Grid.Context: bean FloatingRowModel created
logger.js:52 ag-Grid.Context: bean DragService created
logger.js:52 ag-Grid.Context: bean DisplayedGroupCreator created
logger.js:52 ag-Grid.Context: bean EventService created
logger.js:52 ag-Grid.Context: bean GridOptionsWrapper created
logger.js:52 ag-Grid.Context: bean SelectionController created
logger.js:52 ag-Grid.Context: bean FilterManager created
logger.js:52 ag-Grid.Context: bean ColumnController created
logger.js:52 ag-Grid.Context: bean PaginationProxy created
logger.js:52 ag-Grid.Context: bean RowRenderer created
logger.js:52 ag-Grid.Context: bean HeaderRenderer created
logger.js:52 ag-Grid.Context: bean ExpressionService created
logger.js:52 ag-Grid.Context: bean BalancedColumnTreeBuilder created
logger.js:52 ag-Grid.Context: bean CsvCreator created
logger.js:52 ag-Grid.Context: bean Downloader created
logger.js:52 ag-Grid.Context: bean XmlFactory created
logger.js:52 ag-Grid.Context: bean GridSerializer created
logger.js:52 ag-Grid.Context: bean TemplateService created
logger.js:52 ag-Grid.Context: bean GridPanel created
logger.js:52 ag-Grid.Context: bean PopupService created
logger.js:52 ag-Grid.Context: bean ValueService created
logger.js:52 ag-Grid.Context: bean MasterSlaveService created
logger.js:52 ag-Grid.Context: bean LoggerFactory created
logger.js:52 ag-Grid.Context: bean ColumnUtils created
logger.js:52 ag-Grid.Context: bean AutoWidthCalculator created
logger.js:52 ag-Grid.Context: bean GridCore created
logger.js:52 ag-Grid.Context: bean StandardMenuFactory created
logger.js:52 ag-Grid.Context: bean DragAndDropService created
logger.js:52 ag-Grid.Context: bean SortController created
logger.js:52 ag-Grid.Context: bean ColumnApi created
logger.js:52 ag-Grid.Context: bean FocusedCellController created
logger.js:52 ag-Grid.Context: bean MouseEventService created
logger.js:52 ag-Grid.Context: bean CellNavigationService created
logger.js:52 ag-Grid.Context: bean FilterStage created
logger.js:52 ag-Grid.Context: bean SortStage created
logger.js:52 ag-Grid.Context: bean FlattenStage created
logger.js:52 ag-Grid.Context: bean FocusService created
logger.js:52 ag-Grid.Context: bean FilterService created
logger.js:52 ag-Grid.Context: bean RowNodeFactory created
logger.js:52 ag-Grid.Context: bean CellEditorFactory created
logger.js:52 ag-Grid.Context: bean CellRendererService created
logger.js:52 ag-Grid.Context: bean ValueFormatterService created
logger.js:52 ag-Grid.Context: bean StylingService created
logger.js:52 ag-Grid.Context: bean ScrollVisibleService created
logger.js:52 ag-Grid.Context: bean ColumnHoverService created
logger.js:52 ag-Grid.Context: bean ColumnAnimationService created
logger.js:52 ag-Grid.Context: bean ServerPaginationService created
logger.js:52 ag-Grid.Context: bean SortService created
logger.js:52 ag-Grid.Context: bean AutoGroupColService created
logger.js:52 ag-Grid.Context: >> ag-Application Context ready - component is alive
aurelia-logging-console.js:24 DEBUG [NotificationsTableGridCustomElement] === onGridReady ===
grid.js:129 ag-Grid -> initialised successfully, enterprise = false
aurelia-logging-console.js:24 
swalters commented 7 years ago

@don-bluelinegrid please try get-quick-filter-text.bind="getMessageQuickFilterText"

I'm pretty sure it wants a reference to a function, not the result of a function.

don-bluelinegrid commented 7 years ago

@swalters

Shane,

Thanks for your reply.

However, I have tried every combination of .bind and .call, with a function reference or call. If you read above, the problem is not that the function is not called, the problem is that the function argument is missing so we can't do anything inside the function.

Here is what I've found:

get-quick-filter-text.bind="getMessageQuickFilterText(params) Bound function is called, params is undefined.

get-quick-filter-text.bind="getMessageQuickFilterText Bound function is called, params is undefined.

get-quick-filter-text.call="getMessageQuickFilterText Bound function is called, params is undefined.

In all cases, the getQuickFIlterText function is called before the onGridReady function (see log pasted above, and note sequence of getQuickFilterText and onGridReady and the undefined quickFilter param), and this seems wrong (in addition to the missing argument).

Doesn't this seem incorrect? Is it possible that there is a binding problem in the Aurelia plugin implementation? This is causing headaches here with being able to use QuickFilter in non-trivial cases.

Thanks, Don

seanlandsman commented 7 years ago

This should now be fixed and will be available in the next release