Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

'Undefined' listed in results rather than blank field

Hello,

I have a list generated from my database. The issue I have is that fields that are blank in the database are being displayed as 'undefined' in the results. I would just like them to remain empty in the app when they are empty in the database.

The list is being generated from a standard database service with a 'where' query to limit the results.

Would you please suggest how to resolve this issue. Thanks.

Shaun. Image

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

'Undefined' listed in results rather than blank field

In mapping, you can check for the value and set it to empty string.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

'Undefined' listed in results rather than blank field

Just to add.
You can add request parameter where: {"ww":{"$regex":".", "$options":"i"}}

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

'Undefined' listed in results rather than blank field

Hello,

Sorry, but this is getting too complicated for my level. Would you please help me to adjust my "where" to include this code. This is what I currently have:

return '{ $and: [ { "Brand": "'+value+'" }, { "User_ID": "' + localStorage.getItem("user_id") + '" },{ "Person": "' + localStorage.getItem("selected_person") + '" } ] }';

Where/how should I include your code?

Regards, Shaun.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

'Undefined' listed in results rather than blank field

Shaun,

Try this code:
prereturn '{ $and: [ { "Brand": "'+value+'" }, { "User_ID": "' + localStorage.getItem("user_id") + '" },{ "Person": "' + localStorage.getItem("selected_person") + '" },{"param":{"$regex":".", "$options":"i"}} ] }';/preWhere 'param' is a name of needed parameter that is not empty.

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

'Undefined' listed in results rather than blank field

Hi,

I've just tried adding some javascript to one of the mapped fields:

if (str == null) return "";

It seems to clear the 'undefined' but it causes the page to continually load (circle goes round and round) and some other fields (no javascript added) that contain valid data are emptied...

Clearly I'm missing something.

Regards, Shaun.

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

'Undefined' listed in results rather than blank field

Hello Katya,

Thanks for the code. I've tried it but it doesn't do what I'm looking for. I think I was unclear on the problem.

The code that you have given me results in only complete records being displayed in my list (ie. where none of the 5 fields that make up the record are empty). This is not what I'm trying to do.
I want to display all records even if some of the fields are empty, which I have achieved. The issue I'm having is that when an empty field exists the word 'undefined' is displayed rather than just an empty space.

How can I display just an empty space instead of undefined?

Kind Regards, Shaun

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

'Undefined' listed in results rather than blank field

Hi Shaun,

Add this JavaScript to a mapping of field that can be empty:preif (!value) return "";/pre

Shaun Summers
Posts: 0
Joined: Thu Jul 25, 2013 3:49 pm

'Undefined' listed in results rather than blank field

Hello Katya,

That works. Thanks very much.

The only issue is that it seems to slow down the app but it does work.

Regards, Shaun.

Return to “Issues”