Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Colorise Brouse form

forgot
Posts: 42
Joined: Thu Aug 09, 2012 8:52 pm

Colorise Brouse form

Unread post by forgot »

Hello

Wonderful system. So easy and so powerful! Very easy jump up from Access without knowledge in mySQL and PHP. :!:

:?: Is it possible change style (color of text or background) for specific row in Browse form?
:?: Is there equivalent javafunction nuLoadThis() for Browse form like in Screen form? Function that execute at start of Browse form and I can change it.


Thanks,
Maxim
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Colorise Brouse form

Unread post by admin »

Maxim,

If you put this in Before Browse

Code: Select all

//--changing style in a Browse Form

$s = <<<EOSQL

CREATE TABLE #browseTable# SELECT 
customer_id,
cus_code,
cus_phone,
cus_mobile,
cus_fax,

IF(LEFT(cus_name,1)="J", CONCAT('<b>',cus_name,'</b>'),cus_name) AS cus_name

FROM customer


EOSQL;

nuRunQuery($s);

//--running JavaScript on a Browse Form

$j = <<<EOJS

function nuLoadThis(){

   alert('Customer Names Starting with "J" have been highlighted');

}

EOJS;

addJSfunction($j);
And Change SQL (on the General Tab) to..

Code: Select all

SELECT * FROM #browseTable#
You can try it on the Financial Module, Customer Browse.
nufin.png
nufin.png (14.71 KiB) Viewed 6023 times
Hopefully it answers both your questions..

Steven
forgot
Posts: 42
Joined: Thu Aug 09, 2012 8:52 pm

Re: Colorise Brouse form

Unread post by forgot »

After that manipulations on Customer browse form customer that start with "J" now bold.
But something strange happened. When this Customer form with modify "Browse before" use as lookup form all goes wrong. Customer "J" still bold but when you click on it nothing happened. I say about lookup form.
You can see when creating new invoice on the Financial Module.

As I find it happened after you override function nuLoadThis().


--
Maxim
Sorry for my poor English. Hope you understand all clearly.
forgot
Posts: 42
Joined: Thu Aug 09, 2012 8:52 pm

Re: Colorise Brouse form

Unread post by forgot »

So I found that this some problem with addJSfunction($j); function. If I use it javafunction doIt(pID) despaired from source of form.
As I understand doIt dynamically add when form use as Lookup form.

If use this simple code in Before Browse then select for lookup doesn't work.

Code: Select all

//--running JavaScript on a Browse Form
$j = "";

addJSfunction($j);
If you comment //addJSfunction($j); all will work!

For my task very critical add JavaScript to startup of browse form that use for LOOKUP field.

--
Maxim
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Colorise Brouse form

Unread post by admin »

Maxim,

Here's the fix I will also put it in the next version..

Steven
Attachments
formlookup.zip
(2.12 KiB) Downloaded 345 times
forgot
Posts: 42
Joined: Thu Aug 09, 2012 8:52 pm

Re: Colorise Brouse form

Unread post by forgot »

Thank you Steven. Works!

Here my approach for modify browse form using Javascripts.

So task was for invoice in my system show in lookup form for choosing item only active item. In separate form (item property) sales manager can choice for specific customer that item active and that inactive. And this state will change couple of time and invoice_items and products relationship together because of it impossible using only SQL with where statement.

Code: Select all

//--running JavaScript on a Browse Form

$j = <<<EOJS


function hideSell(sell){
    document.getElementById(sell).innerHTML = "";
    document.getElementById(sell).onmouseover = "";
    document.getElementById(sell).onmouseout = "";
    document.getElementById(sell).onclick = "";
    document.getElementById(sell).style.cursor = "default";
}

function rowsHide(){//---hide rows that unactive

   var columeNumber = 6;   //---number with code colum
   var unactiveCode = 20;  //---unactive code

   //---hide colum title
   element = document.getElementById("title"+columeNumber);
   element.parentNode.removeChild(element);
   
   //---for each row in browse form
   for(i = 0 ; i < 5 ; i++){   
      if ( i < 10 ) {
        rw = "rw0" + i;
      } else { 
        rw = "rw" + i;
      }
      
      //---get volume from code colume and hide this colum
      vol = document.getElementById(rw+columeNumber).innerHTML;
      vol = vol.substring(9,11);
      hideSell(rw+columeNumber);
      
      //---if this unactive element hide whole row
      if (vol == unactiveCode) {   
      
        //---for each colom for specific row
        for(j = 0 ; j < 7 ; j++){ 
          hideSell(rw+j);
        };
      }
   };
}

function nuLoadThis(){
   rowsHide();
}

EOJS;

addJSfunction($j);
Slightly change this code and you can colorize your browse form.
forgot
Posts: 42
Joined: Thu Aug 09, 2012 8:52 pm

Re: Colorise Brouse form

Unread post by forgot »

One more issue with JavaScript at startup lookup.

Then you have two function nuLoadThis(). One in JavaScript of Main Screen form and other in Before Browse of lookup form.
Only JavaScript in Before Browse of lookup form will execute.
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Colorise Brouse form

Unread post by admin »

Maxim,

I don't understand your last post.

Steven
zazzium
Posts: 84
Joined: Mon Jul 04, 2011 12:52 am

Re: Colorise Brouse form

Unread post by zazzium »

forgot,

u can use instead nuLoadThis() jquery load in before browse

Code: Select all

$(document).ready(function () {
 //code
});
or vice versa
forgot
Posts: 42
Joined: Thu Aug 09, 2012 8:52 pm

Re: Colorise Brouse form

Unread post by forgot »

zazzium

Excellent!!!! Thank you very much! :!: :!: :!:
Locked