Follow up to "Datatables defaults on datatable fields in Editor"

Follow up to "Datatables defaults on datatable fields in Editor"

BjornHaBjornHa Posts: 64Questions: 11Answers: 0

As I marked the question as answered, I will follow up here...

Following this up, seems like layout is where I have my issues..
My default settings are

                top: [
                    'buttons',
                    'paging',
                    { search: { placeholder: 'Sökord' } }
                ],
                topStart: null,
                topEnd: null,
                bottomStart: 'info',
                bottomEnd: 'pageLength'

This gets overridden by

                top: hasButtons
                    ? ['search', 'buttons', 'info']
                    : ['search', 'info'],
                bottom: ['paging'],
                bottomStart: null,
                bottomEnd: null,
                topStart: null,
                topEnd: null

It does not seem to be possible to override this in the datatable field type options.
I tried with

                            top: [
                                'buttons'
                            ]

but to no avail.
KR,
Björn H

This question has accepted answers - jump to:

Answers

  • BjornHaBjornHa Posts: 64Questions: 11Answers: 0
    edited November 4

    However, adding a "dom" element instead of a "layout" element such as

    dom: 'Brtp'
    

    does override the layout removing "Search" and "Info".
    /björn

  • rf1234rf1234 Posts: 3,188Questions: 92Answers: 438

    "dom" is legacy. It is what I am still using. So you got a workaround now. Good to hear!

    @allan sounds like there is a bug in "layout"?!

  • allanallan Posts: 65,308Questions: 1Answers: 10,830 Site admin

    It should be working okay.

    It is worth highlighting that the defaults would need to be set to null due to the deep merge.

    Allan

  • kthorngrenkthorngren Posts: 22,314Questions: 26Answers: 5,130
    edited November 5

    @allan This code:

    top: hasButtons
        ? ['search', 'buttons', 'info']
        : ['search', 'info'],
    

    Adds search and info elements if the buttons are added like this:

    top: [
        'buttons'
    ]
    

    For example:
    https://live.datatables.net/jacagowu/1/edit

    Possibly adding info about how to deal with the layout option in the config property of the -field datatable field type would be good.

    Kevin

  • BjornHaBjornHa Posts: 64Questions: 11Answers: 0

    Thanks for the clarification of the problem Kevin, this is exactly what I am trying to understand.
    I thought that the overrule the datatable feild type did, was on the datatable.default settings, but it seems as it is applied after the config section of the actual field itself.
    Then again, if you use "dom:", then it adhears to it.
    We are trying to move from "dom" to "layout" generically during the next quarter as we see it going away in DataTables 3.0 and we have a big technical depth here.
    KR,
    Bjørn H

  • kthorngrenkthorngren Posts: 22,314Questions: 26Answers: 5,130
    Answer ✓

    Define the buttons within the layout option as Allan’s example shows. It works as expected then.

    Kevin

  • allanallan Posts: 65,308Questions: 1Answers: 10,830 Site admin
    Answer ✓

    At the moment, my feeling is that I am unlikely to remove dom from DataTables 3 - it is going to prove to be too much of a backwards compatibility issue for too many people.

    Adds search and info elements if the buttons are added like this

    I'm with you now. Yes, that's a pain. That's due to the use of $.extend and how it handles arrays. I'll need to have a look at changing that to shallow copy arrays. Thank you!

    Allan

  • BjornHaBjornHa Posts: 64Questions: 11Answers: 0

    I have accepted the answers above, but I am glad you will look at it Allan, as the solution is to add buttons in a way that prevents inheritage of definitions as far as I can understand.
    I also really don't see that Allans example is working, there is still "Search" and "Info", but might be missing something here.
    We will probably stick with "dom:" in datatable fields in Editor.
    We try to define the button sets centrally as far as possible.
    And we will still move to layout as far as possible, it is much better for us codewise :)
    Many thanks for your efforts,
    Bjørn H

  • allanallan Posts: 65,308Questions: 1Answers: 10,830 Site admin
    Answer ✓

    That's odd. The example I linked to doesn't show a search or info for me:

    Are you seeing something different?

    Allan

  • BjornHaBjornHa Posts: 64Questions: 11Answers: 0

    No, sorry, my misstake, it looks great.
    /Bjørn h

  • rf1234rf1234 Posts: 3,188Questions: 92Answers: 438

    At the moment, my feeling is that I am unlikely to remove dom from DataTables 3 - it is going to prove to be too much of a backwards compatibility issue for too many people.

    @allan
    Yep, please keep it. Wasn't all that bad :smile: Since the introduction of field type "datatable" I haven't missed anything to be honest. My next challenge is AI. Not for coding, but for the extraction of uploaded documents. I want to make data entering redundant - at least for some of my use cases. Will share when I'm done.

Sign In or Register to comment.