Page 1 of 1
'Undefined' listed in results rather than blank field
Posted: Fri Jan 03, 2014 3:07 pm
by Shaun Summers
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.
'Undefined' listed in results rather than blank field
Posted: Fri Jan 03, 2014 4:29 pm
by maxkatz
In mapping, you can check for the value and set it to empty string.
'Undefined' listed in results rather than blank field
Posted: Fri Jan 03, 2014 4:41 pm
by Kateryna Grynko
Just to add.
You can add request parameter where: {"ww":{"$regex":".", "$options":"i"}}
'Undefined' listed in results rather than blank field
Posted: Fri Jan 03, 2014 7:10 pm
by Shaun Summers
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.
'Undefined' listed in results rather than blank field
Posted: Fri Jan 03, 2014 8:30 pm
by Kateryna Grynko
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.
'Undefined' listed in results rather than blank field
Posted: Fri Jan 03, 2014 8:59 pm
by Shaun Summers
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.
'Undefined' listed in results rather than blank field
Posted: Sat Jan 04, 2014 3:54 pm
by Shaun Summers
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
'Undefined' listed in results rather than blank field
Posted: Mon Jan 06, 2014 10:08 am
by Kateryna Grynko
Hi Shaun,
Add this JavaScript to a mapping of field that can be empty:preif (!value) return "";/pre
'Undefined' listed in results rather than blank field
Posted: Mon Jan 06, 2014 11:16 am
by Shaun Summers
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.