2017-01-10 12 views
0

ユーザーアクセスが"READ ONLY"に設定されている場合、すべてのフォーム入力要素をreadonlyとする必要があるという要件があります。すべてのUIフォームを読み取り専用/無効にしますか?

ウィジェットはテンプレートHTMLで指定され、対応するJSファイルで使用されるウィジェットベースのテンプレートアプローチを使用しています。

私は私のJS postcreate方法を次のコードで試してみました

:あなたはへの参照を取得する必要がウィジェットを無効にするには

var item=dojo.query("#showtech_log_title_pane"); // id of the content pane 

for (var i=0;i{ 
    dijit.byId(item[i]).set('readOnly',true); 
} 

Error : dijit by id-> undefined or null

また、

var container = dojo.query("#showtech_log_title_pane"); 

dojo.query('input', container).forEach(
    function(inputElem){ 
    inputElem.disabled = 'disabled'; 
    } 
) 

Error: Create Element not a method

+0

あなたのコードでは、構文エラーがあります。それらを修正すると良いスタートになるでしょう。 ;-) * disabled *属性はブール値なので、 'inputElem.disabled = true'でもtrueに評価されるので、文字列も同様に動作します(ただし、 'false'に設定するとfalseになります)。 – RobG

+0

2つ目のコードブロックの最初の行に2つの一重引用符を使用し、二重引用符で終わるエラーがあります。最初のブロックのforループ。 – philantrovert

+0

@RobGこれを行うと、次のエラーが表示されます。 コンテンツの解析とレンダリング中にエラーが発生しました。 ( 'xwt.widget.LicenseInfoDialogue'のコンストラクタを解決できません)。 私はpostCreateとaddonLoad関数のコードを入れます –

答えて

1

そのdisabled属性をtrueに設定します。

:あなたのケースでは

は、入力の囲みウィジェットを取得し、実施例の下には無効

に設定した後(つまり、作成したウィジェットの確認するために)のIDを持っているすべての入力を反復処理する必要があります

require([ "dojo/ready", 
 
\t \t "dojo/query", 
 
      "dijit/registry", 
 
      "dojo/_base/array", 
 
\t \t "dijit/TitlePane", 
 
\t \t "dojo/domReady!"], 
 
function (ready, query, registry, array, TitlePane) { 
 
\t ready(function(){ 
 
     //get all 
 
     var inputs = dojo.query('input', "enclosing_input_div"); 
 
     array.forEach(inputs,function(input){ 
 
     //check if a it's a created widget input (all widgets have theire own id) 
 
     \t if(input.id) 
 
      if(registry.byId(input.id)) // recheck if it it has enclosing widget 
 
      registry.byId(input.id).set("disabled",true) 
 
     }) 
 
    }); 
 
});
<link href="https://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" rel="stylesheet"/> 
 
<script> 
 
    dojoConfig= { 
 
     parseOnLoad: true, 
 
     async: true 
 
    }; 
 
</script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script> 
 

 
<body class="claro"> 
 
    <div id="enclosing_input_div"> 
 
    <div id="tp1" data-dojo-type="dijit/TitlePane" data-dojo-props="title: 'tp1'"> 
 
     <table> 
 
     <tr> 
 
      <td>TextField :</td> 
 
      <td><input data-dojo-type="dijit/form/TextBox"></td> 
 
     </tr> 
 
     <tr> 
 
      <td>NumberTextBox :</td> 
 
      <td><input id="numberTextBox" data-dojo-type="dijit/form/NumberTextBox"></td> 
 
     </tr> 
 
     <tr> 
 
      <td>Checkbox :</td> 
 
      <td><input id="checkBox" data-dojo-type="dijit/form/CheckBox"></td> 
 
     </tr> 
 
     <tr> 
 
      <td>RadioButton :</td> 
 
      <td><input id="radioButton" data-dojo-type="dijit/form/RadioButton"></td> 
 
     </tr> 
 
     </table> 
 
    </div> 
 
    </div> 
 
</body>

Here is also a fiddle

+0

これを行うことによって、私は次のエラーが表示されます:コンテンツの解析とレンダリング中にエラーが発生しました。 ( 'xwt.widget.LicenseInfoDialogue'のコンストラクタを解決できません)。私はpostCreate関数にコードを入れて、さらにポストクリエイト関数 –

+0

を書きました。組織化されたコード全体を投稿して、どこに変更を加えるかを確認してください。 –

+0

以下は私のプログラムの一部です。確認して機能を追加する場所を教えてください。 –

関連する問題