IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

jQuery Discussion :

Condition en JQuery


Sujet :

jQuery

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2011
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

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

    Informations forums :
    Inscription : Avril 2011
    Messages : 33
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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

  2. #2
    Membre très actif
    Homme Profil pro
    Inscrit en
    Septembre 2008
    Messages
    168
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Congo-Kinshasa

    Informations forums :
    Inscription : Septembre 2008
    Messages : 168
    Par défaut
    Dans la plus part des cas pareils, on utilise l'opérateur ternaire!
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    (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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2011
    Messages
    33
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

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

    Informations forums :
    Inscription : Avril 2011
    Messages : 33
    Par défaut
    Bonjour tresorunikin

    Merci pour votre aide, la 2ème solution fonctionne

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. la condition if avec Jquery
    Par artenis dans le forum jQuery
    Réponses: 6
    Dernier message: 13/03/2011, 23h13
  2. Condition background-color Jquery(php) ?
    Par castelcerf dans le forum jQuery
    Réponses: 5
    Dernier message: 22/10/2009, 03h18
  3. selecteur jquery dans une condition
    Par godot.beta dans le forum jQuery
    Réponses: 3
    Dernier message: 07/11/2008, 14h16
  4. [jquery] Condition de comparaison
    Par gtraxx dans le forum jQuery
    Réponses: 3
    Dernier message: 08/10/2008, 10h00
  5. Réponses: 2
    Dernier message: 19/09/2008, 09h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo