vipul
Posts: 0
Joined: Wed Jul 31, 2013 8:59 am

How to update multiple objects in a collection on a single click

I have a check box in a grid of 3 columns. which displays list of students through list service which runs on load of the page.
Now i have to select the check box for the students who are present in the class and then on click of submit button its value should be updated in to the database.
in short how will i run update service to updated multiple object on a single click of a button.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to update multiple objects in a collection on a single click

Hello! "On a single click" you can update only one record. You would need to run update service for each record in a loop.

vipul
Posts: 0
Joined: Wed Jul 31, 2013 8:59 am

How to update multiple objects in a collection on a single click

Hello!

this grid is of 3 columns and 1 row.
ex : Name StudentId checkbox
values comes in this grid form previous page.
so let say i got 2 values in this grid
ex:
Marina 1234 checkbox
Vipul 1111 checkbox

here student id is the object id of that particular row in the collection

now when i mark Marina as present by selecting the check box
it should run update service by picking 1234 as the object id

how will I do that??

I know this is a lame question but i m new to Appery so pls help

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to update multiple objects in a collection on a single click

1) You would need to configure Update service to make so that record id will be mapped to localStorage variable;
2) using JS define all checked checkboxes (http://api.jquery.com/checked-selector/). For checked checkboxes (http://api.jquery.com/each/) you need to find parent element with tr tag (http://api.jquery.com/parents/) because you're working with a Grid, tr is a table row, if you're working with another component (not Grid) then you need to find corresponding parent element and in this parent element find element which contains records id (http://api.jquery.com/find/). Save id to localStorage variable, call the service codeserviceName.execute({});/code

vipul
Posts: 0
Joined: Wed Jul 31, 2013 8:59 am

How to update multiple objects in a collection on a single click

Hi Marina
thanks for your help
I am putting a piece of my JS here
can you pls help..!!

var isChecked=$('input[name=mobilecheckbox_27]').is(':checked');
alert(isChecked); // Here i always get false whether it is checked or unchecked
//var localId=localStorage.getItem('object_id');
if(isChecked)
{
var parentEls = $("mobilecheckbox_27").parents("tr");
alert(parentEls); // It is also not showing any thing
$(parentEls).each(function(index) {
alert(index + ": " + $(this).text());
console.log(index + ": " + $(this).text());
});
}

thats why I am not able to proceed
and also let me know how to find particular child element after this

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to update multiple objects in a collection on a single click

Hi,
1) instead codevar isChecked = $('input[name=mobilecheckbox_27]').is(':checked');/code try codevar isChecked = Appery("mobilecheckbox_27").find("input").is(":checked");/code
2) [quote:]find particular child element[/quote] see http://api.jquery.com/children/

vipul
Posts: 0
Joined: Wed Jul 31, 2013 8:59 am

How to update multiple objects in a collection on a single click

with this script also it is showing false only

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How to update multiple objects in a collection on a single click

Please check checkbox name (it's case sensitive)

vipul
Posts: 0
Joined: Wed Jul 31, 2013 8:59 am

How to update multiple objects in a collection on a single click

Hi Marina
Checkbox name is correct, is there any property setting that i need to do for checkbox before running this script.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How to update multiple objects in a collection on a single click

Hi,

This should be working. Please give us a public link to your app.

Return to “Issues”