Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get columnDefs in DataTable to work #25

Open
sanjeevbhalla opened this issue Jan 28, 2016 · 0 comments
Open

Cannot get columnDefs in DataTable to work #25

sanjeevbhalla opened this issue Jan 28, 2016 · 0 comments

Comments

@sanjeevbhalla
Copy link

Have a data table which has some numeric columns. I am not able to get those columns to either be right justified or take num-fmt or even to add some text through a render fn. I am not a datatables/javascript expert so could be doing something basic wrong.

All help appreciated!

Here are my three different attempts

  1. Trying to right justify the col - all other cols appear in table but this col shows undefined
    tb = DataTable("pltable", "/pltable/", latestPL, columns=cols, paging=True, searching=True, sortable=True, pageLength=40,
    columnDefs=[{
    "className": "dt-body-right",
    "targets": [0]
    }])

This should work! Inspecting the option in React/Javascript debugger shows as if the definition is ok

  1. Trying to add fmt - all other cols appear in table but this col shows undefined
    tb = DataTable("pltable", "/pltable/", latestPL, columns=cols, paging=True, searching=True, sortable=True, pageLength=40,
    columnDefs=[{
    "type": "html",
    "targets": [0]
    }])
    This should work! Inspecting the option in React/Javascript debugger shows as if the definition is ok

  2. Trying to just add "(abc)" to value of each row in col 0 (as a test)
    tb = DataTable("pltable", "/pltable/", latestPL, columns=cols, paging=True, searching=True, sortable=True, pageLength=40,
    columnDefs=[{
    "render": function ( data, type, row ) {
    return data +' ('+ 'abc' +')';
    },
    "targets": 0
    }])
    This does not compile. If I surround function with """ then it emits the func as a character string in the react structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant