cancel
Showing results for 
Search instead for 
Did you mean: 

Sapui5 TableSelect Dialog Model

Former Member
0 Kudos

Hi Team, I am not able to bind the model for the table select model. Please see the code below

i will get responce when user clicks and that esponce i am setting model to dialog:

opendialog : function(response){

  var oModel = new sap.ui.model.json.JSONModel();

  oModel.setData(response);

  if (! this._oDialog) {

  this._oDialog = sap.ui.xmlfragment("ven.app.view.Dialog", this);

  this._oDialog.setModel(oModel);

  }

  this.getView().addDependent(this._oDialog);

  this._oDialog.open();

  }

But i see no records found, even though there are records in response

this is fragment

<core:FragmentDefinition

  xmlns="sap.m"

  xmlns:core="sap.ui.core">

  <TableSelectDialog

  noDataText="No Products Found"

  title="Tax Codes"

  items="{'/results'}">

  <ColumnListItem>

  <cells>

  <Text text="{DocumentNo}" />

  <Text text="{TaxCode}" />

  </cells>

  </ColumnListItem>

  <columns>

  <Column width="12em">

  <header>

  <Text text="DocumentNo" />

  </header>

  </Column>

  <Column width="12em">

  <header>

  <Text text="TaxCode" />

  </header>

  </Column>

  </columns>

  </TableSelectDialog>

</core:FragmentDefinition>

Also i want to remove search option, but i dont see any way to remove that.

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

NagaPrakashT
Contributor
0 Kudos

Hi Praveen,

Here is the working code.Hope this helps you.

Table Select Dialog Fragment Definition


<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">

  <TableSelectDialog noDataText="No Employees Found" title="Select Employee"

items="{/value}">

  <columns>

  <Column>

  <Text text="Person ID" />

  </Column>

  <Column>

  <Text text="Age" />

  </Column>

  <Column>

  <Text text="Phone" />

  </Column>

  <Column>

  <Text text="City" />

  </Column>

  <Column>

  <Text text="Country" />

  </Column>

  </columns>

  <items>

  <ColumnListItem>

  <cells>

  <ObjectIdentifier title="{PersonID}" />

  <Text text="{Age}" />

  <Text text="{Phone}" />

  <Text text="{Address/City}" />

  <Text text="{Address/Country}" />

  </cells>

  </ColumnListItem>

  </items>

  </TableSelectDialog>

</core:FragmentDefinition>

Controller.js


  onInit: function() {

    var oModel = new sap.ui.model.json.JSONModel();

    oModel.loadData("http://services.odata.org/V3/OData/OData.svc/PersonDetails");   

   sap.ui.getCore().setModel(oModel);

},

onPress: function() {

      this._oDialog = sap.ui.xmlfragment("tableselectdialog.TableDialog", this);

       this._oDialog.open();

}

View.xml


<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"

  controllerName="tableselectdialog.TableSelectDialog"

xmlns:html="http://www.w3.org/1999/xhtml">

  <Page title="Title">

  <content>

  <Button press="onPress" text="Click here to open Table Select Dialog" />

  </content>

  </Page>

</core:View>

Thanks,

Naga

Former Member
0 Kudos

Thankyou all.. Its working

agentry_src
Active Contributor
0 Kudos

Please mark this Discussion with a Correct Answer (closes, but does not lock the Discussion) and Helpful Answer where appropriate. See http://scn.sap.com/community/support/blog/2013/04/03/how-to-close-a-discussion-and-why   Even if you discovered the solution without any outside contributions, it helps others to understand what the solution turned out to be. 

Do not use Assumed Answered as it confuses anyone looking for the specific answer.  If you dig into the Getting Started link (top right of each SCN page), you are only instructed to mark Helpful or Correct Answers to Discussion responses. 

Thanks, Mike (Moderator)

SAP Technology RIG

Former Member
0 Kudos

This message was moderated.

Answers (3)

Answers (3)

karthikarjun
Active Contributor
0 Kudos

Everything is fine.

One small changes in fragments.

<TableSelectDialog

  noDataText="No Products Found"

  title="Tax Codes"

  items="{'/results'}">

  <ColumnListItem>

  <cells>

It is because of Path. Could you please refer below code.

Items="{path:'/results'}"

Thanks,

KA

saivellanki
Active Contributor
0 Kudos

Hi Praveen,

Are you sure you were able to get data in the response argument passed from some other function?

Just a guess, try like this and check-



  var oModel = new sap.ui.model.json.JSONModel();

  oModel.attachRequestCompleted(function(){

  oModel.setData(response);

  });

Also check in console, what you are getting -


console.log(this._oDialog.getModel())


Regards,

Sai Vellanki.

Former Member
0 Kudos

Yes Sai, i kept a breakpoints and checked everything looks fine, got repsonse and even dialog got the model with data, but when dialog opens i see no records found..

saivellanki
Active Contributor
0 Kudos

Praveen,

Instead of setting the model to dialog. Can you set it to view and check?


  if (! this._oDialog) {

  this._oDialog = sap.ui.xmlfragment("ven.app.view.Dialog", this);

  this.getView().setModel(oModel);

  }

Regards,

Sai Vellanki.

karthikarjun
Active Contributor
0 Kudos

Could you please share your "response" data?


Thanks,

KA

Former Member
0 Kudos

Hi Karthik,

this is the result i got

results: [{

DocumentNo: "200002"

GENERATED_ID: "6219410000"

PostingDate: "20151022"

TaxCode: "03"

WithHoldTaxAmt: "0"

WithHoldTaxBaseAmt: "7116"

}]