2017-01-23 32 views
-1

我想在某一行(在後臺)中設置複選框爲true。修改sap.ui.table.Table中的實體

我使用sap.ui.table.Table ...示例:我有十個採購訂單,並且我想在輸入字段中輸入一個數字(EBELN),當我按下「Enter」表格中的複選框時在行中,數字= EBELN)應該修改爲「真」,焦點也應該在這一行上。如何使用參數進行搜索,特別是如何修改它?

編輯: 查看:

<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

您可以通過綁定達致這,但具體的實現一些細節會受到歡迎:) –

+0

我如何綁定它?我有一個sap.ui.tabe.Table。在一個文本框中,我寫了埃爾伯恩。按enter鍵我想搜索條目並修改它。 \t \t \t \t \t'變種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()); 
    } 
}