Yes, if following the example project, you will have downloaded some or all of the data on the spreadsheet and put it in a listview, which when you make a selection will return a selectionIndex, equal to the rowid (row number) you need.
Alternatively you can do much the same in your apps script (but remember to add 1, because javascript arrays start at 0 and not 1.)
je n'utilise pas de liste dans mon application , ni de sélection. Il faudrait que j'appelle (comme pour lire) les données déjà écrite de la sheet en cliquant sur le bouton et que je les modifie , est ce que c'est possible comme ça ?
As I said you can do it with your apps script, but you will need a column in your data that has unique values for it to work completely.
Let us say that the nom column has unique values, and nom is the first column of data in your sh (Sheet2), as an example.
In your script, after setting the spreadsheet and sheet (Sheet2), get the range values:
// put these with your other variables at the top of the script
rng = sh.getDataRange().getValues()
var rowid;
then iterate over the values for the nom column until you find a match, then you can get the rowid (row number) from the matched record.
// put this at the top of your Modifier section
// 0 is the first row, 1 is the second row, and so on...
for (var i=0;i<rng.length;i++) {
if ( e.parameter.nom == rng[i][0] ) {
rowid = (i+1);
}
}
You then use rowid to replace the data in your Modifier section of the script
oui c'est ce que je veux faire avec la colonne "nom" , je l'avais mis dans la ligne (parseInt(e.parameter.nom) au début mais c'était faux .
ok je vais corriger mon script avec vos informations.
j'ai essayé de placer les blocs mais ça ne fonctionne pas.
J'ai mis le contenu de la réponse dans le label "modifprenom11" et je retrouve toutes les données dans le label alors que que je veux que chaque donnée soit dans leur label pour pouvoir les modifier par la suite, et quand j'enlève le label je n'est plu de données, pouvez vous m'aider à corriger les blocs.
else if (e.parameter.func == "Modifier"){
rng = sh.getDataRange().getValues()
var rowid;
var data = JSON.parse('[' + e.parameter.DATA + ']');
for (var i=0;i<rng.length;i++) {
if ( e.parameter.nom == rng[i][0] ) {
rowid = (i+1);
sh.getRange(parseInt(rowid) + 1,1,1,data[0].length).setValues(data);
}
}
}
voilà func=writeReadReport
if (e.parameter.func == "WriteReadReport") {
var nom = e.parameter.nom ;
var date = e.parameter.date ;
var repas = e.parameter.repas ;
var change = e.parameter.change ;
var sieste = e.parameter.sieste ;
var soins = e.parameter.soins ;
var photo1 = e.parameter.photo1;
var photo2 = e.parameter.photo2;
var transmission = e.parameter.transmission ;
sh.appendRow([nom,date,repas,change,sieste,soins,photo1,photo2,transmission]);
SpreadsheetApp.flush();
var ref = [ ];
var rg = sh.getDataRange().getValues();
for (var i=0;i<rg.length;i++) {
if (rg[i][0] == nom) {
ref.push(rg[i][0]);
ref.push(Utilities.formatDate(rg[i][1],Session.getScriptTimeZone(), 'dd-MM-YYYY'));
ref.push(rg[i][2]);
ref.push(rg[i][3]);
ref.push(rg[i][4]);
ref.push(rg[i][5]);
ref.push(rg[i][6]);
ref.push(rg[i][7]);
ref.push(rg[i][8]);
}
}
j'ai modifié les blocs comme votre exemple mais c'est pareil j'ai toutes les données dans le même label ! est ce qu'il faut que je modifie le bloc web1 que j'ai mis plus haut (au niveau des traits bleu) ? je suis perdu
ah oui désolé, avant de montrer mes blocs j'ai une question , est ce que on peut écrire (qui envoie les données dans la sheet)/lire et modifier les données avec le même bouton ?
Do you want to read the existing data before modifying it, or after modifying it.
In any case, I suggest you just do one thing at a time, get that one thing working, then expand on what you want to do. You already have script that reads the data.