Customize render callback to not expect a string and just perform actions within the callback fn

Customize render callback to not expect a string and just perform actions within the callback fn

anusreemnanusreemn Posts: 11Questions: 3Answers: 0
edited January 2022 in DataTables 1.10

Link to test case:
https://github.com/DataTables/ColReorder/issues/49

Current versions of packages installed:
"datatables.net-dt": "^1.11.3",
"datatables.net-colreorder-bs4": "^1.5.5",

Description of problem:

In reorder of columns using ColReorder, it was unable to trigger the dynamic insertion of components done in createdCell callback due to render being run.

Hence, the workaround I found was to trigger the same createdCell callbackfn in the return of renderFn.

I have raised a PR for the same https://github.com/DataTables/DataTablesSrc/pull/198

The usage sample is as below

col.renderReturnType = 'function'; // only then will these changes be activated

const createdCellCallback = (tdElm, cellData, rowData, rowIndex) => {
  // dynamically insert an angular component into tdElm with help of Renderer2; passing in needed values from rowData and cellData as @Inputs to the component
}

col.render = (data, type, row, meta) => { return createdCellCallback; }

col.createdCell = createCellCallback;

Please check and merge this at the earliest, in a matter of hours to be exact.

Answers

  • anusreemnanusreemn Posts: 11Questions: 3Answers: 0

    @colin http://live.datatables.net/qonidogo/6/ here is the link to reproduce the issue.

    Reorder the columns and see that the links in Name column disapper.

    I want the table to behave in a way that if , commented lines are uncommented in place of existing 'render', then links be inserted no matter what.

    Is it possible for this to be released as in today? My app release is waiting on this feature.

    Feel free to suggest alternative key values for renderReturnType, and I can update the PR accordingly. Any speedy progress is really appreciated!

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Many thanks for the update. I will take a look at the Github updates you've sent as soon as possible.

    I'm afraid there is zero chance of a new DataTables release today. Unless there is anything critical (i.e. security) it is unlikely that there will be a release this week, since we just issues 1.11.4 on Friday.

    That said, you won't need a release of DataTables core for your app. You could just use a fork until the API is settled and released in DataTables core. This shouldn't effect the release timescales for your app :).

    Allan

  • anusreemnanusreemn Posts: 11Questions: 3Answers: 0

    Thankyou @allan !

    I would like to get this released at the earliest if possible. Let me know what improvements I can do to the PR once you take a look at it. Thank you for understanding my situation!

  • anusreemnanusreemn Posts: 11Questions: 3Answers: 0

    Hi @allan ,

    I have included a static updated js file for now, but can you let me know if this PR will be taken under consideration anytime soon (maybe atleast in a couple of weeks)

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Super - great to hear you can progress forward :).

    I've got it in my inbox to take a look at as soon as I can. There are still some outstanding issues that I think need to be resolved before we can consider merging it in, but I'll look into it more.

    Allan

Sign In or Register to comment.