I’m lost

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.
1 person has
this question
+1
This topic is no longer open for comments or replies.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned

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





    Thanks
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • 1
    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();
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • 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?


    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]);

    /* 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();
    }


    Thanks
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly sad, anxious, confused, frustrated happy, confident, thankful, excited indifferent, undecided, unconcerned

  • Hello,

    I've fixed the setCenter issue, by changing the following 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);


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

    Thanks.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly sad, anxious, confused, frustrated happy, confident, thankful, excited indifferent, undecided, unconcerned

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly sad, anxious, confused, frustrated

  • I’m indifferent
    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...

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly sad, anxious, confused, frustrated