Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript > Bibliothèques & Frameworks > jQuery
jQuery Forum d'entraide sur le framework jQuery. Avant de poster : Tutoriels jQuery, FAQ jQuery, Tous les tutoriels JavaScript, Toutes les FAQ JavaScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 01/04/2011, 11h54   #1
Invité de passage
 
Homme franck
Étudiant
Inscription : avril 2011
Messages : 3
Détails du profil
Informations personnelles :
Nom : Homme franck
Localisation : France

Informations professionnelles :
Activité : Étudiant
Secteur : Administration - Collectivité locale

Informations forums :
Inscription : avril 2011
Messages : 3
Points : 1
Points : 1
Par défaut Condition en JQuery

Bonjour,

Je débute avec ce langage et j'aimerais savoir si il est possible de mettre une condition comme decrit ci dessous.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
jQuery("#listProfil").jqGrid({
	    url:'index.php?pagePHP=GererProfilAjaxFonction&actionPHP=loadJqGridProfil&parametrePHP=\'\'&idApplication='+idApplication+'&code='+codeProfil+'&libelle='+libelleProfil,
	    datatype: 'json',
		height:'auto',
	    autowidth: true, // Largeur automatique (100%)
	    colNames:['Id Profil','Id Application','Code Application','Code Profil','Libellé Profil'],
		colModel:[
			{name:'id_profil',index:'id_profil', width:100, editable:true, hidden:true },
			{name:'id_application',index:'id_application', width:100, editable:true, hidden:true },

if ( idApplication == '' ){ 
			{name:'code_application',index:'code_application', width:100, editable:false, editoptions:{readonly:true}},
}else{
			{name:'code_application',index:'code_application', width:100, editable:false, , hidden:true },
}

			{name:'code_profil',index:'code_profil', width:100, editable:true, editrules:{required:true}, formoptions:{ rowpos:4, elmprefix:"*"}},
			{name:'libelle_profil',index:'libelle_profil', width:300, editable:true, editrules:{required:true}, formoptions:{ rowpos:5, elmprefix:"*"}}
			],
	    pager: '#pagerProfil',
	    rowNum:10,
	    rowList:[10,50,100],
	    sortname: 'code_profil',
	    sortorder: "asc",
	    viewrecords: true,
	});
Merci pour votre aide
franck87 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/04/2011, 04h18   #2
Membre habitué
 
Homme
Inscription : septembre 2008
Messages : 161
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Congo-Kinshasa

Informations forums :
Inscription : septembre 2008
Messages : 161
Points : 139
Points : 139
Envoyer un message via Skype™ à tresorunikin
Dans la plus part des cas pareils, on utilise l'opérateur ternaire!
Code :
(idApplication == '')?valeurSiOui : valeurSiNon;
reste à savoir ce que ca donne en JSon!
N'oublies pas de faire rapport!

Mais l'alternative, aussi moins crédible
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
var idApplication=...;
var AppropriateTab=new Array();
var SubAppropriateTab=new Array();
 
if ( idApplication == '' ){ 
			AppropriateTab['name']='code_application';
                       AppropriateTab['index']='code_application';
                       AppropriateTab['width']=100;
                       AppropriateTab['editable']=false;
                       //see
                       SubAppropriateTab['readonly']=true;
                       AppropriateTab['editoptions']=SubAppropriateTab;
}else{
 
			AppropriateTab['name']='code_application';
                       AppropriateTab['index']='code_application';
                       AppropriateTab['width']=100;
                       AppropriateTab['editable']=false;
                       AppropriateTab['hidden']=true;
}
//.....
jQuery("#listProfil").jqGrid({
	    url:'index.php?pagePHP=GererProfilAjaxFonction&actionPHP=loadJqGridProfil&parametrePHP=\'\'&idApplication='+idApplication+'&code='+codeProfil+'&libelle='+libelleProfil,
	    datatype: 'json',
		colModel:[
			{name:'id_profil',index:'id_profil', width:100, editable:true, hidden:true },
			{name:'id_application',index:'id_application', width:100, editable:true, hidden:true },
 
AppropriateTab,
 
			{name:'code_profil',index:'code_profil', width:100, 
//............................................................
à toi d'essayer. Au besoin meme, creer une fonction Array_to_json pour AppropriateTab. Voici l'idee http://stackoverflow.com/questions/4...-array-to-json
tresorunikin est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/04/2011, 15h28   #3
Invité de passage
 
Homme franck
Étudiant
Inscription : avril 2011
Messages : 3
Détails du profil
Informations personnelles :
Nom : Homme franck
Localisation : France

Informations professionnelles :
Activité : Étudiant
Secteur : Administration - Collectivité locale

Informations forums :
Inscription : avril 2011
Messages : 3
Points : 1
Points : 1
Bonjour tresorunikin

Merci pour votre aide, la 2ème solution fonctionne
franck87 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 04h10.


 
 
 
 
Partenaires

Hébergement Web