Skip to Content
0

Removed.Problem Solved.

Jan 02 at 01:14 PM

119

avatar image

Removed.Problem Solved.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Richard Zhao
Jan 03 at 07:39 AM
1

Hello, Burak. Usually, we will create a JSON array model and bind it to table component.

step1: create JSON array and set model to this view.

this.getView().setModel(new JSONModel(data),"testdata");

step2: binging model to table component.

<Table id="table" rows="{testdata>/}" enableCellFilter="true" selectionMode="None">
   <columns>
      <Column width="110px" hAlign="Left" vAlign="Top">
          <m:Label text="Area" />
             <template>
                <m:Text text="{testdata>area}" width="auto" maxLines="3" wrapping="true"/>
             </template>
      </Column>
 <columns>

step3: when you change the value of text you could get the value by using the following way.

onEditRow_Press: function (oEvent) {
     var sPath = oEvent.getSource().getBindingContext("testdata").sPath;
     var oSelectedObject = this.getView().getModel("testdata").getProperty(sPath);
     console.log(oSelectedObject.area);
}
Show 5 Share
10 |10000 characters needed characters left characters exceeded

Hi,

Thanks for answer.

I was working without Json model.I know, I have to learn to work with a json model.

Can I do this code without jsonmodel ? I tryed like this but its not worked.Code working but input values not coming..

for (var i = 0; i < aItems.length; i++) {

var sPath = aItems[i].getBindingContext().getPath();
var oSelectedObject = this.getView().getModel().getProperty(sPath);
console.log(oSelectedObject.Insplot); //its working because Insplot coming from odata
console.log(oSelectedObject.Acklm); // its not working because value not coming from odata. Its input cell. Value entered on the screen.

}
0

Hello. Probably "oSelectedObject.Acklm" is not banding correct to the table column. thanks.

<Table id="table" rows="{testdata>/}" enableCellFilter="true" selectionMode="None">
   <columns>
      <Column width="110px" hAlign="Left" vAlign="Top">
          <m:Label text="Area" />
             <template>
                <m:Text text="{testdata>Acklm}" width="auto" maxLines="3" wrapping="true"/>
             </template>
      </Column>
 <columns>
0

Hi.

I not using Jsonmodel.. My table like this;

<Table id="lineItemsList" width="auto" items="{masterToDetailTable}" updateFinished="onListUpdateFinished"
noDataText="{i18n>detailLineItemTableNoDataText}" busyIndicatorDelay="{detailView>/lineItemTableDelay}" backgroundDesign="Transparent">
<columns>
<Column minScreenWidth="Tablet" demandPopin="true" hAlign="Left" width="2rem">
<Text text="{i18n>inspcharTb}"/>
<Column minScreenWidth="Tablet" demandPopin="true" hAlign="Left">
<Text text="{i18n>acklmTb}"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{= parseFloat(${Inspchar})}"/>
<Input value="{Acklm}"/>
</cells>
</ColumnListItem>
</items>
</Table>
0

Does object masterToDetailTable have "Acklm" property? If answer is no, It will not working.

0

masterToDetailTable have "Acklm" property.I am not getting an error.Data is entered from the screen.The value looking empty..

acklm.png (14.5 kB)
0
Irfan Gokak Jan 04 at 01:54 AM
0

Hi,

Try getting model from table object. Like below

Var data=oTabel.getModel().getData();
Data.yourPropertyName;
Show 3 Share
10 |10000 characters needed characters left characters exceeded

See long comment discussion under my answer.

0

Hi @Irfan Gokak

data is null..

Var data=oTabel.getModel().getData(); // NULL
0

Provide your model name inside getModel function.

0
Iftah Peretz
Jan 02 at 10:16 PM
0

Hi,

As you didn't specify any code snippets, I made my own assumptions. The code I was using is from here .

I pressed the "Edit" button and entered the value "dddd" into the first line (item) of column "Quantity" (see screenshot).

screen-shot-2018-01-03-at-120542-am.png

Now, to get this value, in the controller you do this (I could have used the predefined attribute this.oTable, but wanted to show you the full way)

var items = this.getView().byId("idProductsTable").getItems(), //Get the visible lines of the table
     dddd = items[0].getCells()[1].getValue();   //Get the value of the first line in the second column

and you got your value in dddd.


Show 5 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi All

We do not encourage going to items and to cells to get values.

Please use proper model binding.

Thanks

Dennis
Moderator

0

Hi Former Member the Moderator,

I think that code speaks louder than words, so I'll give the option you suggested to the OP. Please give an additional input if this is not what you meant. (it utilizes getData... and not getProperty as in Richard Zhao's answer - in the example I am working on, I found it easier to do than finding the path).

var dddd2 = this.oTable.getModel().getData().ProductCollection[0].Quantity; // oTable === getView().byId("idProductsTable")

As for your encouragement , can you please provide additional information onto why is that?

Plus, if we just want the data and not binding it, why are you saying "proper binding"?

When, then, would you recommend getItems usage, apart from setting the type (that can't be the only use of this API)? Same goes for getCells?

0
Former Member
Iftah Peretz

Hi Iftah

var dddd2 = this.oTable.getModel().getData().ProductCollection[0].Quantity; // oTable === getView().byId("idProductsTable")

is ok. and not

dddd = items[0].getCells()[1].getValue();

And (IMO) code will be cleaner to be written in this manner

var dddd2 = this.oTable.getModel().getProperty('/ProductCollection/0/Quantity');

Thanks

Dennis

1

Thanks. This code worked but is this structure not recommended?

I dont know how to work with jsonmodel..

0

Dennis has stated his recommendations.

As for the JSON model - Google it or post a new (specific as possible) question as this current question feels to me as answered.

0
Joseph BERTHE Jan 03 at 08:08 AM
0

Hello,

Why not using SubmitChange in OData model instead of. Theoretically it will do the job for you ;)

This will work only for an entity not a deep creation.

Regards,

Joseph

Show 1 Share
10 |10000 characters needed characters left characters exceeded

hello,

How do I get the data with submitChange? Can you inform me for submitChange?

0