John Gouda
Posts: 0
Joined: Sun Mar 02, 2014 4:38 pm

Delete an item from list which is linked to database colelction

Hello,

It's my first day with this great platform, to hit the point. I'm building an application that retrieve a collection from database, bind it to collapsibleSet control, the header of collapsible.Item is the collection.name. inside the collapsible.item there is two buttons and a label.

By clicking a button inside this collapsible.Item I need to delete this item from database. The delete service need the record ID in order to delete a record. While mapping collection to collapsibleSet I'm keeping the record ID in a hidden label. When i click the delete button I need to delete the record, how can I do that?

I couldn't find a direct way to do this, so as I said I have the record ID in a hidden label, by clicking the delete button I'm trying to get the label value using JS, but no luck. since the lable lie in iteration control, I can't get its value by control ID. I've tried to get the parent of Delete button and find the label from there, but also I couldn't do it.

Would you please help?

Thanks.

John Gouda
Posts: 0
Joined: Sun Mar 02, 2014 4:38 pm

Delete an item from list which is linked to database colelction

Hello Alena,

Thanks for your reply! I saw the links but couldn't find a way to delete an item from a list, the click event of a button is invoking a service, but the service need a record id, how to get that?

I think i can't assign the record id to localStorage during the mapping, since the localStorage var is holding a single value while the service response is an array?

If I can get the record id from a label which is located inside a collapsibleSet and assign it to localStorage var, then I can call the delete service.

Please check the images below.

Image

Image

Thanks

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

Delete an item from list which is linked to database colelction

Hello John.
Based on your screenshot, you can retrieve the id’s value for each collapsibleblock in this way:
add to ‘delete’ button’s click event following code:
var id = $(this).parent().find("[name=lblId]").text();

John Gouda
Posts: 0
Joined: Sun Mar 02, 2014 4:38 pm

Delete an item from list which is linked to database colelction

Hello Nikita,

Thanks for your support!! It works fine now, still learning basics :)

I came across another problem, and hope you can assist. By clicking show location on screenshot above, I'm populating a LocalStorage variable with the location coordinates, and then navigate back to the mainScreen. At the PageShow even i'm executing the following code to show the location selected.

When I click the show location, I need to clear all markers on the map, and focus the map center to the location selected. The following code is adding new marker, while keeping old markers and not focusing on the new location. How to fix this please?

code
if(localStorage.getItem("varAppInitialized") == "true")
{
var aloc = localStorage.getItem("varActiveLocation");
// Application already initialized, check the active location varliable!
if(!aloc || !aloc.trim())
{
alert("Empty location");
}
else
{
if (aloc.toLowerCase().indexOf(",") >= 0) // Contain comma
{
var Location = _aloc.split(',');
localStorage.setItem('varLat', Location[0]);
localStorage.setItem('varLng', Location[1]);

Code: Select all

         /* The following code is not adding a marker, and the map is not navigating to new location!! 
         var map = Appery("GMap"); 
         map.Latitude = varLat; 
         map.Longitude = varLng; 
         map.Address = ''; 
         map.refresh(); 
         */ 

         // The following line, is adding the marker to map, but other marker still there. And the map is not navigating to new marker 
         var _marker = new google.maps.Marker({position: new google.maps.LatLng(Location[0], Location[1]), map: Appery("GMap").gmap}); 
     } 
     else 
     { 
         alert("Error: Invalid location!"); 
     } 
 } 

}
else
{
// Application is just loaded, get the current location!
localStorage.setItem('varAppInitialized', 'true');
GetMyLocation.execute();
}
/code

Thanks

John Gouda
Posts: 0
Joined: Sun Mar 02, 2014 4:38 pm

Delete an item from list which is linked to database colelction

This code is being executed on the page show event

John Gouda
Posts: 0
Joined: Sun Mar 02, 2014 4:38 pm

Delete an item from list which is linked to database colelction

Hello,

I've fixed the setCenter issue, by changing the following code:

code
var _newPoint = new google.maps.LatLng(Location[0], Location[1]);
var _marker = new google.maps.Marker({position: newPoint, map: Appery("GMap").gmap});
Appery("GMap").gmap.setCenter(newPoint);
/code

Now I need to clear all markers on the map, before creating the new marker.

Thanks.

pboloz
Posts: 0
Joined: Wed Apr 02, 2014 11:38 pm

Delete an item from list which is linked to database colelction

Hello John,

Would you be able to share a screenshot of how you did the mapping for the delete service? I am having the same problem.

I did that, but it does not work...

Image

Return to “Issues”