mRender not called after ColReorder and fnSetColumnVis

mRender not called after ColReorder and fnSetColumnVis

jeremyhjeremyh Posts: 6Questions: 0Answers: 0
edited April 2013 in Plug-ins
I am using ColReorder to to reorder columns. I have also enabled a modal dialog for column selection (ColVis did not work well for the UI I needed.) I can reorder the columns without any problem. I can also add and remove columns without any problem (by calling fnSetColumnVis) I can also reorder after adding and removing.

However, if I try to add and remove columns after reordering, the mRender function does not seem to get called.

The fiddle shows the behavior. The first few columns have mRender functions set. If you attempt to add or remove any column after rearranging, the custom rendering goes away from all columns.
http://jsfiddle.net/sEXbs/6/

Replies

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    I'd suggest that you use objects rather than arrays as the data source for this kind of table. That will make the referencing / indexes much easier to follow. Also, I wouldn't expect mRender to be called after column visibility change - there shouldn't be any need to call it since only the visible cells have changed, not the content.

    Allan
  • jeremyhjeremyh Posts: 6Questions: 0Answers: 0
    Switching to an object for the dataSource does seem to work. However, the data that I am using comes in an array format from the webservice, so I would prefer to avoid the extra transformation if possible.

    When using objects for the datasource, mRender is called twice after each fnSetColumnVis change. This works before and after reordering columns.

    When an array datasource is used, the behavior is different:
    1) ColReorder works fine. The columns are rearranged as expected. Since it is just rearranging things in the DOM, mRender is not called.
    2) Before reordering columns, fnSetColumnVis works properly. mRender is called 2 times for each cell.
    3) After running ColReorder, fnSetColumnVis behaves differently. The table is redrawn after adding or removing columns. mRender is not called for any of the columns (even if the columns were never touched by any of the options.) The result is that the rendering is all gone.
This discussion has been closed.