2017-01-04 5 views
0

gspのテーブルで作業していますが、チェックボックスの値に動的にロードしたいのですが...チェックボックスがチェックされていないと、テーブルに次のフィールドが表示されます。gspのチェックボックスの値にテーブルを動的にロードする方法

Name age country status 
Tom 35 USA  Confirm 
Nick 30 USA  ready 
Alex 25 Canada Inprogress 
Johny 20 UK  Waiting 

とチェックボックスがチェックされている場合、それは私が次のコード

<g:each in="${domainInstanceList}" status="i" var="domainInstance"> 
       <% 

        //color = "#ff4d4d" 
        color = "#FF6868" 
        def name = domainInstance?.name 
        def age= domainInstance?.age 
        def country= domainInstance?.country 

        if (domainInstance.isConfirm) { 
         //color = "#b3ccff" 
         color = "#56B9CC" 
         status = "Confirmed" 
        } 
        if(domainInstance.isReady){ 
          status = "Ready" 
        }else if(domainInstance.inProgress){ 
         status = "Inprogress" 
        }else if(domainInstance.iswaiting ){ 
         status = "Waiting" 
        } 


       %> 

       <tr style="background-color:${color}" class="${(i % 2) == 0 ? 'even' : 'odd'}"> 
         <td><b><g:link action="show" id="${domainInstance?.id}">${domainInstance?.prefix}${domainInstance?.number}</g:link></td></b></td> 

         <td>${name} 
         <td>${age} 
         <td>${country} 
         <td>${status} 

       </tr>    
      </g:each> 
を使用していたすべてのフィールド

Name age country status 
Tom 35 USA  Confirm 
Nick 30 USA  ready 
Alex 25 Canada Inprogress 
Johny 20 UK  Waiting 
Dipu 22 USA 
Jack 22 UK 

が表示されます

jqueryを使うことができますか? 私を助けてください
感謝

+0

jqueryなどを使用します。ステータスがない場合はクラス( 'nostatus')を追加し、イベントリスナーをチェックボックスに追加して 'nostatus'クラスを非表示にします – dynamo

+0

これらのブール値ではなく実際のステータスとしてステータスを使用してください。チェックボックスの上に交互に表示されるjqueryはフォームになりますが、今回は結果から必要ではないものを取り除きます。しかし、tbhはすべて面倒です。コントローラの 'domainInstanceList'を繰り返して必要な値を追加できます。個人的に見ると、私は追加的な入力が必要ではないと思っています - 常識やより良い方法 - https://github.com/vahidhedayati/grails-queuemail-plugin/blob/e35e382ce17c931e4ef08ac356102ca5ad1e590b/grails-app/domain/org/ grails/plugin/queuemail/Email.groovy#L36 – Vahid

+0

https://github.com/vahidhedayati/grails-queuemail-plugin/blob/e35e382ce17c931e4ef08ac356102ca5ad1e590b/src/main/groovy/org/grails/plugin/queuemail/enums/MessageStatusです。 groovy https://github.com/vahidhedayati/grails-queuemail-plugin/blob/e35e382ce17c931e4ef08ac356102ca5ad1e590b/grails-app/views/queueMail/_list.gsp#L115と実際の英語翻訳https:// githubを参照してください。/linux/grails-app/i18n/messages.properties#L127-L135 - これであなたはより良い方法を見せてくれました。 – Vahid

答えて

0

ませんjQueryのは、ここで答え、おそらく単純化していない...何名の必要性、年齢、国のローカルVARSを。あなたが表現を得るためにドメインインスタンスをマッサージしているなら、私はコントローラで作業を行い、gspを可能な限りシンプルにすることをお勧めします。[id、linkText、name、age、country、 status、color]をgspに渡します。

<g:each in="${personStatuses}" status="i" var="ps"> 
    <tr style="background-color:${ps.status}" class="${(i % 2) == 0 ? 'even' : 'odd'}"> 
    <td> 
     <b><g:link action="show" id="${ps.id}">${ps.linkText}</g:link></b> 
    </td> 
    <td>${ps.name}</td> 
    <td>${ps.age}</td> 
    <td>${ps.country}</td> 
    <td>${ps.status} 
    </tr>    
</g:each> 
関連する問題