How to replace and add buttons to the editor windows
How to replace and add buttons to the editor windows
obrienj
Posts: 93Questions: 38Answers: 0
I have two editor windows, both the default format.
The one for new rows has "Add" in the lower right.
The one for edited rows has "Update" in the lower right.
Both have an "X" for cancelling in the upper right.
What I would like to do is:
- Get rid of the "X"
- Add a "Cancel" button to each window.
- Replace "Add" and "Update" with "Save" but each "Save" has the appropriate function for adding and updating.
- Center the buttons at the bottom of the window
Is there an example or documentation on how to do this?
Regards,
Jim
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi Jim,
Example.
Use
i18n.create.submit
andi18n.edit.submit
.Its hard to write explicit documentation for the first and last since there are millions of possible things you can do with CSS. However, the DOM structure that Editor uses is fully documented here and you can also use the "Inspect" option in your browser.
Allan
Allan,
Thanks for the very complete response.
So far I have run into an issue centering the buttons at the bottom of the screen.
The css you gave me moves the buttons to the left.
Any thoughts?
Regards,
Jim
Allan,
I must be missing something, the example you pointed to to add button does so on the table list window not the editor window.
I want to add a "Cancel" button at the bottom of the Editor window to the right of the new "Save" button.
Your thoughts?
Regards,
Jim
Allan,
Got the button centered (still don't have "Cancel") by modifying what you sent to:
"text-align: center; doesn't do it.
Regards,
Jim
Hi Jim,
Can you show me the code you are using to add the cancel button? This example shows how it can be done, but perhaps there is something else overriding that on your page or you are using it in a different way.
Allan
Allan,
On the Editor window I want a cancel button to the right of the "Save" button.
As you can see, I have "defined" the "Save" button and I have centered it.
All I need is the cancel button.
This is the editor definition:
This is the editor window definition:
In the example I linked to above it uses the
formButtons
option of the Buttons that Editor presents:Are you using those buttons? Or are you using some other way of triggering the create / edit action?
Allan
Alan,
I put my edit and delete buttons on the end of each row in the Datatables list.
I have attached an image of the Create (Editor) screen and I want a "Cancel" button to the right of the "Add" button.
I must be very confused but I don't see how the example you referenced accomplishes this.
Regards,
Jim O'Brien
Allan,
In doing more research I found that the way I do access to the editor is via a "New" button on the Datatables list screen and and "edit/delete" on the right of each line on the Datatables list screen.
I my code I do the following:
For "edit":
And for "New":
I'm guessing I have to do something here but the next question is "What?".
Regards,
Jim
Perfect - that's what I needed to know. You are defining the
buttons
option as simply'Update'
or'Add'
, which is why only one button is shown. That option is passed directly to thebuttons()
method.So what you want to use is:
And likewise for the edit.
Allan
Allan,
Thanks you.
Now I have the buttons I want, but they are stacked one on top of the other.
Where do a I make a change to get them side but side? (Hints on what to change also appreciated).
Regards,
Jim
Not sure I'm afraid - when I tried it they were side by side. It will be a CSS property, but exactly which one I'm not certain. I would suggest right clicking on the buttons and select "Inspect" and check to see what CSS is applied to them. Possibly you might need
display: inline-block
.Allan
Allan,
Will do.
I've encountered a strange behavior that may be my issue.
If I open edit first, the buttons don't appear.
If I open new first, the buttons are there and on all subsequent new and edit windows.
I see no error s in Web Console or Browser Console.
Any thoughts?
Regards,
Jim
Can you show me your full Javascript?
Thanks,
Allan
Also, when this occurs, I get the string "multiple values" appearing in all the fields on the editor screen.
I've put my code in https://pastebin.com/jnXQcmQX
Regards,
Jim
Allan,
I must have really messed up the button code because when I took it all out, the issues I was having went away.
But I still don't have the Cancel button so what I will do is add pieces back until I get the buttons I want and everything else is functioning as it should.
Any thoughts you have as you look at the code on this subject would be appreciated.
Thanks for your help.
Regards,
Jim
I'm surprised that isn't showing the cancel button - it looks like it should. Are you able to link to a page with running code?
Allan
Allan,
Finally got the "Cancel" button.
Apparently when using buttons on each row, I needed to do the following:
In the handler for the "Edit" button on the line I coded:
And in the Datatables definition I had to code this:
Of course, I had to repeat this for "Create".
I will admit that I have no clue as to what is behind this and it was actually a trial and error coding process.
If you see any changes I should make, please pass them on.
I appreciate all your help and I will mark this as the answer.
Regards,
Jim