For savedStatesCreate How can I modify the Button Text
For savedStatesCreate How can I modify the Button Text
I currently am using the savedStatesCreate extension to group the save and restore state functionality in one button -- but i have been unsuccessful at renaming the button. For the purposed of my team, we want to use save/load filter instead of save states ... is there any way to do this?
Also from a recommendation side of things, within this button, id recommend changing the css for div.dt-button-collection div.dt-btn-split-wrapper button.dt-button to include width: fit content and remove the pixel width on div.dt-button-collection (i set it to width: auto) This way the saved states expand to show the full name. Its not perfect but it works.
This question has an accepted answers - jump to answer
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Thanks Colin -- sorry given i had nothing to show i didnt know how to even provide a test... here is my code block atm below. My main issue is how i rename the Save States button that shows by default. Below you will see I am trying to rename it through
Here is the full code set (sans ajax and all the columns):
See if this savedStates Custom Button Text example helps. Its different than what you have.
Kevin
Unfortunately not. The issue is that I am using savesStatesCreate -- if i add another button "savedStates" it just adds that button. I need to modify the text within the extension...this is where im getting lost. I have tried text, and within the language modifier tried to adjust stateRestore there (no dice on either)
I took the example I linked and used it with just
savedStatesCreate
.http://live.datatables.net/tuhunihu/1/edit
Note the example states this:
Kevin
@kthorngren -- 100% that worked. However -- if you reference my code, you will see under language i say
by changing it to:
Corrected the text under saved states -- but then broke searchBuilder As you can see i moved the nested buttons from searchbuilder and made it the top of the hierachy
To be clear -- to correct the issue I used
Which solves everything, but i guess the prior post im asking -- why the difference in how its written
It's just the way the code is structured. The language options are per component, and when SearchBuilder is being used under a button, the Buttons are the extension. It's not ideal, agreed, but just how it is,
Colin
Thanks and understood! One final final note...for future people looking for help -- the custom name _: (%d) Custom Filter Selected is not necessarily accurate -- that value will only tell you how many filters have been saved. I have since replaced the zero state with the null state (and deleted the old null state) since knowing there are 10 filters available was less useful to our users.
One last question... While I can physically change the name of the button as listed above -- is there a way to change the name of the button to list the actual name of the state activated?
The goal here would be to have a null condition ( _: ) where when there is a state selected the button name would reflect the activated button -- or alternatively have something somewhere that gives the user more information about the active state
You could use
searchBuilder.filterChanged
to do that. Your function there is triggered every time a search is added/removed/changed, and you can use that trigger to change the text of the button. The example on that reference page is doing just that,Colin
Ok so after a lot of playing around I figured it out -- I will say this seems like something that i have overengineered -- but it works by taking advantage of the following example: https://datatables.net/extensions/staterestore/examples/customisation/activeLabel.html
Nice, thanks for reporting back,
Colin