cancel
Showing results for 
Search instead for 
Did you mean: 

how to get values from search help tables

0 Kudos

hi all,

I am trying to get the value of selected item from search help table in input field and i am using sap.m.Table. for search help i have used sap.ui.ux3.ToolPopup  and I am using XML view.

xml code:


<ux:ToolPopup id="toolpopup" modal="true" inverted="flase"

  title="Selct Guest House Id" opener="aghid" closed="hclosed" >

  <!-- <Button icon="sap-icon://sys-cancel" press="helpClose"/> -->

  <Table selectionChange="selectitem" id="helptable" items="{/es_triconGhouse}" mode="SingleSelectMaster">

  <columns>

  <Column>

  <Label text="Guest House Id" />

  </Column>

  <Column>

  <Label text="Guest House Name" />

  </Column>

  </columns>

  <items>

  <ColumnListItem>

  <cells>

  <Text id="ttt" text="{GhouseID}" />

  <Text text="{GhouseName}" />

  </cells>

  </ColumnListItem>

  </items>

  </Table>

controller code:


hclosed: function (oEvent) {

       // return selected tabled line/value

       var oCore = sap.ui.getCore();

       var tId = oCore.byId("aghid");

       alert(tId);

       var oContext = tId.getContextByIndex(tId.getSelectedItem());

       alert(oContext);

       if (oContext) {

             var oSel = oContext.getModel().getProperty(oContext.getPath());

            tId.setValue(oSel["GhouseID"]);

       };

   }

so i am getting the table id but the error is occurring on line no 6 .

so can anyone please help me to get it done.

Thanks and regards,

Prashant

View Entire Topic
Qualiture
Active Contributor
0 Kudos

It seems you're not getting the id of your table (which has id 'helptable') but the opener control 'aghid', whatever that may be.

0 Kudos

Hello Robin, Sorry about that id, i forgot to change it. But the error is same i.e getSelectedIndex(). Thanks, Prashant

Qualiture
Active Contributor
0 Kudos

That's right, because the sap.m.Table does not have a getSelectedIndex() method.

However, in your view it seems you are using sap.m.Table, but in your controller you are using methods from sap.ui.Table, and the two are totally different. You should use the API for the correct table.