2017-01-23 10 views
-1

ある特定の行(背景)にチェックボックスを設定します。sap.ui.table.Tableのエンティティを変更します。

私はsap.ui.table.Tableを使用しています。例:10件の注文書があります。入力フィールドに数字(EBELN)を書きたいと思います。テーブルのチェックボックスを "Enter"行の番号= EBELN)を "True"に変更し、フォーカスもこの行になければなりません。パラメータを使用して検索するにはどうすればよいですか?また、特にどのように変更できますか?

編集: ビュー:

<Table id="tableItemsId" enableBusyIndicator="true" rows="{items>/results}" 
      selectionMode="None" visibleRowCount="12"> 
      <toolbar> 
       <m:Toolbar> 
        <m:Input id="inEbeln" 
        placeholder="{i18n>Ebeln}" /> 
        <m:Button text="{i18n>Ebeln}" press="onPress" /> 
       </m:Toolbar> 
      </toolbar> 
      <columns> 
       <Column width="2rem"> 
        <m:Label text="{i18n>Check}" /> 
        <template> 
         <m:CheckBox 
          selected="{ 
          path: '{items>Check}', 
          type: 'sap.ui.model.type.String' 
         }" 
          editable="false" /> 
        </template> 
       </Column> 
       <Column width="6rem"> 
        <m:Label text="{i18n>Ebeln}" /> 
        <template> 
         <m:Text text="{items>Ebeln}" /> 
        </template> 
       </Column> 

たonPress:

onPress : function(oEvent) { 
       var that = this; 
       var oRouter = sap.ui.core.UIComponent.getRouterFor(this); 
       // Here I want to modify the row in the table "tableItemsId", where Ebeln = "inEbeln" 
+0

あなたが結合することによって、これをacheiveすることができますが、実装上のいくつかの詳細は歓迎:) –

+0

だろうどうしたらいいですか?私はsap.ui.tabe.Tableを持っています。テキストフィールドで私はエーベルンを書く。 enterを押すと、エントリを検索して変更します。 \t \t \t \t \t 'VAR sEbeln = this.getView()byId( "テキストフィールド") \t \t \t \t \t \t \t以降.getvalue()。 \t \t \t \t \t var oRouter = sap.ui.core.UIComponent.getRouterFor(this); \t \t \t \t \t var oTable = this.getView()。byId( "tableItemsId"); 'テーブルとsEbelnを持っていますが、どうすればこのebelnを検索できますか? – Mario

+0

テキストフィールドの内容を{/ value}のようなものにバインドし、チェックボックスの選択状態を{= $ {/ value} === $ {number}}にバインドします:p) –

答えて

0

私は小さなexample作成しました。イベントハンドラでは、すべての行をループした行の値を入力した値を比較し、それに応じてチェックボックスを設定します。

onPress : function(event) { 
    // this gets the value of the input field 
    let value = this.byId("inEbeln").getValue(); 
    if (!value || value.length === 0) { 
     return; 
    } 
    // loop through all rows and compare the entered value with the value in the row 
    let rows = this.byId("table").getRows(); 
    for (let i = 0; i < rows.length; i += 1) { 
     let row = rows[i]; 
     let cells = row.getCells(); 
     // cells[0] contains the Checkbox 
     // cells[1] contains the Text with Ebeln 
     cells[0].setSelected(value === cells[1].getText()); 
    } 
} 
関連する問題