Page 1 of 3

Populate Select with Contact Service on Screen Load

Posted: Wed Mar 12, 2014 4:29 am
by Milton Davis

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?


Populate Select with Contact Service on Screen Load

Posted: Wed Mar 12, 2014 4:37 am
by Igor

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...


Populate Select with Contact Service on Screen Load

Posted: Wed Mar 12, 2014 7:16 am
by Milton Davis

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?


Populate Select with Contact Service on Screen Load

Posted: Wed Mar 12, 2014 4:09 pm
by Nikita

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?


Populate Select with Contact Service on Screen Load

Posted: Wed Mar 12, 2014 5:39 pm
by Milton Davis

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


Populate Select with Contact Service on Screen Load

Posted: Wed Mar 12, 2014 8:48 pm
by Nikita

Hi,

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


Populate Select with Contact Service on Screen Load

Posted: Thu Apr 17, 2014 8:00 pm
by Milton Davis

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?


Populate Select with Contact Service on Screen Load

Posted: Fri Apr 18, 2014 3:20 am
by Illya Stepanov

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


Populate Select with Contact Service on Screen Load

Posted: Fri Apr 18, 2014 6:42 pm
by Milton Davis

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


Populate Select with Contact Service on Screen Load

Posted: Sun Apr 20, 2014 6:00 pm
by Milton Davis

Any update on this?