Reputation: 175
I know that sap.ui.table.Table lets you uses MultiToggle selectionMode. This adds a column with check boxes. Is there any way to use that check box to select a row and get that row value in my controller. I define my table control in a xml viw not in my controller. Using this setup would it be possible to retrieve a single row and get the values for the row. each row has a nested text area and label.
Here is my view
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:t="sap.ui.table"
controllerName="ariba.so.kaaguidedassistance.controller.GuidedAssistance" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:l="sap.ui.layout">
<Page title="Guided Assistance Flow Page">
<content>
<Toolbar id="toolbar1">
<Button text="update" press="onSubmit"></Button>
<Button text="add Guided Assistance QA" press="onAddGAQA"></Button>
<Button text="add Guided Assistance Keywords QA" press="onAddGAKQA"></Button>
<Button text="delete" press="onNavigateDelete"></Button>
<ToolbarSpacer/>
<ToolbarSpacer/>
</Toolbar>
<t:Table id="GAQA" rows="{guidedAssistanceGA>/data}" title="Guided Assistance QA" selectionMode="MultiToggle" visibleRowCount="7">
<t:Column width="11rem">
<Label text="ID"/>
<t:template>
<Label text="{guidedAssistanceGA>ID}"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="value_long"/>
<t:template>
<TextArea id="value_long" value="{guidedAssistanceGA>value_long}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Type"/>
<t:template>
<TextArea id="type" value="{guidedAssistanceGA>Type}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Action"/>
<t:template>
<TextArea id="Action" value="{guidedAssistanceGA>Action}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Button1"/>
<t:template>
<TextArea id="Button1" value="{guidedAssistanceGA>Button1}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Button2"/>
<t:template>
<TextArea id="Button2" value="{guidedAssistanceGA>Button2}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Button3"/>
<t:template>
<TextArea id="Button3" value="{guidedAssistanceGA>Button3}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Button4"/>
<t:template>
<TextArea id="Button4" value="{guidedAssistanceGA>Button4}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Button5"/>
<t:template>
<TextArea id="Button5" value="{guidedAssistanceGA>Button5}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Button6"/>
<t:template>
<TextArea id="Button6" value="{guidedAssistanceGA>Button6}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Active_Flag"/>
<t:template>
<TextArea id="Active_Flag" value="{guidedAssistanceGA>Active_Flag}" width="100%"/>
</t:template>
</t:Column>
</t:Table>
<Toolbar id="toolbar2">
<ToolbarSpacer/>
<ToolbarSpacer/>
</Toolbar>
<t:Table id="GAKQA" rows="{guidedAssistanceGAK>/data}" title="Guided Assistance Keywords QA" selectionMode="MultiToggle" visibleRowCount="7">
<t:Column width="11rem">
<Label text="Flow_ID"/>
<t:template>
<Label text="{guidedAssistanceGAK>Flow_ID}"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Keywords"/>
<t:template>
<TextArea id="Keywords" value="{guidedAssistanceGAK>Keywords}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Intersection1"/>
<t:template>
<TextArea id="Intersection1" value="{guidedAssistanceGAK>Intersection1}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Intersection2"/>
<t:template>
<TextArea id="Intersection2" value="{guidedAssistanceGAK>Intersection2}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Logic_Group"/>
<t:template>
<TextArea id="Logic_Group" value="{guidedAssistanceGAK>Logic_Group}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Logic_Order"/>
<t:template>
<TextArea id="Logic_Order" value="{guidedAssistanceGAK>Logic_Order}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="Points"/>
<t:template>
<TextArea id="Points" value="{guidedAssistanceGAK>Points}" width="100%"/>
</t:template>
</t:Column>
<t:Column width="11rem">
<Label text="ID"/>
<t:template>
<Label text="{guidedAssistanceGAK>ID}"/>
</t:template>
</t:Column>
</t:Table>
</content>
</Page>
</mvc:View>
I expect to retrieve the value for one of the rows in my controller. The value is in my label and text area.
Upvotes: 0
Views: 2401
Reputation: 626
just take a look in the API documentation of sap.ui.table. https://openui5.hana.ondemand.com/#/api/sap.ui.table.Table/methods/getContextByIndex
You can use getSelectedIndex or getSelectedIndices to determine which lines are currently selected. The method getContextByIndex gives you than the object for one row with all values.
Upvotes: 1