Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Add 2 button to the rows of the browse form

Questions related to customising nuBuilder Forte with JavaScript or PHP.
calida
Posts: 6
Joined: Thu Mar 30, 2017 12:14 am

Add 2 button to the rows of the browse form

Unread post by calida »

hi, is there the possibility to add 2 buttons to the rows of the browse form?
I would like to press the first button to open the edit form of the selected record, pressing the second to open another form browse with the records related to the selected record
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Add 2 button to the rows of the browse form

Unread post by kev1n »

Hi,

Are you familiar with JavaScript?

There's an article in the Code Library that shows how to add a button to each row of a Browse Form:
https://github.com/smalos/nuBuilder4-Co ... te_buttons
steven
Posts: 370
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 53 times
Been thanked: 52 times

Re: Add 2 button to the rows of the browse form

Unread post by steven »

calida,

If you know Javascript this might help.

It adds an Edit Button to the first column of a Browse/Lookup.

Code: Select all


for(var i = 0 ; i < 20 ; i++){

    if($('#nucell_' +  i + '_1').html() != ''){
        $('#nucell_' +  i + '_0').html('<input type="button" id="edit' + i + '"class="nuActionButton" value="Edit" onclick="editBuildType(event)">');
    }
}

function editBuildType(e){

    var p = e.target.id.substr(4)
    $('#nucell_' +  p + '_0').prop("onclick", null).off("click");
    var pk = $('#nucell_' +  p + '_0').attr('data-nu-primary-key');
    nuForm('600cc03b4195b7f', pk, '', '', '1');


}

Steven
A short post is a good post.
apmuthu
Posts: 249
Joined: Sun Dec 06, 2020 6:50 am
Location: Chennai, India, Singapore

Re: Add 2 button to the rows of the browse form

Unread post by apmuthu »

Should we not have a button on the form designer to add buttons with standard options like Delete, Edit, Popup (with parameters), etc - a sort of a wizard or standard form to add them in?

This way we can leverage some standard functions to generate them instead of custom JS each time.
icoso
Posts: 181
Joined: Sun Feb 07, 2021 11:09 pm
Been thanked: 1 time

Re: Add 2 button to the rows of the browse form

Unread post by icoso »

apmuthu wrote:Should we not have a button on the form designer to add buttons with standard options like Delete, Edit, Popup (with parameters), etc - a sort of a wizard or standard form to add them in?

This way we can leverage some standard functions to generate them instead of custom JS each time.
Great Idea! Also How can I either disable or delete a button once I add it.

I have a form that all fields are disabled when you first open it (view only). For example: I have a function that deletes the clone button, via: $('#nuCloneButton').hide(); Then I add two buttons: One to duplicate the current record and one to just edit the current record.


nuAddActionButton('DupMyForm', 'Duplicate MyForm', 'clearFields("cust_billdate|cust_retdate")');
nuAddActionButton('EditMyForm', 'Edit MyForm', 'clearFields("NO")');

My clearfields() function will either clear out some fields after I click DupMyForm or NOT if I just click the EditMyForm button.

If I click my DupMyForm Button, I'd like to disable it afterwards or hide it. Same with the Edit Button. Don't want the user to get to click happy.

Doing this: $('#DuMyForm').hide(); OR nuDisableAllObjects(); OR nuDisable('DupMyForm'); does not work to disable the buttons.

Also, I'd like to add a Title to the page that Shows Im "Editing" or Duplicating" so the user has an idea what they clicked. Any IDea how to do that would be appreciated.
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Add 2 button to the rows of the browse form

Unread post by kev1n »

Use nuDisable() to disable objects.

Where should this "Title" be displayed?
icoso
Posts: 181
Joined: Sun Feb 07, 2021 11:09 pm
Been thanked: 1 time

Re: Add 2 button to the rows of the browse form

Unread post by icoso »

kev1n wrote:Use nuDisable() to disable objects.

Where should this "Title" be displayed?
Kevin, I've tested with nuDisable(): "Doing this: $('#DuMyForm').hide(); OR nuDisableAllObjects(); OR nuDisable('DupMyForm'); does not work to disable the buttons. "

As with any web page, usually a page has a text title. I'd like it to appear on the Form just above the fields on the page. I could do it with a <div> on the Form page itself and just hide or display it using java script on a regular web page. BUt I don't know how to put a text field (not one that needs to be saved in the dB) on the form itself.

Any ideas would be helpful...
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Add 2 button to the rows of the browse form

Unread post by kev1n »

To disable the save button:

Code: Select all

nuDisable('nuSaveButton');
To disable the clone button:

Code: Select all

nuDisable('nuCloneButton');
To disable the delete button:

Code: Select all

nuDisable('nuDeleteButton');
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Add 2 button to the rows of the browse form

Unread post by kev1n »

icoso wrote: BUt I don't know how to put a text field (not one that needs to be saved in the dB) on the form itself.
Just create a new object to the form an give it any ID.

icoso wrote:As with any web page, usually a page has a text title. I'd like it to appear on the Form just above the fields on the page.
Where exactly should this title appear? At position 1,2,3 or somewhere else?
where.png
You do not have the required permissions to view the files attached to this post.
icoso
Posts: 181
Joined: Sun Feb 07, 2021 11:09 pm
Been thanked: 1 time

Re: Add 2 button to the rows of the browse form

Unread post by icoso »

I should be able to put a title or text object on the form itself that is not associated with a DB field that I can hide or unhide or change appropriately.
Example-FormTitle.png
I tried just adding a display field but it wants an ID that attached to the database.
Screenshot-Save Display Text.png
With a Javascript <div id=whatever> I can typically hide or unhide it using javascript. I just want to display something on the screen when the user is either EDITING or has CLONED a RECORD. This is just to warn them that Hey you're changing something and need to save it or exit out. For example: If the user is looking at a display only form and hits Edit then I want this title to appear and state: "You ARE EDITING AN EXISTING RECORD. Make your changes and click SAVE to save your changes or EXIT to NOT save your changes."

But if they click duplicate:
"You have DUPLICATED AN EXISTING RECORD. YOu must change the Billing & Filing Date and click SAVE to save your changes or EXIT to NOT save your changes."

Its just a text box on the form to use as an instructional thing as the user does something.
You do not have the required permissions to view the files attached to this post.
Post Reply