Convert Cell Template to itemFormatter w/Controller and Event Handler

Posted by: johnny.su on 25 July 2018, 6:01 am EST

    • Post Options:
    • Link

    Posted 25 July 2018, 6:01 am EST

    Hi,

    Is there an example somewhere that demonstrate converting custom cell template to using the itemFormatter function or formatItem handler? Our custom cell template has a controller and some event handlers (ie. ng-mousedown)?

    We have a grid that has a lot of custom cell templates and it’s causing performance issues when any cell leaves edit mode and the whole grid is refreshed. I searched through the forum and others are also having this issue with custom cell templates. One suggestion was to create the custom cells in the itemFormatter function.

    I created a Fiddle to demonstrate what we have: http://jsfiddle.net/7kj8veh9/2/

    Thanks,

    Johnny

  • Posted 26 July 2018, 5:33 am EST

    Hi,

    For information, the performance issue can also be seen for itemFormatter as it also refresh the FlexGrid view.

    The only way to display angular directives/tags using from itemFormatter would be to use $compile API to first compile the template and then append it to the cell.

    From the performance point of view, we would recommend you to you cellFactory as it will provide the best performance of all the available options.

    Please refer to the following sample to get started with cellFactory:-

    https://demos.wijmo.com/5/Angular/CellFactory/CellFactory/

    ~Manish

  • Posted 3 August 2018, 8:45 am EST

    Hi Manish,

    I followed the example on creating a custom cell factory but can’t seem to emulate the custom cell template functionality in the fiddle above. Once I override the innerHTML I can’t edit the cell anymore and if I have custom cell templates in other columns of the table, it completely removes the custom cell templates from all columns. I have multiple columns that use custom templates and I only want to refactor one of them to use a custom cell factory.

    Is there other examples that you could provide?

    Thanks,

    Johnny

  • Posted 6 August 2018, 2:16 pm EST

    Hi Johnny,

    We are sorry, currently, CellTemplate and CellFactory can’t be used at the same time. Hence, this issue has been forwarded to the concerned team with tracking id 337365.

    We will let you know as we get an update on this.

    ~Manish

  • Posted 8 August 2018, 8:53 pm EST

    Hi,

    We got a response from developers.

    The problem with cell factories and cell templates using together is that cell templates use their own cellFactory assigned to the grid.cellFactory property.

    When we assign our CustomCellFactory the one previously used by cell templates gets lost.

    So as developers suggested instead of calling super.updateCell, the custom cellFactory should read current cellFactory, store the referance to it(say in _baseCF property) and call _baseCF.updateCell.

    Please find the attached sample which uses the same approach to use cell factory and cell templates together.

    Thanks,

    Manish GuptaCellFactoryWithTemplates.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels