×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    12

    How to hide NULL items?

    Hi,

    I have 5 user-defined items.
    But there are times whereby some users choose to key-in 4 or less items.

    Below is the coding which will display both NULL and not NULL items:

    viewNote.append("Name"+" : "+myNotearray.myNote[i].Name, null);
    viewNote.append("Age"+" : "+myNotearray.myNote[i].Age, null);
    viewNote.append("Race"+" : "+myNotearray.myNote[i].Race, null);
    viewNote.append("Occupation"+" : "+myNotearray.myNote[i].Occupation, null);
    viewNote.append("Salary"+" : "+myNotearray.myNote[i].Salary, null);

    Please advise how can I avoid displaying those NULL items?
    Thank you.

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to hide NULL items?

    Just check them...

    Code:
    if (myNotearray.myNote[i].Name != null) {
        viewNote.append("Name"+" : "+myNotearray.myNote[i].Name, null);
    }
    Graham.

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    12

    Re: How to hide NULL items?

    I tried. But it doesn't work.
    I think it might be due to the null inside this coding:

    viewNote.append("Name"+" : "+myNotearray.myNote[i].Name, null);

  4. #4
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    81

    Re: How to hide NULL items?

    Hi,

    Will you please clear it more. According to your code , what Graham told is correct. What is viewNote . What the output is coming ? If something is null, then obviously null will show on screen.

    Thanks

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: How to hide NULL items?

    Quote Originally Posted by cheri_sakura View Post
    I tried. But it doesn't work.
    I think it might be due to the null inside this coding:

    [I]viewNote.append("Name"+" : "+myNotearray.myNote.Name, null);
    What is the second null parameter,i am sure that null is coming sue to the second null parameter in red color.
    1.If user leaving few values as null,then you can yourself write the "N/A" in the same field.
    2. Else you can make the values as not null
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  6. #6
    Registered User
    Join Date
    Jul 2009
    Posts
    12

    Re: How to hide NULL items?

    Quote Originally Posted by lalitendu_panda View Post
    Hi,

    Will you please clear it more. According to your code , what Graham told is correct. What is viewNote . What the output is coming ? If something is null, then obviously null will show on screen.

    Thanks
    Hi,

    viewNote is like a blank page. Its purpose is only to display my records using append method.

    This is my output:
    Name: Cherry
    Age : 20
    Race: <-- Any method to hide this?
    Occupation: Student
    Salary: <-- Any method to hide this?

  7. #7
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: How to hide NULL items?

    Hello,
    If the values for any field are null, then simply do not draw the same on the Form/Canavs.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  8. #8
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: How to hide NULL items?

    Quote Originally Posted by cheri_sakura View Post
    This is my output:
    Name: Cherry
    Age : 20
    Race: <-- Any method to hide this?
    Occupation: Student
    Salary: <-- Any method to hide this?
    You need to identify the value of the variables you want to omit. From what you say, it sounds like these variables are not null. Possibly, the are empty strings. You can omit empty strings like this:

    Code:
    if (myNotearray.myNote[i].Name.length() > 0) {
        viewNote.append("Name: " + myNotearray.myNote[i].Name, null);
    }
    If this doesn't work, then you need to find out what the value actually is, and modify the test appropriately.

    Graham.

  9. #9
    Registered User
    Join Date
    Jul 2009
    Posts
    12

    Re: How to hide NULL items?

    Quote Originally Posted by grahamhughes View Post
    From what you say, it sounds like these variables are not null. Possibly, the are empty strings. You can omit empty strings like this:

    Code:
    if (myNotearray.myNote[i].Name.length() > 0) {
        viewNote.append("Name: " + myNotearray.myNote[i].Name, null);
    }
    Graham,

    It works! They are indeed empty strings.


    Dear all,

    Thank you so much for your prompt replies and patience guidance.

    Cheers,
    cheri_sakura

Similar Threads

  1. BT problem with startInquiry() method.
    By lparmy in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2010-11-08, 16:10
  2. java.io.IOException: Out of response entries in 6300
    By mtuhukumar k in forum Mobile Java Networking & Messaging & Security
    Replies: 16
    Last Post: 2009-10-12, 10:56
  3. is it rite? Help
    By fani_ccc in forum Mobile Java General
    Replies: 38
    Last Post: 2009-07-23, 05:47
  4. Problem with HTTP POST
    By thathoo in forum Mobile Java General
    Replies: 2
    Last Post: 2006-12-18, 18:23
  5. Gauge to monitor progress not working :(
    By mattsaccount in forum Mobile Java General
    Replies: 1
    Last Post: 2004-05-17, 02:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×