cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the xpath corresponding to delete button in ColumnListItem?

Former Member
0 Kudos

Hello experts,

    I have a question,how to get the xpath corresponding to delete button in columnListItem?

    what I want is when click delete button in item line,delete the item in table and delete the json item corresponding to table item.

    I have done with add item function:handleAddItem,but I don't know how to delete.

View.xml

<Table id="createItems" headerText="" items="{new>/Items}" >

  <columns>

  <Column>

  <header hAlign="Center" >

  <Label text="{i18n>PreqItem}" />

  </header>

  </Column>

  <Column hAlign="Center" >

  <header>

  <Label text="{i18n>Quantity}" />

  </header>

  </Column>

  <Column hAlign="Center" >

  <header>

  <Label text="{i18n>DelivDate}" />

  </header>

  </Column>

  <Column hAlign="Center" >

  <header>

  <Label text="{i18n>ShortText}" />

  </header>

  </Column>

  <Column hAlign="Right" width="3em">

  <header>

  <Button icon="sap-icon://add" press="handleAddItem" />

  </header>

  </Column>

  </columns>

  <ColumnListItem type="Navigation" press="handleLineItemPress" >

  <cells>

  <Input type="Text" placeholder="{i18n>PreqItem}" value="{new>PreqItem}" />

  <Input type="Text" placeholder="{i18n>Quantity}" value="{new>Quantity}" />

  <Input type="Text" placeholder="{i18n>DelivDate}" value="{new>DelivDate}" />

  <Input type="Text" placeholder="{i18n>ShortText}" value="{new>ShortText}" />

  <Button icon="sap-icon://delete" press="handleDeleteItem" />

  </cells>

  </ColumnListItem>

  </Table>

controller.js

handleAddItem : function(evt) {
var view = this.getView();
var bindingContext = view.getBindingContext("new");
var path = bindingContext.getPath();
var object = bindingContext.getModel().getProperty(path);
object.Items.push({Accounts : [], ServiceLines : [], TextLines : []});
bindingContext.getModel().setProperty(path, object);
},

handleDeleteItem : function(evt) {

},

binding json:

{

  "PreqNo" : "",

  "PrType" : "NB",

  "Testrun" : "",

  "Commit" : "",

  "Eerpid" : "",

  "Code" : "",

  "Message" : "",

  "ApplicationNumber" : "SP00115081200014",

  "ApplicationID" : "002573",

  "SN" : "13791_17",

  "Items" : [{

  "PreqNo" : "",

  "PreqItem" : "10",

  "DocType" : "NB",

  "PurGroup" : "A50",

  "CreatedBy" : "",

  "PreqName" : "liufang4",

  "DelivDate": "2015-08-11T00:00:00",

  "ShortText" : "Firoi行项目短文本",

  "Plant" : "2293",

  "Quantity" : "1.000",

  "Unit" : "AU",

  "ItemCat" : "9",

  "Acctasscat" : "K",

  "PurchOrg" : "1123",

  "Currency" : "CNY",

  "Accounts" : [{

  "PreqNo" : "",

  "PreqItem" : "00010",

  "SerialNo" : "01",

  "PreqQty" : "1.000",

  "GLAcct" : "4301010099",

  "CostCtr" : "1442060301"

  }],

  "ServiceLines" : [{

  "PreqNo" : "",

  "PreqItem" : "00010",

  "SerialNo" : "01",

  "ExtLine" : "0000000010",

  "Quantity" : "1.000",

  "BaseUom" : "AU",

  "GrPrice" : "1.0000",

  "ShortText" : "Firoi 服务行短文本 ShortText01"

  }],

  "TextLines" : [{

  "PreqNo" : "10090599",

  "PreqItem" : "00010",

  "TextId" : "B01",

  "TextLine" : "Firoi 行项目文本  Text Line01"

  }, {

  "PreqNo" : "10090599",

  "PreqItem" : "00010",

  "TextId" : "B02",

  "TextLine" : "Firoi 行项目文本  Text Line02"

  }]

  }],

  "TextLines" : [{

  "PreqNo" : "",

  "PreqItem" : "00000",

  "TextId" : "B01",

  "TextLine" : "Firoi 抬头文本"

  }]

}

thank you

best regards,

felix.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Now I know how to get the json path

handleDeleteItem : function(evt) {

      var sPath = evt.getSource().getBindingContext('new').getPath();

      alert(sPath);

  },

But How to delete node from JsonModel using jsonpath sPath?

Former Member
0 Kudos

Hi Santhosh,

   thanks for your reply.but I get some error,Does table have no such method "getSelectedIndex"??

Former Member
0 Kudos

It works by this way:

thank you very much.

best regards,

felix.

Answers (0)