Add 2 icon fields to each row to the browse/search form

Questions related to using nuBuilder Forte.

Re: Add 2 icon fields to each row to the browse/search form

Postby kev1n » Thu Sep 12, 2019 4:58 am

calida82 wrote:Hi thanks for the answer I tried and it works. but there is a way to add the icon only where there are records? in this way he adds it to all the lines even if there are no records.


Just check if the cell is not empty:
Code: Select all
if (nuFormType() == 'browse') {
    $('[data-nu-column="0"]').each(function (index) { // 1st column
       
      var cellId = $(this).attr('id');
      var cell = $('#' + cellId);
      if (cell.html() != '') {
                  
         cell.html('<img src="graphics/select.png" alt="select"  ">');
         this.onclick = function() { alert('clicked!'); };   
      }
    });
}


calida82 wrote:to open a new form I can use nuForm (nuGetProperty ('form_id'), r, '', '', '0', '1'); ?


You need to replace the variable r with the record id. So it will look like this:

i
Code: Select all
f (nuFormType() == 'browse') {
    $('[data-nu-column="0"]').each(function (index) { // 1st column
       
      var cellId = $(this).attr('id');
      var cell = $('#' + cellId);
      if (cell.html() != '') {
                  
         $(this).data('record_id', cell.html());
         cell.html('<img src="graphics/select.png" alt="select"  ">');
         
         this.onclick = function() {          
            var r = $(this).data('record_id');
            
            nuForm (nuGetProperty ('form_id'), r, '', '', '0');
         };   
      }
    });
}
kev1n
 
Posts: 244
Joined: Mon Oct 15, 2018 2:13 am

Re: Add 2 icon fields to each row to the browse/search form

Postby calida82 » Thu Sep 12, 2019 6:56 pm

Hi
i'm trying your code
Code: Select all
if (nuFormType() == 'browse') {
    $('[data-nu-column="0"]').each(function (index) { // 1st column
       
      var cellId = $(this).attr('id');
      var cell = $('#' + cellId);
      if (cell.html() != '') {
                 
         $(this).data('record_id', cell.html());
         cell.html('<img src="graphics/select.png" alt="select"  ">');
         
         this.onclick = function() {         
            var r = $(this).data('record_id');
           
            nuForm (nuGetProperty ('FF1'), r, '', '', '0');
         };   
      }
    });
}


but when i press on the icon
I am redirected to the first home page of nubuilder.

but nuGetProperty what does he do?
because in the wiki says
nuForm(string1, string2,string3,string4,string5)
but in the example appear nuGetProperty.....
i try with NuForm('FF1',r,'','','0');

but an empty edit page opens without fields
calida82
 
Posts: 5
Joined: Mon Sep 09, 2019 3:50 pm

Re: Add 2 icon fields to each row to the browse/search form

Postby kev1n » Sun Sep 15, 2019 12:20 am

Use nuCurrentProperties().form_id to redirect to the current edit screen.
kev1n
 
Posts: 244
Joined: Mon Oct 15, 2018 2:13 am

Previous

Return to General