Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Populate Select with Contact Service on Screen Load

2 Questions:

1) How come I can't populate a Select with the Contact Service on Screen Load? I can only do it by Invoke Service on a Button Click. Invoking the service on screen load does nothing.

2) When I populate a list by invoking the contact service, it automatically selects the first contact in the list. Is there a way to set all to False as a default?

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Populate Select with Contact Service on Screen Load

Hello,

1) Please try to use page show event
2) You could use filter parameter to determines which records must be shown.
http://docs.appery.io/tutorials/using...

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Populate Select with Contact Service on Screen Load

1) Page Show does not work either. I do not understand why the service will work with a click event but not show or load.

2) I am able to show the correct record, the problem is the Select component automatically marks the first item in the list as true. Any way to load this as False like the rest of the items in the list?

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

Populate Select with Contact Service on Screen Load

Hello,

1) "why the service will work with a click event but not show or load" - this is device service and it works only after 'device ready'. But if you invoke it on show event of the start page, then 'device ready' event isn't fired yet and service invocation doesn't work.
2) "Select component automatically marks the first item in the list as true" - it is not clear.
Do you mean that the first item is marked in select but you want that there wouldn't be any marked items by default at all? Is it right?

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Populate Select with Contact Service on Screen Load

1) Thank you.
2) Yes that is correct. I do not want any items to be selected when the list loads.

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

Populate Select with Contact Service on Screen Load

Hi,

In this case you should add one more item to the select component with empty label and value

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Populate Select with Contact Service on Screen Load

How do I do that, if the list is being populated by a service?

Also, some of the contacts start with a #. How do I add a filter to remove these or blank entries?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Populate Select with Contact Service on Screen Load

Hi Milton,

To add filter to your contacts please follow the next steps:
ol
liOpen mapping./li

liFind username-Label map and click "Add JS" - http://prntscr.com/3b1iqq/direct/li

liAdd the following code: http://prntscr.com/3b1kbw/direct/li
precode

return value.replace(/\#/gi, "");/code/pre
That's all.
/ol
To make default item for users select, please follow the steps below:
ol
liOpen Design tab and activate the select./li

liClick "Options - change". http://prntscr.com/3b1m50/direct/li

liOptions popup will appear. Delete all items. And create new one with value "default" and Label "Select users". Click save. http://prntscr.com/3b1mhf/direct/li

liOpen data tab. Navigate to your users service and add JS event handler on Success event. And insert the following code. http://prntscr.com/3b1my6/direct/li
precode

//You have to change "mobileselectmenu_12" with your select component name.
Appery("mobileselectmenu_12").val("default").trigger("change");/code/pre
That's all.

Regards./ol

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Populate Select with Contact Service on Screen Load

Hi Illya,

Unfortunately, neither of these things did what I want. The filter just removed the "#" from my label, not removed the entry from the select. I was looking for something closer to this, although it does not work:

//delete values with # in them
var test = value;
if( test.indexOf('#') = 0){
// Found #, now remove entry from select
$("Contact_Select option[value]").remove();
return;
}

To make default entry, added Select Users entry and made it default to true, but placed it at the bottom of my select, and still defaulted to selecting the first contact. I attached a screen shot so you can see. Image Image

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Populate Select with Contact Service on Screen Load

Any update on this?

Return to “Issues”